dhyuti-n/xlcost-variable-roles huggingface dataset:
Python program:
def isVowel ( c ) :
    if ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' ) :
        return True
    return False
def checkPossibility ( s1 , s2 ) :
    l1 = len ( s1 )
    l2 = len ( s2 )
    if ( l1 != l2 ) :
        return False
    for i in range ( l1 ) :
        if ( isVowel ( s1 [ i ] ) and isVowel ( s2 [ i ] ) ) :
            continue
        elif ( ( isVowel ( s1 [ i ] ) ) == False and ( isVowel ( s2 [ i ] ) == False ) ) :
            continue
        else :
            return False
    return True
S1 , S2 = " abcgle " , " ezggli "
if ( checkPossibility ( S1 , S2 ) ) :
    print ( " Yes " )
else :
    print ( " No " )

Index/key variables: i
Iterator variables: i
Python program:
def generateString ( A , B ) :
    rt = " "
    while ( 0 < A or 0 < B ) :
        if ( A < B ) :
            if ( 0 < B ) :
                rt = rt + ' b '
                B -= 1
            if ( 0 < B ) :
                rt += ' b '
                B -= 1
            if ( 0 < A ) :
                rt += ' a '
                A -= 1
        elif ( B < A ) :
            if ( 0 < A ) :
                rt += ' a '
                A -= 1
            if ( 0 < A ) :
                rt += ' a '
                A -= 1
            if ( 0 < B ) :
                rt += ' b '
                B -= 1
        else :
            if ( 0 < A ) :
                rt += ' a '
                A -= 1
            if ( 0 < B ) :
                rt += ' b '
                B -= 1
    print ( rt )
if __name__ == " _ _ main _ _ " :
    A = 2
    B = 6
    generateString ( A , B )

Accumulator variables: A, B, rt
Python program:
def getSubSeq ( s , n ) :
    res = " "
    cr = 0
    while ( cr < n ) :
        mx = s [ cr ]
        for i in range ( cr + 1 , n ) :
            mx = max ( mx , s [ i ] )
        lst = cr
        for i in range ( cr , n ) :
            if ( s [ i ] == mx ) :
                res += s [ i ]
                lst = i
        cr = lst + 1
    return res
if __name__ == ' _ _ main _ _ ' :
    s = " geeksforgeeks "
    n = len ( s )
    print ( getSubSeq ( s , n ) )

Index/key variables: cr, i
Accumulator variables: res
Iterator variables: i
Python program:
def isValid ( string ) :
    k = 0 ;
    operands = [ " " ] * 5 ;
    operators = [ " " ] * 4 ;
    ans = 0 ; ans1 = 0 ; ans2 = 0 ;
    for i in range ( len ( string ) ) :
        if ( string [ i ] != ' + ' and string [ i ] != ' = ' and string [ i ] != ' - ' ) :
            operands [ k ] += string [ i ] ;
        else :
            operators [ k ] = string [ i ] ;
            if ( k == 1 ) :
                if ( operators [ k - 1 ] == ' + ' ) :
                    ans += int ( operands [ k - 1 ] ) + int ( operands [ k ] ) ;
                if ( operators [ k - 1 ] == ' - ' ) :
                    ans += int ( operands [ k - 1 ] ) - int ( operands [ k ] ) ;
            if ( k == 2 ) :
                if ( operators [ k - 1 ] == ' + ' ) :
                    ans1 += ans + int ( operands [ k ] ) ;
                if ( operators [ k - 1 ] == ' - ' ) :
                    ans1 -= ans - int ( operands [ k ] ) ;
            if ( k == 3 ) :
                if ( operators [ k - 1 ] == ' + ' ) :
                    ans2 += ans1 + int ( operands [ k ] ) ;
                if ( operators [ k - 1 ] == ' - ' ) :
                    ans2 -= ans1 - int ( operands [ k ] ) ;
            k += 1
    if ( ans2 == int ( operands [ 4 ] ) ) :
        return True ;
    else :
        return False ;
if __name__ == " _ _ main _ _ " :
    string = "2 ▁ + ▁ 5 ▁ + ▁ 3 ▁ + ▁ 1 ▁ = ▁ 11" ;
    if ( isValid ( string ) ) :
        print ( " Valid " ) ;
    else :
        print ( " Invalid " ) ;

Index/key variables: i, k
Accumulator variables: ans, ans1, ans2
Iterator variables: i
Python program:
def countSubStr ( str , l , k ) :
    count = 0
    for i in range ( l ) :
        n = 0
        for j in range ( i , l , 1 ) :
            n = n * 10 + ( ord ( str [ j ] ) - ord ( '0' ) )
            if ( n % k == 0 ) :
                count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    str = "33445"
    l = len ( str )
    k = 11
    print ( countSubStr ( str , l , k ) )

Index/key variables: j
Accumulator variables: count
Iterator variables: i, j
Python program:
def Colour_Combination ( s ) :
    temp = s [ 0 ]
    for i in range ( 1 , len ( s ) , 1 ) :
        if ( temp != s [ i ] ) :
            if ( ( temp == ' B ' or temp == ' G ' ) and ( s [ i ] == ' G ' or s [ i ] == ' B ' ) ) :
                temp = ' Y '
            elif ( ( temp == ' B ' or temp == ' Y ' ) and ( s [ i ] == ' Y ' or s [ i ] == ' B ' ) ) :
                temp = ' G '
            else :
                temp = ' B '
    return temp
if __name__ == ' _ _ main _ _ ' :
    s = " GBYGB "
    print ( Colour_Combination ( s ) )

Index/key variables: i
Iterator variables: i
Python program:
def reverse ( str1 , x ) :
    n = ( len ( str1 ) - x ) // 2
    for i in range ( n ) :
        print ( str1 [ i ] , end = " " )
    for i in range ( n + x - 1 , n - 1 , - 1 ) :
        print ( str1 [ i ] , end = " " )
    for i in range ( n + x , len ( str1 ) ) :
        print ( str1 [ i ] , end = " " )
str1 = " geeksforgeeks "
x = 3
reverse ( str1 , x )

Index/key variables: i
Iterator variables: i
Python program:
def getSteps ( str , i , j , n ) :
    k = i + 1
    steps = 0
    ch = str [ i ]
    while ( k <= j ) :
        if ( str [ k ] != ch ) :
            steps = steps + 1
            ch = str [ k ]
        k = k + 1
    return steps
def getMinSteps ( str , i , j , n ) :
    if ( j < i ) :
        temp = i
        i = j
        j = temp
    stepsToRight = getSteps ( str , i , j , n )
    stepsToLeft = getSteps ( str , 0 , i , n ) + getSteps ( str , j , n - 1 , n )
    if ( str [ 0 ] != str [ n - 1 ] ) :
        stepsToLeft = stepsToLeft + 1
    return min ( stepsToLeft , stepsToRight )
str = " SSNSS "
n = len ( str )
i = 0
j = 3
print ( getMinSteps ( str , i , j , n ) )

Index/key variables: i, k
Python program:
MAX_CHAR = 256
def countSubStrings ( s , anotherStr , k ) :
    illegal = [ False ] * MAX_CHAR
    for i in range ( len ( anotherStr ) ) :
        illegal [ ord ( anotherStr [ i ] ) ] = True
    us = set ( )
    for i in range ( len ( s ) ) :
        ss = " "
        count = 0
        for j in range ( i , len ( s ) ) :
            if ( illegal [ ord ( s [ j ] ) ] ) :
                count += 1
            ss = ss + s [ j ]
            if ( count <= k ) :
                us . add ( ss )
            else :
                break
    return len ( us )
if __name__ == " _ _ main _ _ " :
    string = " acbacbacaa "
    anotherStr = " abcdefghijklmnopqrstuvwxyz "
    k = 2
    print ( countSubStrings ( string , anotherStr , k ) )

Index/key variables: i, j
Accumulator variables: count, us
Iterator variables: i, j
Python program:
import math as mt
def countPairs ( bracks , num ) :
    openn = dict ( )
    close = dict ( )
    cnt = 0
    for i in range ( num ) :
        s = bracks [ i ]
        l = len ( s )
        op , cl = 0 , 0
        for j in range ( l ) :
            if ( s [ j ] == ' ( ' ) :
                op += 1
                if ( op ) :
                    op -= 1
                    cl += 1
        if ( op and cl == 0 ) :
            if op in openn . keys ( ) :
                openn [ op ] += 1
            else :
                openn [ op ] = 1
        if ( cl and op == 0 ) :
            if cl in openn . keys ( ) :
                close [ cl ] += 1
            else :
                close [ cl ] = 1
        if ( op == 0 and cl == 0 ) :
            cnt += 1
    cnt = cnt // 2
    for it in openn :
        cnt += min ( openn [ it ] , close [ it ] )
    return cnt
bracks = [ " ) ( ) ) " , " ) " , " ( ( " , " ( ( " , " ( " , " ) " , " ) " ]
num = len ( bracks )
print ( countPairs ( bracks , num ) )

Index/key variables: cl, i, it, j, op
Accumulator variables: cnt
Iterator variables: i, it, j
Python program:
def decrypt ( s , l ) :
    ans = " "
    if ( l % 2 ) :
        cnt = 0
        indl = 0
        indr = l - 1
        while ( len ( ans ) != l ) :
            if ( cnt % 2 == 0 ) :
                ans += s [ indl ]
                indl += 1
            else :
                ans += s [ indr ]
                indr -= 1
            cnt += 1
    else :
        cnt = 0
        indl = 0
        indr = l - 1
        while ( len ( ans ) != l ) :
            if ( cnt % 2 == 0 ) :
                ans += s [ indr ]
                indr -= 1
            else :
                ans += s [ indl ]
                indl += 1
            cnt += 1
    string = list ( ans )
    string . reverse ( )
    ans = ' ' . join ( string )
    return ans
if __name__ == " _ _ main _ _ " :
    s = " segosegekfrek "
    l = len ( s )
    print ( decrypt ( s , l ) )

Index/key variables: indl, indr
Accumulator variables: ans, cnt
Python program:
def removeChars ( s ) :
    modifiedStr = " "
    modifiedStr += s [ 0 ]
    for i in range ( 1 , len ( s ) ) :
        if ( s [ i ] . isupper ( ) and s [ i - 1 ] . islower ( ) or s [ i ] . islower ( ) and s [ i - 1 ] . isupper ( ) ) :
            modifiedStr += s [ i ]
    return modifiedStr
if __name__ == " _ _ main _ _ " :
    s = " GeeksForGeeks "
    print ( removeChars ( s ) )

Index/key variables: i
Accumulator variables: modifiedStr
Iterator variables: i
Python program:
def pangramCost ( arr , string ) :
    cost = 0
    occurred = [ False ] * 26
    for i in range ( len ( string ) ) :
        occurred [ ord ( string [ i ] ) - ord ( ' a ' ) ] = True
    for i in range ( 26 ) :
        if ( not occurred [ i ] ) :
            cost += arr [ i ]
    return cost
if __name__ == " _ _ main _ _ " :
    arr = [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 ]
    string = " abcdefghijklmopqrstuvwz "
    print ( pangramCost ( arr , string ) )

Index/key variables: i
Accumulator variables: cost
Iterator variables: i
Python program:
def getFrequencies ( string ) :
    freq = [ 0 ] * 26
    for i in range ( len ( string ) ) :
        freq [ ord ( string [ i ] ) - ord ( ' a ' ) ] += 1
    return freq
def countMinParts ( string ) :
    n = len ( string )
    freq = getFrequencies ( string )
    oddFreq = [ ]
    evenFreq = [ ]
    sumEven = 0
    for i in range ( 26 ) :
        if freq [ i ] == 0 :
            continue
        if freq [ i ] % 2 == 0 :
            evenFreq . append ( freq [ i ] )
        else :
            oddFreq . append ( freq [ i ] )
    for i in range ( len ( evenFreq ) ) :
        sumEven += evenFreq [ i ]
    if len ( oddFreq ) == 0 :
        return 1
    if sumEven == 0 :
        if len ( oddFreq ) == 1 :
            return 1
        return 0
    i = 0
    while ( i < len ( oddFreq ) ) :
        if ( ( sumEven / 2 ) % len ( oddFreq ) == 0 ) :
            return len ( oddFreq )
        if ( oddFreq [ i ] == 1 ) :
            i += 1
            continue
        sumEven += 2
        oddFreq [ i ] = oddFreq [ i ] - 2
    return n
if __name__ == " _ _ main _ _ " :
    s = " noonpeep "
    print ( countMinParts ( s ) )

Index/key variables: i
Accumulator variables: evenFreq, oddFreq, sumEven
Iterator variables: i
Python program:
def printPattern ( s , n ) :
    print ( ' ' . join ( s ) )
    i , j = 0 , n - 1
    while i < j :
        s [ i ] , s [ j ] = s [ j ] , s [ i ]
        i += 1
        j -= 1
    i , j = 0 , n - 1
    while j - i > 1 :
        s [ i ] , s [ j ] = ' * ' , ' * '
        print ( ' ' . join ( s ) )
        i += 1
        j -= 1
if __name__ == " _ _ main _ _ " :
    s = " geeks "
    n = len ( s )
    printPattern ( list ( s ) , n )

Index/key variables: i, j
Python program:
def prime ( n ) :
    if ( n <= 1 ) :
        return False
    if ( n <= 3 ) :
        return True
    if ( n % 2 == 0 or n % 3 == 0 ) :
        return False
    i = 5
    while i * i <= n :
        if ( n % i == 0 or n % ( i + 2 ) == 0 ) :
            return False
        i += 6
    return True
def isVowel ( c ) :
    c = c . lower ( )
    if ( c == ' a ' or c == ' e ' or c == ' i ' or c == ' o ' or c == ' u ' ) :
        return True
    return False
def isValidString ( word ) :
    cnt = 0 ;
    for i in range ( len ( word ) ) :
        if ( isVowel ( word [ i ] ) ) :
            cnt += 1
    if ( prime ( cnt ) ) :
        return True
    else :
        return False
if __name__ == " _ _ main _ _ " :
    s = " geeksforgeeks "
    if ( isValidString ( s ) ) :
        print ( " YES " )
    else :
        print ( " NO " )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
def printExpansion ( str ) :
    suff = " "
    for i in range ( len ( str ) - 1 , - 1 , - 1 ) :
        suff = suff + str [ i ]
        print ( suff , end = " " )
if __name__ == " _ _ main _ _ " :
    str = " geeks "
    printExpansion ( str )

Index/key variables: i
Iterator variables: i
Python program:
import math as mt
def logicalExpressionEvaluation ( string ) :
    arr = list ( )
    n = len ( string )
    for i in range ( n - 1 , - 1 , - 1 ) :
        if ( string [ i ] == " [ " ) :
            s = list ( )
            while ( arr [ - 1 ] != " ] " ) :
                s . append ( arr [ - 1 ] )
                arr . pop ( )
            arr . pop ( )
            if ( len ( s ) == 3 ) :
                if s [ 2 ] == "1" :
                    arr . append ( "0" )
                else :
                    arr . append ( "1" )
            elif ( len ( s ) == 5 ) :
                a = int ( s [ 0 ] ) - 48
                b = int ( s [ 4 ] ) - 48
                c = 0
                if s [ 2 ] == " & " :
                    c = a & b
                else :
                    c = a | b
                arr . append ( ( c ) + 48 )
        else :
            arr . append ( string [ i ] )
    return arr [ - 1 ]
string = " [ | , [ & ,1 , [ ! , 0 ] ] , [ ! , [ | , [ ▁ , 1,0 ] , [ ! ,1 ] ] ] ] "
print ( logicalExpressionEvaluation ( string ) )

Index/key variables: i
Accumulator variables: arr, s
Iterator variables: i
Python program:
def count ( s , k ) :
    n = len ( s )
    d , count = 0 , 0
    for i in range ( k ) :
        d += ord ( s [ i ] )
        if ( d % k == 0 ) :
            count += 1
            for i in range ( k , n ) :
                prev = ord ( s [ i - k ] )
                d -= prev
                d += ord ( s [ i ] )
                if ( d % k == 0 ) :
                    count += 1
                    return count
s = " bcgabc "
k = 3
ans = count ( s , k )
print ( ans )

Index/key variables: i
Accumulator variables: count, d
Iterator variables: i
Python program:
def K_String ( s , k ) :
    n = len ( s )
    fre = [ 0 ] * 26
    for i in range ( n ) :
        fre [ ord ( s [ i ] ) - ord ( ' a ' ) ] += 1
    str = " "
    for i in range ( 26 ) :
        if ( fre [ i ] % k == 0 ) :
            x = fre [ i ] // k
            while ( x ) :
                str += chr ( i + ord ( ' a ' ) )
                x -= 1
        else :
            return " - 1"
    return str
if __name__ == " _ _ main _ _ " :
    s = " aabb "
    k = 2
    print ( K_String ( s , k ) )

Index/key variables: i
Accumulator variables: str, x
Iterator variables: i
Python program:
def check ( s ) :
    fr = [ 0 ] * 26
    n = len ( s )
    for i in range ( n ) :
        x = ord ( s [ i ] )
        fr [ x - 97 ] += 1
    minimum = 99999999999
    for i in range ( 26 ) :
        for j in range ( i + 1 , 26 ) :
            z = fr [ i ] + fr [ j ]
            minimum = min ( minimum , n - z )
    return minimum
s = " geeksforgeeks "
print ( check ( s ) )

Index/key variables: i, j
Iterator variables: i, j
Python program:
def pushBoxes ( S ) :
    N = len ( S )
    force = [ 0 ] * N
    f = 0
    for i in range ( 0 , N ) :
        if S [ i ] == ' R ' :
            f = N
        elif S [ i ] == ' L ' :
            f = 0
        else :
            f = max ( f - 1 , 0 )
        force [ i ] += f
    f = 0
    for i in range ( N - 1 , - 1 , - 1 ) :
        if S [ i ] == ' L ' :
            f = N
        elif S [ i ] == ' R ' :
            f = 0
        else :
            f = max ( f - 1 , 0 )
        force [ i ] -= f
    return " " . join ( ' . ' if f == 0 else ' R ' if f > 0 else ' L ' for f in force )
S = " . L . R . . . LR . . L . . "
print ( pushBoxes ( S ) )

Index/key variables: i
Iterator variables: i
Python program:
def CountWords ( str , k ) :
    sum = 0
    NumberOfWords = 0
    counter = 0
    l = len ( str )
    for i in range ( l ) :
        if ( str [ i ] == ' ▁ ' ) :
            if ( sum < k ) :
                counter += 1
            sum = 0
            NumberOfWords += 1
        else :
            sum += ord ( str [ i ] )
    NumberOfWords += 1
    if ( sum < k ) :
        counter += 1
    print ( " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII " , " values ▁ less ▁ than ▁ k ▁ = " , counter )
    print ( " Number ▁ of ▁ words ▁ having ▁ sum ▁ of ▁ ASCII ▁ values " , " greater ▁ than ▁ or ▁ equal ▁ to ▁ k ▁ = " , NumberOfWords - counter )
if __name__ == " _ _ main _ _ " :
    str = " Learn ▁ how ▁ to ▁ code "
    k = 400
    CountWords ( str , k )

Index/key variables: i
Accumulator variables: NumberOfWords, counter, sum
Iterator variables: i
Python program:
def separateChar ( str__ ) :
    n = len ( str__ )
    digitSum = 0
    alphabetSum = 0
    j = 0
    for i in range ( n ) :
        if ( ord ( str__ [ i ] ) >= 48 and ord ( str__ [ i ] ) <= 56 ) :
            digitSum += ord ( str__ [ i ] ) - ord ( '0' )
        else :
            alphabetSum += ord ( str__ [ i ] ) - ord ( ' a ' ) + 1
            alphabetSum %= 26
    sumStr = str ( digitSum )
    alphabetStr = chr ( alphabetSum + ord ( ' a ' ) - 1 )
    sumStr += alphabetStr
    return sumStr
if __name__ == ' _ _ main _ _ ' :
    str__ = "3652adyz3423"
    print ( separateChar ( str__ ) )

Index/key variables: i
Accumulator variables: alphabetSum, digitSum
Iterator variables: i
Python program:
MAX_CHAR = 26
def countPalindrome ( str ) :
    n = len ( str )
    sum = 0
    hashTable = [ 0 ] * MAX_CHAR
    for i in range ( n ) :
        hashTable [ ord ( str [ i ] ) - ord ( ' a ' ) ] += 1
    for i in range ( 26 ) :
        if ( hashTable [ i ] ) :
            sum += ( hashTable [ i ] * ( hashTable [ i ] + 1 ) // 2 )
    return sum
if __name__ == " _ _ main _ _ " :
    str = " ananananddd "
    print ( countPalindrome ( str ) )

Index/key variables: i
Accumulator variables: sum
Iterator variables: i
Python program:
def countConsecutive ( s ) :
    count = - 1
    for i in range ( len ( s ) - 1 ) :
        if ( i <= len ( s ) ) :
            if ( s [ i ] is s [ i + 1 ] ) :
                i += 1
            else :
                count += 1
    return count
if __name__ == ' _ _ main _ _ ' :
    str = "44522255"
    print ( countConsecutive ( str ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
def check_digits ( n ) :
    while ( n ) :
        if ( ( n % 10 ) % 2 == 0 ) :
            return 0
        n = int ( n / 10 )
    return 1
def smallest_number ( n ) :
    i = n
    while ( 1 ) :
        if ( check_digits ( i ) ) :
            return i
        i += 1
if __name__ == ' _ _ main _ _ ' :
    N = 2397
    print ( smallest_number ( N ) )

Accumulator variables: i
Python program:
def smallestNumber ( n ) :
    num = 0
    s = " "
    duplicate = n
    while ( n ) :
        s = chr ( n % 10 + 48 ) + s
        n //= 10
    index = - 1
    for i in range ( len ( s ) ) :
        digit = ord ( s [ i ] ) - ord ( '0' )
        if ( ( digit & 1 ) == 0 ) :
            index = i
            break
    if ( index == - 1 ) :
        return duplicate
    for i in range ( index ) :
        num = num * 10 + ( ord ( s [ i ] ) - ord ( '0' ) )
    num = num * 10 + ( ord ( s [ index ] ) - ord ( '0' ) + 1 )
    for i in range ( index + 1 , len ( s ) ) :
        num = num * 10 + 1
    return num
if __name__ == " _ _ main _ _ " :
    N = 2397
    print ( smallestNumber ( N ) )

Index/key variables: i, index
Accumulator variables: n
Iterator variables: i
Python program:
def CountCharacters ( str1 , l , r ) :
    cnt = 0 ;
    len1 = len ( str1 )
    for i in str1 :
        if ( l <= ord ( i ) and ord ( i ) <= r ) :
            cnt = cnt + 1
            print ( i , end = " ▁ " )
    return cnt
if __name__ == ' _ _ main _ _ ' :
    str1 = " geeksforgeeks "
    l = 102
    r = 111
    print ( " Characters ▁ with ▁ ASCII ▁ values ▁ " + " in ▁ the ▁ range ▁ [ l , ▁ r ] ▁ are " )
    print ( " and their count is   " , CountCharacters ( str1 , l , r ) )

Iterator variables: i
Python program:
def minSteps ( str ) :
    count = 0
    i = 0
    while i < len ( str ) - 2 :
        if str [ i ] == '0' :
            if ( str [ i + 1 ] == '1' ) :
                if ( str [ i + 2 ] == '0' ) :
                    count = count + 1
                    i = i + 2
        i = i + 1
    return count
str = "0101010"
print ( minSteps ( str ) )

Index/key variables: i
Python program:
from collections import defaultdict
def SieveOfEratosthenes ( prime , p_size ) :
    prime [ 0 ] = False
    prime [ 1 ] = False
    p = 2
    while p * p <= p_size :
        if prime [ p ] :
            for i in range ( p * 2 , p_size + 1 , p ) :
                prime [ i ] = False
        p += 1
def xorOfPrime ( s ) :
    prime = [ True ] * 100005
    SieveOfEratosthenes ( prime , 10005 )
    m = defaultdict ( lambda : 0 )
    for i in range ( 0 , len ( s ) ) :
        m [ s [ i ] ] += 1
    result = flag = 0
    for it in m :
        if prime [ m [ it ] ] :
            result ^= m [ it ]
            flag = 1
    if not flag :
        return - 1
    return result
if __name__ == " _ _ main _ _ " :
    s = " gggggeeekkkks "
    print ( xorOfPrime ( s ) )

Index/key variables: i, it, p
Accumulator variables: result
Iterator variables: i, it
Python program:
def CountCharacters ( str , k ) :
    cnt = 0
    l = len ( str )
    for i in range ( l ) :
        if ( ord ( str [ i ] ) < k ) :
            cnt += 1
    return cnt
if __name__ == " _ _ main _ _ " :
    str = " GeeksForGeeks "
    k = 90
    count = CountCharacters ( str , k )
    print ( " Characters ▁ with ▁ ASCII ▁ values " , " less ▁ than ▁ K ▁ are " , count )
    print ( " Characters ▁ with ▁ ASCII ▁ values " , " greater ▁ than ▁ or ▁ equal ▁ to ▁ K ▁ are " , len ( str ) - count )

Index/key variables: i
Accumulator variables: cnt
Iterator variables: i
Python program:
import math
seen = set ( )
edges = [ ]
def dfs ( node , k , A ) :
    for i in range ( k ) :
        str = node + A [ i ]
        if ( str not in seen ) :
            seen . add ( str )
            dfs ( str [ 1 : ] , k , A )
            edges . append ( i )
def deBruijn ( n , k , A ) :
    seen . clear ( )
    edges . clear ( )
    startingNode = A [ 0 ] * ( n - 1 )
    dfs ( startingNode , k , A )
    S = " "
    l = int ( math . pow ( k , n ) )
    for i in range ( l ) :
        S += A [ edges [ i ] ]
    S += startingNode
    return S
n = 3
k = 2
A = "01"
print ( deBruijn ( n , k , A ) )

Index/key variables: i
Accumulator variables: S, edges, seen
Iterator variables: i
Python program:
def countWords ( str ) :
    count = 1
    for i in range ( 1 , len ( str ) - 1 ) :
        if ( str [ i ] . isupper ( ) ) :
            count += 1
    return count
str = " geeksForGeeks " ;
print ( countWords ( str ) )

Index/key variables: i
Accumulator variables: count
Iterator variables: i
Python program:
from collections import defaultdict
def isFibonacci ( s ) :
    m = defaultdict ( lambda : 0 )
    for i in range ( 0 , len ( s ) ) :
        m [ s [ i ] ] += 1
    v = [ ]
    n = len ( m )
    a = b = 1
    v . append ( a )
    v . append ( b )
    for i in range ( 0 , n - 2 ) :
        v . append ( a + b )
        c = a + b
        a , b = b , c
    flag , i = 1 , 0
    for itr in sorted ( m ) :
        if m [ itr ] != v [ i ] :
            flag = 0
            break
        i += 1
    if flag == 1 :
        return " YES "
    else :
        return " NO "
if __name__ == " _ _ main _ _ " :
    s = " abeeedd "
    print ( isFibonacci ( s ) )

Index/key variables: i, itr
Accumulator variables: v
Iterator variables: i, itr