dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
class Node { constructor ( ) { this . c = " " ; this . next = null ; } } ; function newNode ( c ) { var temp = new Node ( ) ; temp . c = c ; temp . next = null ; return temp ; } function reverse_word ( str ) { var s = " " ; for ( var i = 0 ; i < str . length ; i ++ ) s = str [ i ] + s ; return s ; } function reverse ( head ) { var ptr = head ; while ( ptr != null ) { ptr . c = reverse_word ( ptr . c ) ; ptr = ptr . next ; } return head ; } function printList ( head ) { while ( head != null ) { document . write ( head . c + " " ) ; head = head . next ; } } var head = newNode ( " " ) ; head . next = newNode ( " " ) ; head . next . next = newNode ( " " ) ; head . next . next . next = newNode ( " " ) ; head . next . next . next . next = newNode ( " " ) ; head . next . next . next . next . next = newNode ( " " ) ; head . next . next . next . next . next . next = newNode ( " " ) ; document . write ( " " ) ; printList ( head ) ; head = reverse ( head ) ; document . write ( " " ) ; printList ( head ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Class/struct names: Node
Javascript program:
function CountSpecialPalindrome ( str ) { var n = str . length ; var result = 0 ; var sameChar = [ ... Array ( n ) ] ; var i = 0 ; while ( i < n ) { var sameCharCount = 1 ; var j = i + 1 ; while ( str [ i ] == str [ j ] && j < n ) sameCharCount ++ , j ++ ; result += ( sameCharCount * ( sameCharCount + 1 ) ) / 2 ; sameChar [ i ] = sameCharCount ; i = j ; } for ( var j = 1 ; j < n ; j ++ ) { if ( str [ j ] == str [ j - 1 ] ) sameChar [ j ] = sameChar [ j - 1 ] ; if ( j > 0 && j < n - 1 && str [ j - 1 ] == str [ j + 1 ] && str [ j ] != str [ j - 1 ] ) result += Math . min ( sameChar [ j - 1 ] , sameChar [ j + 1 ] ) ; } return result - n ; } var str = " " ; document . write ( CountSpecialPalindrome ( str ) + " " ) ;

Index/key variables: i, j
Accumulator variables: j, result, sameCharCount
Iterator variables: j
Javascript program:
function printBracketNumber ( exp , n ) { var left_bnum = 1 ; var right_bnum = [ ] ; for ( var i = 0 ; i < n ; i ++ ) { if ( exp [ i ] == ' ' ) { document . write ( left_bnum + " " ) ; right_bnum . push ( left_bnum ) ; left_bnum ++ ; } else if ( exp [ i ] == ' ' ) { document . write ( right_bnum [ right_bnum . length - 1 ] + " " ) ; right_bnum . pop ( ) ; } } } var exp = " " ; var n = exp . length ; printBracketNumber ( exp , n ) ;

Index/key variables: i
Accumulator variables: i, left_bnum
Iterator variables: i
Javascript program:
let s = " " ; function ReverseString ( s ) { let arr = s . split ( " " ) ; for ( let i = 0 ; i < arr . length / 2 ; i ++ ) { let temp = arr [ i ] ; arr [ i ] = arr [ arr . length - i - 1 ] ; arr [ arr . length - i - 1 ] = temp ; } return arr . join ( " " ) ; } function binary_conversion ( m ) { while ( m != 0 ) { let tmp = m % 2 ; s += tmp . toString ( ) ; m = Math . floor ( m / 2 ) ; } s = ReverseString ( s ) ; } function find_character ( n , m , i ) { binary_conversion ( m ) ; let s1 = " " ; for ( let x = 0 ; x < n ; x ++ ) { for ( let y = 0 ; y < s . length ; y ++ ) { if ( s [ y ] == ' ' ) s1 += " " ; else s1 += " " ; } s = s1 ; s1 = " " ; } return s [ i ] - ' ' ; } let m = 5 , n = 2 , i = 8 ; document . write ( find_character ( n , m , i ) ) ;

Index/key variables: i, y
Accumulator variables: i, s, s1, x, y
Iterator variables: i, x, y
Javascript program:
function isConsecutive ( str ) { let start ; let length = str . length ; for ( let i = 0 ; i < length / 2 ; i ++ ) { let new_str = str . substring ( 0 , i + 1 ) ; let num = parseInt ( new_str ) ; start = num ; while ( new_str . length < length ) { num ++ ; new_str = new_str + ( num ) . toString ( ) ; } if ( new_str == ( str ) ) return start ; } return - 1 ; } let str = " " ; document . write ( " " + str + " " ) ; let start = isConsecutive ( str ) ; if ( start != - 1 ) document . write ( " " + start + " " ) ; else document . write ( " " ) ; let str1 = " " ; document . write ( " " + str1 + " " ) ; start = isConsecutive ( str1 ) ; if ( start != - 1 ) document . write ( " " + start + " " ) ; else document . write ( " " ) ;

Accumulator variables: i, num
Iterator variables: i
Javascript program:
function isConvertible ( str1 , str2 , k ) { if ( ( str1 . length + str2 . length ) < k ) return true ; var commonLength = 0 ; for ( var i = 0 ; i < Math . min ( str1 . length , str2 . length ) ; i ++ ) { if ( str1 [ i ] == str2 [ i ] ) commonLength ++ ; else break ; } if ( ( k - str1 . length - str2 . length + 2 * commonLength ) % 2 == 0 ) return true ; return false ; } var str1 = " " , str2 = " " ; var k = 7 ; if ( isConvertible ( str1 , str2 , k ) ) document . write ( " " ) ; else document . write ( " " ) ; str1 = " " , str2 = " " ; k = 5 ; document . write ( " " ) ; if ( isConvertible ( str1 , str2 , k ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: commonLength, i
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function maxLower ( str ) { let n = str . length ; let i = 0 ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { i ++ ; break ; } } let maxCount = 0 ; let count = new Array ( MAX_CHAR ) ; for ( ; i < n ; i ++ ) { if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { let currCount = 0 ; for ( let j = 0 ; j < MAX_CHAR ; j ++ ) { if ( count [ j ] > 0 ) { currCount ++ ; } } maxCount = Math . max ( maxCount , currCount ) ; for ( let i = 0 ; i < count . length ; i ++ ) { count [ i ] = 0 ; } } if ( str [ i ] >= ' ' && str [ i ] <= ' ' ) { count [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } } return maxCount ; } let str = " " ; document . write ( maxLower ( str ) ) ;

Index/key variables: i, j
Accumulator variables: currCount, i, j
Iterator variables: i, j
Javascript program:
function maxLower ( str ) { let n = str . length ; let i = 0 ; for ( ; i < n ; i ++ ) { if ( str [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { i ++ ; break ; } } let maxCount = 0 ; let s = new Set ( ) ; for ( ; i < n ; i ++ ) { if ( str [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) { maxCount = Math . max ( maxCount , s . size ) ; s . clear ( ) ; } if ( str [ i ] . charCodeAt ( 0 ) >= ' ' . charCodeAt ( 0 ) && str [ i ] . charCodeAt ( 0 ) <= ' ' . charCodeAt ( 0 ) ) s . add ( str [ i ] ) ; } return maxCount ; } let str = " " ; document . write ( maxLower ( str . split ( " " ) ) ) ;

Index/key variables: i
Accumulator variables: i
Javascript program:
function first ( str ) { for ( var i = 0 ; i < str . length ; i ++ ) if ( str [ i ] === str [ i ] . toUpperCase ( ) ) return str [ i ] ; return 0 ; } var str = " " ; var res = first ( str ) ; if ( res == 0 ) document . write ( " " ) ; else { document . write ( res ) ; document . write ( " " ) ; }

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function fact ( n ) { let ans = 1 ; for ( let i = 1 ; i <= n ; i ++ ) ans = ans * i ; return ( ans ) ; } function numberOfPossiblePallindrome ( str , n ) { let mp = new Map ( ) ; for ( let i = 0 ; i < n ; i ++ ) mp . set ( str [ i ] , mp . get ( str [ i ] ) == null ? 1 : mp . get ( str [ i ] ) + 1 ) ; let fi ; for ( let [ key , value ] of mp . entries ( ) ) { if ( value % 2 == 0 ) fi = value / 2 ; else { fi = ( value - 1 ) / 2 ; k ++ ; } num = num + fi ; den = den * fact ( fi ) ; } if ( num != 0 ) num = fact ( num ) ; let ans = Math . floor ( num / den ) ; if ( k != 0 ) { ans = ans * k ; } return ( ans ) ; } let str = " " ; let n = str . length ; document . write ( numberOfPossiblePallindrome ( str , n ) ) ;

Index/key variables: i
Accumulator variables: i, k
Iterator variables: i
Javascript program:
function evenDecimalValue ( str , n ) { var result = 0 ; for ( var i = 0 ; i < n ; i ++ ) { for ( var j = i ; j < n ; j ++ ) { var decimalValue = 0 ; var powerOf2 = 1 ; for ( var k = i ; k <= j ; k ++ ) { decimalValue += ( ( str [ k ] - ' ' ) * powerOf2 ) ; powerOf2 *= 2 ; } if ( decimalValue % 2 == 0 ) result ++ ; } } return result ; } var str = " " ; var n = 5 ; document . write ( evenDecimalValue ( str , n ) ) ;

Index/key variables: k
Accumulator variables: decimalValue, i, j, k, powerOf2, result
Iterator variables: i, j, k
Javascript program:
function solve ( s ) { var l = s . length ; var x = l / 2 ; var y = l ; var p = " " ; while ( x > 0 && y > l / 2 ) { var ch = s . charAt ( x - 1 ) ; p += ch ; x -- ; ch = s . charAt ( y - 1 ) ; p += ch ; y -- ; } if ( y > l / 2 ) { var ch = s . charAt ( x - 1 ) ; p += ch ; y -- ; } document . write ( p ) ; } var s = " " ; solve ( s ) ;

Accumulator variables: p, x, y
Javascript program:
function isConsonant ( ch ) { ch = ch . toUpperCase ( ) ; console . log ( ch ) ; return ( ! ( ch == " " ch == " " ch == " " ch == " " ch == " " ) && ch . match ( / [A-Z] / i ) ) ; } function totalConsonants ( str ) { var count = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) if ( isConsonant ( str [ i ] ) ) ++ count ; return count ; } var str = " " ; document . write ( totalConsonants ( str ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function reverseBits ( n ) { let rev = 0 ; while ( n > 0 ) { rev <<= 1 ; if ( ( n & 1 ) == 1 ) rev ^= 1 ; n >>= 1 ; } return rev ; } function isPalindrome ( n ) { let rev = reverseBits ( n ) ; return ( n == rev ) ; } let n = 9 ; if ( isPalindrome ( n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: rev
Javascript program:
let MAX = 26 ; function Swap ( s , t , n ) { let dp = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { dp [ i ] = new Array ( MAX ) ; for ( let j = 0 ; j < MAX ; j ++ ) { dp [ i ] [ j ] = - 1 ; } } let tot = 0 ; for ( let i = 0 ; i < n ; i ++ ) if ( s [ i ] != t [ i ] ) tot ++ ; for ( let i = 0 ; i < n ; i ++ ) { let a = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; let b = t [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( a == b ) continue ; if ( dp [ a ] [ b ] != - 1 ) { document . write ( i + 1 + " " + ( dp [ a ] [ b ] + 1 ) + " " ) ; return ; } dp [ b ] [ a ] = i ; } let A = new Array ( MAX ) , B = new Array ( MAX ) ; for ( let i = 0 ; i < MAX ; i ++ ) { A [ i ] = - 1 ; B [ i ] = - 1 ; } for ( let i = 0 ; i < n ; i ++ ) { let a = s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; let b = t [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( a == b ) continue ; if ( A [ b ] != - 1 ) { document . write ( i + 1 + " " + ( A [ b ] + 1 ) + " " ) ; return ; } if ( B [ a ] != - 1 ) { document . write ( i + 1 + " " + ( B [ a ] + 1 ) + " " ) ; return ; } A [ a ] = i ; B [ b ] = i ; } document . write ( - 1 ) ; } let S = " " ; let T = " " ; let n = S . length ; if ( S == " " T == " " ) document . write ( " " ) ; else Swap ( S , T , n ) ;

Index/key variables: a, b, i, j
Accumulator variables: i, j, tot
Iterator variables: i, j
Javascript program:
const MAX = 26 ; function printAnagramAndChanges ( X , Y ) { var countx = new Array ( MAX ) . fill ( 0 ) ; var county = new Array ( MAX ) . fill ( 0 ) ; var ctrx = new Array ( MAX ) . fill ( 0 ) ; var ctry = new Array ( MAX ) . fill ( 0 ) ; var change = 0 ; var l = X . length ; for ( var i = 0 ; i < l ; i ++ ) { countx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ++ ; county [ Y [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] ++ ; } for ( var i = 0 ; i < MAX ; i ++ ) { if ( countx [ i ] > county [ i ] ) { ctrx [ i ] += countx [ i ] - county [ i ] ; } else if ( countx [ i ] < county [ i ] ) { ctry [ i ] += county [ i ] - countx [ i ] ; } change += Math . abs ( county [ i ] - countx [ i ] ) ; } for ( var i = 0 ; i < l ; i ++ ) { if ( ctrx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] === 0 ) { continue ; } var j ; for ( j = 0 ; j < MAX ; j ++ ) { if ( ctry [ j ] > 0 ) { break ; } } if ( countx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] === ctrx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] || X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) > j ) { countx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] -- ; ctrx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] -- ; ctry [ j ] -- ; X [ i ] = String . fromCharCode ( " " . charCodeAt ( 0 ) + j ) ; } else { countx [ X [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ] -- ; } } document . write ( " " + X . join ( " " ) + " " ) ; document . write ( " " + change / 2 ) ; } var x = " " , y = " " ; printAnagramAndChanges ( x . split ( " " ) , y . split ( " " ) ) ;

Index/key variables: i, j
Accumulator variables: change, i, j
Iterator variables: i, j
Javascript program:
function lexNext ( s , n ) { for ( let i = n - 1 ; i >= 0 ; i -- ) { if ( s [ i ] != ' ' ) { let code = s . charCodeAt ( i ) + 1 ; let str = String . fromCharCode ( code ) ; return s . substr ( 0 , i ) + str + s . substr ( i + 1 ) ; } s [ i ] = ' ' ; } } let S = " " ; let T = " " ; let n = S . length ; let res = lexNext ( S , n ) ; if ( res != T ) document . write ( res , ' ' ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function calSumUtil ( a , b , n , m ) { let sum = new Array ( n ) ; let i = n - 1 , j = m - 1 , k = n - 1 ; let carry = 0 , s = 0 ; while ( j >= 0 ) { s = a [ i ] + b [ j ] + carry ; sum [ k ] = ( s % 10 ) ; carry = Math . floor ( s / 10 ) ; k -- ; i -- ; j -- ; } while ( i >= 0 ) { s = a [ i ] + carry ; sum [ k ] = ( s % 10 ) ; carry = Math . floor ( s / 10 ) ; i -- ; k -- ; } let ans = 0 ; if ( carry ) ans = 10 ; for ( let i = 0 ; i <= n - 1 ; i ++ ) { ans += sum [ i ] ; ans *= 10 ; } return ans / 10 ; } function calSum ( a , b , n , m ) { if ( n >= m ) return calSumUtil ( a , b , n , m ) ; else return calSumUtil ( b , a , m , n ) ; } let a = [ 9 , 3 , 9 ] ; let b = [ 6 , 1 ] ; let n = a . length ; let m = b . length ; document . write ( calSum ( a , b , n , m ) + " " ) ;

Index/key variables: i, j, k
Accumulator variables: ans, i, j, k
Iterator variables: i
Javascript program:
let SIZE = 26 ; function longCommomAnagramSubseq ( str1 , str2 , n1 , n2 ) { let freq1 = new Array ( SIZE ) ; let freq2 = new Array ( SIZE ) ; for ( let i = 0 ; i < SIZE ; i ++ ) { freq1 [ i ] = 0 ; freq2 [ i ] = 0 ; } let len = 0 ; for ( let i = 0 ; i < n1 ; i ++ ) freq1 [ str1 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < n2 ; i ++ ) freq2 [ str2 [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 0 ; i < SIZE ; i ++ ) len += Math . min ( freq1 [ i ] , freq2 [ i ] ) ; return len ; } let str1 = " " ; let str2 = " " ; let n1 = str1 . length ; let n2 = str2 . length ; document . write ( " " + longCommomAnagramSubseq ( str1 , str2 , n1 , n2 ) ) ;

Index/key variables: i
Accumulator variables: i, len
Iterator variables: i
Javascript program:
function isPanalphabeticWindow ( s , n ) { var ch = ' ' ; for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] == ch ) ch = String . fromCharCode ( ch . charCodeAt ( 0 ) + 1 ) ; if ( ch == String . fromCharCode ( ' ' . charCodeAt ( 0 ) + 1 ) ) return true ; } return false ; } var s = " " + " " ; var n = ( s . length ) ; ( isPanalphabeticWindow ( s , n ) ) ? ( document . write ( " " ) ) : ( document . write ( " " ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isPrime ( n ) { if ( n <= 1 ) return false ; for ( let i = 2 ; i < n ; i ++ ) if ( n % i == 0 ) return false ; return true ; } function prime_index ( input ) { let n = input . length ; for ( let i = 2 ; i <= n ; i ++ ) if ( isPrime ( i ) ) document . write ( input [ i - 1 ] ) ; } let input = " " ; prime_index ( input ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isHeterogram ( s , n ) { var hash = Array ( 26 ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] != ' ' ) { if ( hash [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) hash [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] = 1 ; else return false ; } } return true ; } var s = " " ; var n = s . length ; ( isHeterogram ( s , n ) ) ? ( document . write ( " " ) ) : ( document . write ( " " ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function ASCIISentence ( str ) { let l = str . length ; let convert ; for ( let i = 0 ; i < l ; i ++ ) { convert = str [ i ] . charCodeAt ( 0 ) ; document . write ( convert ) ; } } let str = " " ; document . write ( " " ) ; ASCIISentence ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function convert ( str ) { let n = str . length ; let str1 = " " ; for ( i = 0 ; i < n ; i ++ ) { if ( str [ i ] == ' ' ) str1 = str1 + ' ' ; else str1 = str1 + ( str [ i ] ) . toLowerCase ( ) ; } document . write ( str1 ) ; } let str = " " ; convert ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function largestAnagramSet ( arr , n ) { var maxSize = 0 ; var count = new Map ( ) ; for ( var i = 0 ; i < n ; ++ i ) { var temp = arr [ i ] . split ( ' ' ) ; temp . sort ( ) ; arr [ i ] = temp . join ( ' ' ) ; if ( count . has ( arr [ i ] ) ) { count . set ( arr [ i ] , count . get ( arr [ i ] ) + 1 ) ; } else { count . set ( arr [ i ] , 1 ) ; } maxSize = Math . max ( maxSize , count . get ( arr [ i ] ) ) ; } return maxSize ; } var arr = [ " " , " " , " " , " " , " " ] ; var n = arr . length ; document . write ( largestAnagramSet ( arr , n ) + " " ) ; var arr1 = [ " " , " " , " " , " " ] ; n = arr1 . length ; document . write ( largestAnagramSet ( arr1 , n ) ) ;

Index/key variables: i
Iterator variables: i
Javascript program:
function countCharacterType ( str ) { var vowels = 0 , consonant = 0 , specialChar = 0 , digit = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) { var ch = str [ i ] ; if ( ( ch >= " " && ch <= " " ) || ( ch >= " " && ch <= " " ) ) { ch = ch . toLowerCase ( ) ; if ( ch == " " ch == " " ch == " " ch == " " ch == " " ) vowels ++ ; else consonant ++ ; } else if ( ch >= " " && ch <= " " ) digit ++ ; else specialChar ++ ; } document . write ( " " + vowels + " " ) ; document . write ( " " + consonant + " " ) ; document . write ( " " + digit + " " ) ; document . write ( " " + specialChar + " " ) ; } var str = " " ; countCharacterType ( str ) ;

Index/key variables: i
Accumulator variables: consonant, digit, i, specialChar, vowels
Iterator variables: i
Javascript program:
function findNextWord ( s , m ) { m += 97 ; var n = s . length ; var i = s . length - 1 ; s [ i ] = String . fromCharCode ( s [ i ] . charCodeAt ( 0 ) + 1 ) ; while ( i >= 0 && i <= n - 1 ) { if ( s [ i ] . charCodeAt ( 0 ) >= m ) { s [ i ] = ' ' ; s [ i - 1 ] = String . fromCharCode ( s [ i - 1 ] . charCodeAt ( 0 ) + 1 ) ; i -- ; } else if ( s [ i ] == s [ i - 1 ] s [ i ] == s [ i - 2 ] ) s [ i ] = String . fromCharCode ( s [ i ] . charCodeAt ( 0 ) + 1 ) ; else i ++ ; } if ( i <= - 1 ) document . write ( " " ) ; else document . write ( s . join ( ' ' ) ) ; } var str = " " . split ( ' ' ) ; var k = 4 ; findNextWord ( str , k ) ;

Index/key variables: i
Accumulator variables: i, m
Javascript program:
function replace ( s , c1 , c2 ) { let l = s . length ; let arr = s . split ( " " ) ; for ( let i = 0 ; i < l ; i ++ ) { if ( arr [ i ] == c1 ) arr [ i ] = c2 ; else if ( arr [ i ] == c2 ) arr [ i ] = c1 ; } return arr . join ( " " ) ; } let s = " " ; let c1 = ' ' , c2 = ' ' ; document . write ( replace ( s , c1 , c2 ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function fibWord ( n ) { var Sn_1 = " " ; var Sn = " " ; var tmp ; for ( var i = 2 ; i <= n ; i ++ ) { tmp = Sn ; Sn += Sn_1 ; Sn_1 = tmp ; } return Sn ; } var n = 6 ; document . write ( fibWord ( n ) ) ;

Accumulator variables: Sn, i
Iterator variables: i
Javascript program:
function decToBin ( n ) { if ( n == 0 ) return " " ; var bin = " " ; while ( n > 0 ) { bin = ( ( n & 1 ) == 0 ? ' ' : ' ' ) + bin ; n >>= 1 ; } return bin ; } function convertBinToOct ( bin ) { var l = bin . length ; for ( var i = 1 ; i <= ( 3 - l % 3 ) % 3 ; i ++ ) bin = ' ' + bin ; var bin_oct_map = new Map ( ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; bin_oct_map . set ( " " , ' ' ) ; var i = 0 ; var octal = " " ; while ( 1 ) { octal += bin_oct_map . get ( bin . substring ( i , i + 3 ) ) ; i += 3 ; if ( i == bin . length ) break ; } return octal ; } function decToOctal ( n ) { var bin = decToBin ( n ) ; return convertBinToOct ( bin ) ; } var n = 151 ; document . write ( decToOctal ( n ) ) ; ing

Accumulator variables: i, octal
Iterator variables: i
Javascript program:
function splitStrings ( str , dl ) { var word = " " ; var num = 0 ; str = str + dl ; var l = str . length ; var substr_list = [ ] ; for ( var i = 0 ; i < l ; i ++ ) { if ( str [ i ] != dl ) word = word + str [ i ] ; else { if ( word . length != 0 ) substr_list . push ( word ) ; word = " " ; } } return substr_list ; } var str = " " ; var dl = ' ' ; var res = splitStrings ( str , dl ) ; res . forEach ( x => { document . write ( x + " " ) ; } ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function constructPalin ( str , len ) { var i = 0 , j = len - 1 ; for ( ; i < j ; i ++ , j -- ) { if ( str [ i ] == str [ j ] && str [ i ] != ' ' ) continue ; else if ( str [ i ] == str [ j ] && str [ i ] == ' ' ) { str [ i ] = ' ' ; str [ j ] = ' ' ; continue ; } else if ( str [ i ] == ' ' ) { str [ i ] = str [ j ] ; continue ; } else if ( str [ j ] == ' ' ) { str [ j ] = str [ i ] ; continue ; } document . write ( " " ) ; return " " ; } return str . join ( " " ) ; } var str = " " . split ( " " ) ; var len = str . length ; document . write ( constructPalin ( str , len ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function conversion ( charSet , str ) { var n = str . length ; var hashChar = Array ( 26 ) ; for ( var i = 0 ; i < 26 ; i ++ ) { var ch = Math . abs ( charSet [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ) ; hashChar [ ch ] = String . fromCharCode ( ' ' . charCodeAt ( 0 ) + i ) ; } var s = " " ; for ( var i = 0 ; i < n ; i ++ ) s += ( hashChar [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ) ; return s ; } var charSet = " " . split ( ' ' ) ; var str = " " ; str = conversion ( charSet , str ) ; document . write ( str ) ;

Index/key variables: ch, i
Accumulator variables: i, s
Iterator variables: i
Javascript program:
function numberOfDifferentSubstrings ( s , a , b ) { let ans = 0 ; let ls = s . length ; let x = new Array ( ls ) ; let y = new Array ( ls ) ; for ( let i = 0 ; i < ls ; i ++ ) { x [ i ] = 0 ; y [ i ] = 0 ; } for ( let i = 0 ; i < ls ; i ++ ) { if ( s [ i ] == a ) x [ i ] = 1 ; if ( s [ i ] == b ) y [ i ] = 1 ; } let hash = new Set ( ) ; let curr_substr = " " ; for ( let i = 0 ; i < ls ; i ++ ) { if ( x [ i ] != 0 ) { for ( let j = i ; j < ls ; j ++ ) { if ( y [ j ] == 0 ) curr_substr += s [ i ] ; if ( y [ j ] != 0 ) { curr_substr += s [ j ] ; if ( ! hash . has ( curr_substr ) ) ans ++ ; hash . add ( curr_substr ) ; } } curr_substr = " " ; } } return ans ; } let s = " " ; let begin = ' ' ; let end = ' ' ; document . write ( numberOfDifferentSubstrings ( s , begin , end ) ) ;

Index/key variables: i, j
Accumulator variables: ans, curr_substr, i, j
Iterator variables: i, j
Javascript program:
function generateString ( n ) { var s = " " ; for ( var i = 0 ; i < n ; i ++ ) s += ( ( i & 2 ) > 1 ? ' ' : ' ' ) ; document . write ( s + " " ) ; } var n = 5 ; generateString ( n ) ; n = 8 ; generateString ( n ) ; n = 10 ; generateString ( n ) ;

Accumulator variables: i, s
Iterator variables: i