dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
let N = 4 ; function performQueries ( l , r , prefix ) { l -- ; r -- ; let flag = false ; let count = 0 ; for ( let i = 0 ; i < 26 ; i ++ ) { let cnt = prefix [ r ] [ i ] ; if ( l > 0 ) cnt -= prefix [ l - 1 ] [ i ] ; if ( cnt % 2 == 1 ) { flag = true ; count += cnt - 1 ; } else count += cnt ; } if ( flag ) count += 1 ; return count ; } function preCalculate ( s , prefix ) { let n = s . length ; for ( let i = 0 ; i < n ; i ++ ) { prefix [ i ] [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } for ( let i = 1 ; i < n ; i ++ ) { for ( let j = 0 ; j < 26 ; j ++ ) prefix [ i ] [ j ] += prefix [ i - 1 ] [ j ] ; } } let s = " " ; let prefix = new Array ( N ) ; for ( let i = 0 ; i < 26 ; i ++ ) { prefix [ i ] = new Array ( 26 ) ; for ( let j = 0 ; j < 26 ; j ++ ) { prefix [ i ] [ j ] = 0 ; } } preCalculate ( s , prefix ) ; let queries = [ [ 1 , 4 ] , [ 3 , 4 ] ] ; let q = queries . length ; for ( let i = 0 ; i < q ; i ++ ) { document . write ( performQueries ( queries [ i ] [ 0 ] , queries [ i ] [ 1 ] , prefix ) + " " ) ; }

Index/key variables: i, j, r
Accumulator variables: cnt, count, i, j, l, r
Iterator variables: i, j
Boolean variables: flag
Javascript program:
function isValid ( str , n ) { if ( ! ( ( str [ 0 ] >= ' ' && str [ 0 ] <= ' ' ) || ( str [ 0 ] >= ' ' && str [ 0 ] <= ' ' ) str [ 0 ] == ' ' ) ) return false ; for ( let i = 1 ; i < str . length ; i ++ ) { if ( ! ( ( str [ i ] >= ' ' && str [ i ] <= ' ' ) || ( str [ i ] >= ' ' && str [ i ] <= ' ' ) || ( str [ i ] >= ' ' && str [ i ] <= ' ' ) str [ i ] == ' ' ) ) return false ; } return true ; } let str = " " ; let n = str . length ; if ( isValid ( str , n ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function check ( s , l ) { var pos = [ ] ; for ( var i = 0 ; i < l ; i ++ ) { if ( s [ i ] == ' ' ) pos . push ( i ) ; } var t = pos . length ; for ( var i = 1 ; i < t ; i ++ ) { if ( ( pos [ i ] - pos [ i - 1 ] ) != ( pos [ 1 ] - pos [ 0 ] ) ) return false ; } return true ; } var s = " " ; var l = s . length ; if ( check ( s , l ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function FirstAndLast ( str ) { var ch = str . split ( ' ' ) ; for ( var i = 0 ; i < ch . length ; i ++ ) { var k = i ; while ( i < ch . length && ch [ i ] != ' ' ) i ++ ; ch [ k ] = String . fromCharCode ( ch [ k ] >= ' ' && ch [ k ] <= ' ' ? ( ch [ k ] . charCodeAt ( 0 ) - 32 ) : ch [ k ] . charCodeAt ( 0 ) ) ; ch [ i - 1 ] = String . fromCharCode ( ch [ i - 1 ] >= ' ' && ch [ i - 1 ] <= ' ' ? ( ch [ i - 1 ] . charCodeAt ( 0 ) - 32 ) : ch [ i - 1 ] . charCodeAt ( 0 ) ) ; } return ch . join ( ' ' ) ; } var str = " " ; document . write ( str + " " ) ; document . write ( FirstAndLast ( str ) ) ;

Index/key variables: i, k
Accumulator variables: i
Iterator variables: i
Javascript program:
function findM ( s , x ) { var cnt = 0 ; for ( i = 0 ; i < s . length ; i ++ ) { if ( s . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) != x ) cnt ++ ; } return cnt ; } var s = " " ; var x = 6 ; document . write ( findM ( s , x ) ) ;

Accumulator variables: cnt, i
Iterator variables: i
Javascript program:
function FirstAndLast ( str ) { for ( var i = 0 ; i < str . length ; i ++ ) { if ( i == 0 ) document . write ( str [ i ] ) ; if ( i == str . length - 1 ) document . write ( str [ i ] ) ; if ( str [ i ] === " " ) { document . write ( str [ i - 1 ] + " " + str [ i + 1 ] ) ; } } } var str = " " ; FirstAndLast ( str ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function compute_lps ( s ) { var n = s . length ; var lps = Array ( n ) ; var len = 0 ; lps [ 0 ] = 0 ; var i = 1 ; while ( i < n ) { if ( s [ i ] == s [ len ] ) { len ++ ; lps [ i ] = len ; i ++ ; } else { if ( len != 0 ) len = lps [ len - 1 ] ; else { lps [ i ] = 0 ; i ++ ; } } } return lps ; } function Longestsubstring ( s ) { var lps = compute_lps ( s ) ; var n = s . length ; if ( lps [ n - 1 ] == 0 ) { document . write ( - 1 ) ; return ; } for ( var i = 0 ; i < n - 1 ; i ++ ) { if ( lps [ i ] == lps [ n - 1 ] ) { document . write ( s . substring ( 0 , lps [ i ] ) ) ; return ; } } if ( lps [ lps [ n - 1 ] - 1 ] == 0 ) document . write ( - 1 ) ; else document . write ( s . substr ( 0 , lps [ lps [ n - 1 ] - 1 ] ) ) ; } var s = " " ; Longestsubstring ( s ) ;

Index/key variables: i, len
Accumulator variables: i, len
Iterator variables: i
Javascript program:
const MAX = 64 ; function getBitmask ( s ) { var temp = 0 ; for ( var j = 0 ; j < s . length ; j ++ ) { switch ( s [ j ] ) { case " " : temp = temp | 1 ; break ; case " " : temp = temp | 2 ; break ; case " " : temp = temp | 4 ; break ; case " " : temp = temp | 8 ; break ; case " " : temp = temp | 16 ; break ; case " " : temp = temp | 32 ; break ; default : break ; } } return temp ; } function countPairs ( arr , n ) { var bitMask = new Array ( MAX ) . fill ( 0 ) ; for ( var i = 0 ; i < n ; i ++ ) bitMask [ getBitmask ( arr [ i ] . split ( " " ) ) ] ++ ; var cnt = 0 ; for ( var i = 0 ; i < MAX ; i ++ ) { for ( var j = i ; j < MAX ; j ++ ) { if ( ( i j ) === MAX - 1 ) { if ( i === j ) cnt += parseInt ( ( bitMask [ i ] * bitMask [ i ] - 1 ) / 2 ) ; else cnt += bitMask [ i ] * bitMask [ j ] ; } } } return cnt ; } var arr = [ " " , " " , " " ] ; var n = arr . length ; document . write ( countPairs ( arr , n ) ) ;

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i, j
Javascript program:
function countOcc ( s ) { var cnt = 0 ; for ( var i = 0 ; i < s . length - 3 ; i ++ ) { var c = 0 , l = 0 , a = 0 , p = 0 ; for ( var j = i ; j < i + 4 ; j ++ ) { switch ( s [ j ] ) { case ' ' : c ++ ; break ; case ' ' : l ++ ; break ; case ' ' : a ++ ; break ; case ' ' : p ++ ; break ; } } if ( c == 1 && l == 1 && a == 1 && p == 1 ) cnt ++ ; } return cnt ; } var s = " " ; s = s . toLowerCase ( ) ; document . write ( countOcc ( s ) ) ;

Index/key variables: j
Accumulator variables: a, c, cnt, i, j, l, p
Iterator variables: i, j
Javascript program:
function calculateWays ( s , n , l , r ) { var freq = Array ( 26 ) . fill ( 0 ) ; for ( i = 0 ; i < n ; i ++ ) { if ( i < l i > r ) freq [ s . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ++ ; } var ways = 1 ; for ( i = l ; i <= r ; i ++ ) { if ( freq [ s . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] != 0 ) { ways = ways * freq [ s . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] ; freq [ s . charCodeAt ( i ) - ' ' . charCodeAt ( 0 ) ] -- ; } else { ways = 0 ; break ; } } return ways ; } var s = " " ; var n = s . length ; var l = 1 , r = 3 ; document . write ( calculateWays ( s , n , l , r ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function asciiToSentence ( str , len ) { var num = 0 ; for ( var i = 0 ; i < len ; i ++ ) { num = num * 10 + ( str [ i ] - ' ' ) ; if ( num >= 32 && num <= 122 ) { var ch = String . fromCharCode ( num ) ; document . write ( ch ) ; num = 0 ; } } } var str = " " ; var len = str . length ; asciiToSentence ( str , len ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function countDistinctCode ( str ) { var codes = new Set ( ) ; for ( var i = 0 ; i < str . length - 1 ; i ++ ) codes . add ( str . substr ( i , 2 ) ) ; return codes . size ; } var str = " " ; document . write ( countDistinctCode ( str ) )

Accumulator variables: i
Iterator variables: i
Javascript program:
var arr = [ 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 1 , 2 , 3 , 4 , 1 , 2 , 3 , 1 , 2 , 3 , 4 ] function countKeyPressed ( str , len ) { var count = 0 ; for ( var i = 0 ; i < len ; i ++ ) count = count + arr [ str . charCodeAt ( i ) - 97 ] ; return count ; } var str = " " ; var len = str . length ; document . write ( countKeyPressed ( str , len ) ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function isReverseEqual ( s1 , s2 ) { if ( s1 . length != s2 . length ) return false ; let len = s1 . length ; for ( let i = 0 ; i < len ; i ++ ) if ( s1 [ i ] != s2 [ len - i - 1 ] ) return false ; return true ; } function getWord ( str , n ) { for ( let i = 0 ; i < n - 1 ; i ++ ) for ( let j = i + 1 ; j < n ; j ++ ) if ( isReverseEqual ( str [ i ] , str [ j ] ) ) return str [ i ] ; return " " ; } let str = [ " " , " " , " " ] ; document . write ( getWord ( str , 3 ) ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPrefix ( str , len , i , k ) { if ( i + k > len ) return false ; for ( let j = 0 ; j < k ; j ++ ) { if ( str [ i ] != str [ j ] ) return false ; i ++ ; } return true ; } function isKPeriodic ( str , len , k ) { for ( let i = k ; i < len ; i += k ) if ( ! isPrefix ( str , len , i , k ) ) return false ; return true ; } let str = " " ; let len = str . length ; let k = 5 ; if ( isKPeriodic ( str , len , k ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function findMaxLenEven ( str ) { var n = str . length ; var i = 0 ; var currlen = 0 ; var maxlen = 0 ; var st = - 1 ; while ( i < n ) { if ( str [ i ] == ' ' ) { if ( currlen % 2 == 0 ) { if ( maxlen < currlen ) { maxlen = currlen ; st = i - currlen ; } } currlen = 0 ; } else { currlen ++ ; } i ++ ; } if ( currlen % 2 == 0 ) { if ( maxlen < currlen ) { maxlen = currlen ; st = i - currlen ; } } if ( st == - 1 ) return " " ; return str . substr ( st , maxlen ) ; } var str = " " ; document . write ( findMaxLenEven ( str ) ) ;

Index/key variables: i
Accumulator variables: currlen, i
Javascript program:
function findMinLenStr ( str , k ) { var n = str . length ; var st = 0 ; var end = 0 ; var cnt = Array ( 26 ) . fill ( 0 ) ; var distEle = 0 ; var currlen ; var minlen = n ; var startInd = - 1 ; while ( end < n ) { cnt [ str [ end ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; if ( cnt [ str [ end ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 1 ) distEle ++ ; if ( distEle > k ) { while ( st < end && distEle > k ) { if ( cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 1 ) distEle -- ; cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; st ++ ; } } if ( distEle == k ) { while ( st < end && cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] > 1 ) { cnt [ str [ st ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; st ++ ; } currlen = end - st + 1 ; if ( currlen < minlen ) { minlen = currlen ; startInd = st ; } } end ++ ; } return str . substr ( startInd , minlen ) ; } var str = " " ; var k = 4 ; document . write ( findMinLenStr ( str , k ) ) ;

Index/key variables: end, st
Accumulator variables: distEle, end, st
Javascript program:
function minReplacement ( s , len ) { var ans = 0 ; for ( var i = 0 ; i < len ; i ++ ) { if ( i % 2 == 0 && s [ i ] == ' ' ) ans ++ ; if ( i % 2 == 1 && s [ i ] == ' ' ) ans ++ ; } return Math . min ( ans , len - ans ) ; } var s = " " ; var len = s . length ; document . write ( minReplacement ( s , len ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function substrDeletion ( str , len ) { let count0 = 0 , count1 = 0 ; for ( let i = 0 ; i < len ; i ++ ) { if ( str [ i ] == ' ' ) count0 ++ ; else count1 ++ ; } return Math . min ( count0 , count1 ) ; } let str = " " ; let len = str . length ; document . write ( substrDeletion ( str , len ) ) ;

Index/key variables: i
Accumulator variables: count0, count1, i
Iterator variables: i
Javascript program:
function groupCharacters ( s , len ) { let temp = " " ; for ( let i = 0 ; i < len ; i ++ ) if ( s [ i ] != ' ' ) temp = temp + s [ i ] ; len = temp . length ; let ans = " " ; let i = 0 ; while ( i < len ) { if ( temp [ i ] >= ( ' ' ) && temp [ i ] <= ( ' ' ) ) { while ( i < len && temp [ i ] >= ( ' ' ) && temp [ i ] <= ( ' ' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " " ; } else if ( temp [ i ] >= ( ' ' ) && temp [ i ] <= ( ' ' ) ) { while ( i < len && temp [ i ] >= ( ' ' ) && temp [ i ] <= ( ' ' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " " ; } else { while ( i < len && temp [ i ] >= ( ' ' ) && temp [ i ] <= ( ' ' ) ) { ans = ans + temp [ i ] ; i ++ ; } ans = ans + " " ; } } return ans ; } let s = " " ; let len = s . length ; document . write ( groupCharacters ( s . split ( " " ) , len ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function Preprocess ( A , B ) { let n = A . length ; let ans = 0 ; for ( let i = 0 ; i < n / 2 ; i ++ ) { let mp = new Map ( ) ; if ( mp . has ( A [ i ] ) ) mp . set ( A [ i ] , mp . get ( A [ i ] ) + 1 ) ; else mp . set ( A [ i ] , 1 ) ; if ( mp . has ( A [ n - i - 1 ] ) ) mp . set ( A [ n - i - 1 ] , mp . get ( A [ n - i - 1 ] ) + 1 ) ; else mp . set ( A [ n - i - 1 ] , 1 ) ; if ( mp . has ( B [ i ] ) ) mp . set ( B [ i ] , mp . get ( B [ i ] ) + 1 ) ; else mp . set ( B [ i ] , 1 ) ; if ( mp . has ( B [ n - i - 1 ] ) ) mp . set ( B [ n - i - 1 ] , mp . get ( B [ n - i - 1 ] ) + 1 ) ; else mp . set ( B [ n - i - 1 ] , 1 ) ; let sz = mp . size ; if ( sz == 4 ) ans += 2 ; else if ( sz == 3 ) ans += 1 + ( A [ i ] == A [ n - i - 1 ] ? 1 : 0 ) ; else if ( sz == 2 ) ans += mp . get ( A [ i ] ) != 2 ? 1 : 0 ; } if ( n % 2 == 1 && A [ Math . floor ( n / 2 ) ] != B [ Math . floor ( n / 2 ) ] ) ans ++ ; return ans ; } let A = " " , B = " " ; document . write ( Preprocess ( A , B ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function isVowel ( c ) { if ( c === " " c === " " c === " " c === " " c === " " ) return true ; return false ; } function checkPossibility ( s1 , s2 ) { var l1 = s1 . length ; var l2 = s2 . length ; if ( l1 !== l2 ) return false ; for ( var i = 0 ; i < l1 ; i ++ ) { if ( isVowel ( s1 [ i ] ) && isVowel ( s2 [ i ] ) ) continue ; else if ( ! isVowel ( s1 [ i ] ) && ! isVowel ( s2 [ i ] ) ) continue ; else return false ; } return true ; } var S1 = " " , S2 = " " ; if ( checkPossibility ( S1 , S2 ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function generateString ( A , B ) { let rt = " " ; while ( 0 < A 0 < B ) { if ( A < B ) { if ( 0 < B -- ) { rt += ( ' ' ) ; } if ( 0 < B -- ) { rt += ( ' ' ) ; } if ( 0 < A -- ) { rt += ( ' ' ) ; } } else if ( B < A ) { if ( 0 < A -- ) { rt += ( ' ' ) ; } if ( 0 < A -- ) { rt += ( ' ' ) ; } if ( 0 < B -- ) { rt += ( ' ' ) ; } } else { if ( 0 < A -- ) { rt += ( ' ' ) ; } if ( 0 < B -- ) { rt += ( ' ' ) ; } } } document . write ( rt ) ; } let A = 2 , B = 6 ; generateString ( A , B ) ;

Accumulator variables: A, B, rt
Javascript program:
function getSubSeq ( s , n ) { var res = " " ; var cr = 0 ; while ( cr < n ) { var mx = s [ cr ] . charCodeAt ( 0 ) ; for ( var i = cr + 1 ; i < n ; i ++ ) mx = Math . max ( mx , s [ i ] . charCodeAt ( 0 ) ) ; var lst = cr ; for ( var i = cr ; i < n ; i ++ ) if ( s [ i ] . charCodeAt ( 0 ) == mx ) { res += s [ i ] ; lst = i ; } cr = lst + 1 ; } return res ; } var s = " " ; var n = s . length ; document . write ( getSubSeq ( s , n ) ) ;

Index/key variables: cr, i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function countMinimalReplacements ( s ) { var n = s . length ; var mini = 2147483647 ; var dup = " " . split ( " " ) ; do { var dif = 0 ; for ( var i = 0 ; i < n ; i ++ ) { if ( s [ i ] !== dup [ i % 3 ] ) { dif ++ ; } } mini = Math . min ( mini , dif ) ; } while ( next_permutation ( dup ) ) ; return mini ; } function next_permutation ( p ) { for ( var a = p . length - 2 ; a >= 0 ; -- a ) { if ( p [ a ] < p [ a + 1 ] ) { for ( var b = p . length - 1 ; ; -- b ) { if ( p [ b ] > p [ a ] ) { var t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; for ( ++ a , b = p . length - 1 ; a < b ; ++ a , -- b ) { t = p [ a ] ; p [ a ] = p [ b ] ; p [ b ] = t ; } return true ; } } } } return false ; } var s = " " ; document . write ( countMinimalReplacements ( s ) ) ;

Index/key variables: a, b, i
Accumulator variables: dif, i
Iterator variables: a, b, i
Javascript program:
function countSubStr ( str , len , k ) { let count = 0 ; for ( let i = 0 ; i < len ; i ++ ) { let n = 0 ; for ( let j = i ; j < len ; j ++ ) { n = n * 10 + ( str [ j ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) ; if ( n % k == 0 ) count ++ ; } } return count ; } let str = " " ; let len = str . length ; let k = 11 ; document . write ( countSubStr ( str , len , k ) ) ;

Index/key variables: j
Accumulator variables: count, i, j
Iterator variables: i, j
Javascript program:
function Colour_Combination ( s ) { let temp = s [ 0 ] ; for ( let i = 1 ; i < s . length ; i ++ ) { if ( temp != s [ i ] ) { if ( ( temp == ' ' temp == ' ' ) && ( s [ i ] == ' ' s [ i ] == ' ' ) ) temp = ' ' ; else if ( ( temp == ' ' temp == ' ' ) && ( s [ i ] == ' ' s [ i ] == ' ' ) ) temp = ' ' ; else temp = ' ' ; } } return temp ; } let s = " " ; document . write ( Colour_Combination ( s ) ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function reverse ( str , x ) { var n = ( str . length - x ) / 2 ; for ( i = 0 ; i < n ; i ++ ) document . write ( str . charAt ( i ) ) ; for ( i = n + x - 1 ; i >= n ; i -- ) document . write ( str . charAt ( i ) ) ; for ( i = n + x ; i < str . length ; i ++ ) document . write ( str . charAt ( i ) ) ; } var str = " " ; var x = 3 ; reverse ( str , x ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX_CHAR = 256 ; function countSubStrings ( s , anotherStr , k ) { let illegal = [ ] ; for ( let i = 0 ; i < 256 ; i ++ ) illegal . push ( false ) ; for ( let i = 0 ; i < anotherStr . length ; i ++ ) illegal [ anotherStr [ i ] ] = true ; let us = new Set ( ) ; for ( let i = 0 ; i < s . length ; ++ i ) { let ss = " " ; let count = 0 ; for ( let j = i ; j < s . length ; ++ j ) { if ( illegal [ s [ j ] ] ) ++ count ; ss = ss + s [ j ] ; if ( count <= k ) { us . add ( ss ) ; } else break ; } } return us . size ; } let str = " " ; let anotherStr = " " ; let k = 2 ; document . write ( countSubStrings ( str , anotherStr , k ) ) ;

Index/key variables: i, j
Accumulator variables: i
Iterator variables: i, j
Javascript program:
function countPairs ( bracks , num ) { let open = new Map ( ) ; let close = new Map ( ) ; let cnt = 0 ; for ( let i = 0 ; i < num ; i ++ ) { let s = bracks [ i ] ; let l = s . length ; let op = 0 , cl = 0 ; for ( let j = 0 ; j < l ; j ++ ) { if ( s [ j ] == ' ' ) op ++ ; else { if ( op != 0 ) op -- ; else cl ++ ; } } if ( op != 0 && cl == 0 ) open . set ( op , open . get ( op ) == null ? 1 : open . get ( op ) + 1 ) ; if ( cl != 0 && op == 0 ) close . set ( cl , close . get ( cl ) == null ? 1 : close . get ( cl ) + 1 ) ; if ( op == 0 && cl == 0 ) cnt ++ ; } cnt /= 2 ; for ( let [ key , value ] of open . entries ( ) ) cnt += Math . min ( value , close . get ( value ) ) ; return cnt ; } let bracks = [ " " , " " , " " , " " , " " , " " , " " ] ; let num = bracks . length ; document . write ( countPairs ( bracks , num ) ) ;

Index/key variables: i, j
Accumulator variables: cl, cnt, i, j, op
Iterator variables: i, j
Javascript program:
function decrypt ( s , l ) { var ans = " " ; if ( l % 2 == 1 ) { var cnt = 0 ; var indl = 0 , indr = l - 1 ; while ( ans . length != l ) { if ( cnt % 2 == 0 ) ans += s . charAt ( indl ++ ) ; else ans += s . charAt ( indr -- ) ; cnt ++ ; } } else { var cnt = 0 ; var indl = 0 , indr = l - 1 ; while ( ans . length != l ) { if ( cnt % 2 == 0 ) ans += s . charAt ( indr -- ) ; else ans += s . charAt ( indl ++ ) ; cnt ++ ; } } return ans . split ( ' ' ) . reverse ( ) . join ( ' ' ) ; } var s = " " ; var l = s . length ; document . write ( decrypt ( s , l ) ) ;

Accumulator variables: ans, cnt, indl, indr
Javascript program:
function removeChars ( s ) { let modifiedStr = " " ; modifiedStr += s [ 0 ] ; for ( let i = 1 ; i < s . length ; i ++ ) { if ( s [ i ] == ( s [ i ] ) . toUpperCase ( ) && ( s [ i - 1 ] ) == ( s [ i - 1 ] ) . toLowerCase ( ) || s [ i ] == s [ i ] . toLowerCase ( ) && ( s [ i - 1 ] ) == ( s [ i - 1 ] ) . toUpperCase ( ) ) modifiedStr += s [ i ] ; } return modifiedStr ; } let s = " " ; document . write ( removeChars ( s ) ) ;

Index/key variables: i
Accumulator variables: i, modifiedStr
Iterator variables: i
Javascript program:
function pangramCost ( arr , str ) { var cost = 0 ; var occurred = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) occurred [ i ] = false ; for ( let i = 0 ; i < str . length ; i ++ ) occurred [ str [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] = true ; for ( let i = 0 ; i < 26 ; i ++ ) { if ( occurred [ i ] == false ) cost += arr [ i ] ; } return cost ; } var 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 ] ; var str = " " ; document . write ( pangramCost ( arr , str ) ) ;

Index/key variables: i
Accumulator variables: cost, i
Iterator variables: i
Javascript program:
let output = " " ; function pairStar ( input , i ) { output = output + input [ i ] ; if ( i == input . length - 1 ) return ; if ( input [ i ] == input [ i + 1 ] ) output = output + ' ' ; pairStar ( input , i + 1 ) ; } let input = " " ; pairStar ( input , 0 ) ; document . write ( output ) ;

Index/key variables: i
Javascript program:
function maxOperations ( str ) { let i , g , gk , gks ; i = g = gk = gks = 0 ; for ( i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] == ' ' ) { g ++ ; } else if ( str [ i ] == ' ' ) { if ( g > 0 ) { g -- ; gk ++ ; } } else if ( str [ i ] == ' ' ) { if ( gk > 0 ) { gk -- ; gks ++ ; } } } return gks ; } let a = " " ; document . write ( maxOperations ( a ) ) ;

Index/key variables: i
Accumulator variables: g, gk, gks, i
Iterator variables: i
Javascript program:
function getFrequencies ( str ) { let freq = new Array ( 26 ) ; for ( let i = 0 ; i < 26 ; i ++ ) freq [ i ] = 0 ; for ( let i = 0 ; i < str . length ; i ++ ) { freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } return freq ; } function countMinParts ( str ) { let n = str . length ; let freq = getFrequencies ( str ) ; let oddFreq = [ ] ; let evenFreq = [ ] ; let i , sumEven = 0 ; for ( i = 0 ; i < 26 ; i ++ ) { if ( freq [ i ] == 0 ) continue ; if ( freq [ i ] % 2 == 0 ) evenFreq . push ( freq [ i ] ) ; else oddFreq . push ( freq [ i ] ) ; } for ( i = 0 ; i < evenFreq . length ; i ++ ) { sumEven += evenFreq [ i ] ; } if ( oddFreq . length == 0 ) return 1 ; if ( sumEven == 0 ) { if ( oddFreq . length == 1 ) return 1 ; return 0 ; } i = 0 ; while ( i < oddFreq . length ) { if ( ( sumEven / 2 ) % oddFreq . length == 0 ) return oddFreq . length ; if ( oddFreq [ i ] == 1 ) { i ++ ; continue ; } sumEven += 2 ; oddFreq [ i ] = oddFreq [ i ] - 2 ; } return n ; } let s = " " ; document . write ( countMinParts ( s ) ) ;

Index/key variables: i
Accumulator variables: i, sumEven
Iterator variables: i
Javascript program:
function printPattern ( s , n ) { document . write ( s . join ( ' ' ) + " " ) ; var i = 0 , j = n - 1 ; while ( i < j ) { var c = s [ i ] ; s [ i ] = s [ j ] ; s [ j ] = c ; i ++ ; j -- ; } i = 0 ; j = n - 1 ; while ( j - i > 1 ) { s [ i ] = s [ j ] = ' ' ; document . write ( s . join ( ' ' ) + " " ) ; i ++ ; j -- ; } } var s = " " . split ( ' ' ) ; var n = s . length ; printPattern ( s , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Javascript program:
function prime ( n ) { if ( n <= 1 ) { return false ; } if ( n <= 3 ) { return true ; } if ( n % 2 == 0 n % 3 == 0 ) { return false ; } for ( let i = 5 ; i * i <= n ; i = i + 6 ) { if ( n % i == 0 || n % ( i + 2 ) == 0 ) { return false ; } } return true ; } function isVowel ( c ) { c = c . toLowerCase ( ) ; if ( c == ' ' c == ' ' c == ' ' c == ' ' c == ' ' ) { return true ; } return false ; } function isValidString ( word ) { let cnt = 0 ; for ( let i = 0 ; i < word . length ; i ++ ) { if ( isVowel ( word [ i ] ) ) { cnt ++ ; } } if ( prime ( cnt ) ) { return true ; } else { return false ; } } let s = " " ; if ( isValidString ( s ) ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: cnt, i
Iterator variables: i