Returns the nth character of a character->occurrence map
426842
def nth_char(char_map, index):
    """"""
    for char in char_map:
        if index < char_map[char]:
            return char
        index = index - char_map[char]
    return None
1288152
def _nth_str(n):
    """"""
    if n % 10 == 1 and n % 100 != 11:
        return "%dst" % n
    if n % 10 == 2 and n % 100 != 12:
        return "%dnd" % n
    if n % 10 == 3 and n % 100 != 13:
        return "%drd" % n
    return "%dth" % n
1235386
def _soln2str(self, soln, fancy=False):
        """"""
        chars = list()
        for r in range(1, 10):
            for c in range(1, 10):
                if fancy and c in (4, 7):
                    chars.append("|")
                chars.append(self._get_val(soln, r, c))
            if fancy and r != 9:
                chars.append("\n")
                if r in (3, 6):
                    chars.append("---+---+---\n")
        return "".join(chars)
693052
public static int occurrencesOf(String string, String singleCharacter)
    {
        if (singleCharacter.length() != 1)
        {
            throw new IllegalArgumentException("Argument should be a single character: " + singleCharacter);
        }
        return StringIterate.occurrencesOfChar(string, singleCharacter.charAt(0));
    }
1072781
def charindex(self, line, char, context):
        """"""
        #Make sure that we have chars and lines to work from
        if len(context.bufferstr) > 0 and len(self._chars) == 0:
            #Add one for the \n that we split on for each line
            self._chars = [ len(x) + 1 for x in context.bufferstr ]
            #Remove the last line break since it doesn't exist
            self._chars[-1] -= 1

            #Now we want to add up the number of characters in each line
            #as the lines progress so that it is easy to search for the
            #line of a single character index
            total = 0
            for i in range(len(self._chars)):
                total += self._chars[i]
                self._chars[i] = total
        
        return self._chars[line - 1] + char
315566
public static int findNotIn(byte[] arra, int start, int limit,
                                byte[] charset) {

        int k = 0;

        for (; k < limit; k++) {
            for (int i = 0; i < charset.length; i++) {
                if (arra[k] == charset[i]) {
                    continue;
                }
            }

            return k;
        }

        return -1;
    }
1300242
def finditer_noregex(string, sub, whole_word):
    
    start = 0
    while True:
        start = string.find(sub, start)
        if start == -1:
            return
        if whole_word:
            if start:
                pchar = string[start - 1]
            else:
                pchar = ' '
            try:
                nchar = string[start + len(sub)]
            except IndexError:
                nchar = ' '
            if nchar in DocumentWordsProvider.separators and \
                    pchar in DocumentWordsProvider.separators:
                yield start
            start += len(sub)
        else:
            yield start
            start += 1
797334
def match(self, chars):
        """"""
        start_index = self.next_index
        for char in self:
            if char not in chars:
                self.next_index -= 1
                break
        return self[start_index:self.next_index]
832457
def char_conv(out):
    
    out_conv = list()
    for i in range(out.shape[0]):
        tmp_str = ''
        for j in range(out.shape[1]):
            if int(out[i][j]) >= 0:
                tmp_char = int2char(int(out[i][j]))
                if int(out[i][j]) == 27:
                    tmp_char = ''
                tmp_str = tmp_str + tmp_char
        out_conv.append(tmp_str)
    return out_conv
556505
def eliminate_repeats(text):
    ''''''
    
    bannedwords = read_file('stopwords.txt')
    alphabet = 'abcdefghijklmnopqrstuvwxyz'
    words = text.split()
    standardwords = []
    for word in words:
        newstr = ''
        for char in word:
            if char in alphabet or char in alphabet.upper():
               newstr += char
        if newstr not in standardwords and newstr != '' and newstr not in bannedwords:
            standardwords.append(newstr)
        
    return map(lambda x: x.lower(),standardwords)
754531
def nth(lst, n):
    """"""
    expect_type(n, (String, Number), unit=None)

    if isinstance(n, String):
        if n.value.lower() == 'first':
            i = 0
        elif n.value.lower() == 'last':
            i = -1
        else:
            raise ValueError("Invalid index %r" % (n,))
    else:
        # DEVIATION: nth treats lists as circular lists
        i = n.to_python_index(len(lst), circular=True)

    return lst[i]
95765
def longest_non_repeat_v2(string):
    
    if string is None:
        return 0
    start, max_len = 0, 0
    used_char = {}
    for index, char in enumerate(string):
        if char in used_char and start <= used_char[char]:
            start = used_char[char] + 1
        else:
            max_len = max(max_len, index - start + 1)
        used_char[char] = index
    return max_len
608816
def get_char_range(self, start, end, increment=None):
        """"""

        increment = int(increment) if increment else 1
        if increment < 0:
            increment = -increment

        # Zero doesn't make sense as an incrementer
        # but like bash, just assume one
        if increment == 0:
            increment = 1

        inverse = start > end
        alpha = _nalpha if inverse else _alpha

        start = alpha.index(start)
        end = alpha.index(end)

        if start < end:
            return (c for c in alpha[start:end + 1:increment])

        else:
            return (c for c in alpha[end:start + 1:increment])
401998
function countCharFromStr(str, ch) {
    let strArr = [...str];
    let count = 0;
    for (let k in strArr) {
        if (strArr[k] === ch) {
            count++
        }
    }
    return count
}
276526
def _sequence(self, i):
        """"""

        result = ['[']
        end_range = 0
        escape_hyphen = -1
        removed = False
        last_posix = False

        c = next(i)
        if c in ('!', '^'):
            # Handle negate char
            result.append('^')
            c = next(i)
        if c == '[':
            last_posix = self._handle_posix(i, result, 0)
            if not last_posix:
                result.append(re.escape(c))
            c = next(i)
        elif c in ('-', ']'):
            result.append(re.escape(c))
            c = next(i)

        while c != ']':
            if c == '-':
                if last_posix:
                    result.append('\\' + c)
                    last_posix = False
                elif i.index - 1 > escape_hyphen:
                    # Found a range delimiter.
                    # Mark the next two characters as needing to be escaped if hyphens.
                    # The next character would be the end char range (s-e),
                    # and the one after that would be the potential start char range
                    # of a new range (s-es-e), so neither can be legitimate range delimiters.
                    result.append(c)
                    escape_hyphen = i.index + 1
                    end_range = i.index
                elif end_range and i.index - 1 >= end_range:
                    if self._sequence_range_check(result, '\\' + c):
                        removed = True
                    end_range = 0
                else:
                    result.append('\\' + c)
                c = next(i)
                continue
            last_posix = False

            if c == '[':
                last_posix = self._handle_posix(i, result, end_range)
                if last_posix:
                    c = next(i)
                    continue

            if c == '\\':
                # Handle escapes
                subindex = i.index
                try:
                    value = self._references(i, True)
                except PathNameException:
                    raise StopIteration
                except StopIteration:
                    i.rewind(i.index - subindex)
                    value = r'\\'
            elif c == '/':
                if self.pathname:
                    raise StopIteration
                value = c
            elif c in SET_OPERATORS:
                # Escape &, |, and ~ to avoid &&, ||, and ~~
                value = '\\' + c
            else:
                # Anything else
                value = c

            if end_range and i.index - 1 >= end_range:
                if self._sequence_range_check(result, value):
                    removed = True
                end_range = 0
            else:
                result.append(value)

            c = next(i)

        result.append(']')
        # Bad range removed.
        if removed:
            value = "".join(result)
            if value == '[]':
                # We specified some ranges, but they are all
                # out of reach.  Create an impossible sequence to match.
                result = ['[^%s]' % ('\x00-\xff' if self.is_bytes else uniprops.UNICODE_RANGE)]
            elif value == '[^]':
                # We specified some range, but hey are all
                # out of reach. Since this is exclusive
                # that means we can match *anything*.
                result = ['[%s]' % ('\x00-\xff' if self.is_bytes else uniprops.UNICODE_RANGE)]
            else:
                result = [value]

        if self.pathname or self.after_start:
            return self._restrict_sequence() + ''.join(result)

        return ''.join(result)
4085
def _case_format(self, occur):
        """""" 
        if self.occur == 1:
            self.attr["nma:implicit"] = "true"
        ccnt = len(self.rng_children())
        if ccnt == 0: return "<empty/>%s"
        if ccnt == 1 or not self.interleave:
            return self.start_tag("group") + "%s" + self.end_tag("group")
        return (self.start_tag("interleave") + "%s" +
                self.end_tag("interleave"))
387050
function strRepeat(str, n) {
    var res = '';
    do {
        if (n & 1) {
            res += str;
        }

        str += str;
    } while (n = n >> 1);

    return res;
}