dhyuti-n/xlcost-variable-roles huggingface dataset:
Javascript program:
function printSubsequences ( s ) { let str = s . split ( ' ' ) ; let n = str . length ; let opsize = Math . pow ( 2 , n - 1 ) ; for ( let counter = 0 ; counter < opsize ; counter ++ ) { for ( let j = 0 ; j < n ; j ++ ) { document . write ( str [ j ] ) ; if ( ( counter & ( 1 << j ) ) > 0 ) document . write ( " " ) ; } document . write ( " " ) ; } } let str = " " ; printSubsequences ( str ) ;

Index/key variables: j
Accumulator variables: counter, j
Iterator variables: counter, j
Javascript program:
let MAX_CHAR = 26 ; let MAX_FACT = 20 ; let fact = new Array ( MAX_FACT ) ; function precomputeFactorirals ( ) { fact [ 0 ] = 1 ; for ( let i = 1 ; i < MAX_FACT ; i ++ ) fact [ i ] = fact [ i - 1 ] * i ; } function nPermute ( str , n ) { precomputeFactorirals ( ) ; let len = str . length ; let freq = new Array ( MAX_CHAR ) ; for ( let i = 0 ; i < MAX_CHAR ; i ++ ) { freq [ i ] = 0 ; } for ( let i = 0 ; i < len ; i ++ ) freq [ str [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; let out = " " ; let sum = 10 ; let k = 0 ; while ( sum >= n ) { for ( let i = 0 ; i < MAX_CHAR ; i ++ ) { if ( freq [ i ] == 0 ) continue ; freq [ i ] -- ; sum = 0 ; let xsum = fact [ len - 1 - k ] ; for ( let j = 0 ; j < MAX_CHAR ; j ++ ) xsum = Math . floor ( xsum / fact [ freq [ j ] ] ) ; sum += xsum ; if ( sum >= n ) { out += String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ; k ++ ; n -= ( sum - xsum ) ; break ; } if ( sum < n ) freq [ i ] ++ ; } } for ( let i = MAX_CHAR - 1 ; k < len && i >= 0 ; i -- ) if ( freq [ i ] != 0 ) { out += String . fromCharCode ( i + ' ' . charCodeAt ( 0 ) ) ; freq [ i ++ ] -- ; } document . write ( out ) ; } let n = 2 ; let str = " " ; nPermute ( str , n ) ;

Index/key variables: i, j
Accumulator variables: i, j, k, n, out, sum
Iterator variables: i, j
Javascript program:
function countDeletions ( s ) { var ans = 0 ; var str = s ; for ( var i = 0 ; i < str . length - 1 ; i ++ ) if ( str [ i ] == str [ i + 1 ] ) ans ++ ; return ans ; } var str = " " ; document . write ( countDeletions ( str ) ) ;

Index/key variables: i
Accumulator variables: ans, i
Iterator variables: i
Javascript program:
function countWords ( str , n ) { var m = new Map ( ) ; for ( var i = 0 ; i < n ; i ++ ) { if ( m . has ( str [ i ] ) ) m . set ( str [ i ] , m . get ( str [ i ] ) + 1 ) else m . set ( str [ i ] , 1 ) } var res = 0 ; m . forEach ( ( value , key ) => { if ( ( value == 2 ) ) res ++ ; } ) ; return res ; } var s = [ " " , " " , " " , " " , " " , " " , " " , " " , " " , " " ] ; var n = s . length ; document . write ( countWords ( s , n ) ) ;

Index/key variables: i
Accumulator variables: i, res
Iterator variables: i
Javascript program:
function evenlength ( n ) { let res = n ; for ( let j = n . length - 1 ; j >= 0 ; -- j ) res += n [ j ] ; return res ; } let n = " " ; document . write ( evenlength ( n ) ) ;

Index/key variables: j
Accumulator variables: res
Iterator variables: j
Javascript program:
function countinString ( ch , s ) { if ( s . length == 0 ) return 0 ; var count = 0 ; if ( s [ 0 ] == ch ) count ++ ; count += countinString ( ch , s . substring ( 1 ) ) ; return count ; } var str = " " ; var c = ' ' ; document . write ( countinString ( c , str ) ) ;

Accumulator variables: count
Javascript program:
function uniqueCharacters ( str ) { for ( let i = 0 ; i < str . length ; i ++ ) for ( let j = i + 1 ; j < str . length ; j ++ ) if ( str [ i ] == str [ j ] ) return false ; return true ; } let input = " " ; if ( uniqueCharacters ( input ) == true ) document . write ( " " + input + " " + " " ) ; else document . write ( " " + input + " " ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function strcheck ( s1 , s2 ) { if ( s1 . localeCompare ( s2 ) != 0 ) return false ; return true ; } function check ( s ) { if ( s . length >= 10 ) return true ; for ( let i = 1 ; i < s . length ; i ++ ) { for ( let j = i + 1 ; j < s . length ; j ++ ) { for ( let k = j + 1 ; k < s . length ; k ++ ) { let s1 = " " , s2 = " " , s3 = " " , s4 = " " ; s1 = s . substring ( 0 , i ) ; s2 = s . substring ( i , i + j - i ) ; s3 = s . substring ( j , j + k - j ) ; s4 = s . substring ( k , k + s . length - k ) ; if ( strcheck ( s1 , s2 ) && strcheck ( s1 , s3 ) && strcheck ( s1 , s4 ) && strcheck ( s2 , s3 ) && strcheck ( s2 , s4 ) && strcheck ( s3 , s4 ) ) return true ; } } } return false ; } let str = " " ; if ( check ( str ) ) document . write ( " " ) ; else document . write ( " " ) ;

Accumulator variables: i, j, k
Iterator variables: i, j, k
Javascript program:
function findIndex ( str ) { let len = str . length ; let open = new Array ( len + 1 ) ; let close = new Array ( len + 1 ) ; for ( let i = 0 ; i < len + 1 ; i ++ ) { open [ i ] = 0 ; close [ i ] = 0 ; } let index = - 1 ; open [ 0 ] = 0 ; close [ len ] = 0 ; if ( str [ 0 ] == ' ' ) open [ 1 ] = 1 ; if ( str [ len - 1 ] == ' ' ) close [ len - 1 ] = 1 ; for ( let i = 1 ; i < len ; i ++ ) { if ( str [ i ] == ' ' ) open [ i + 1 ] = open [ i ] + 1 ; else open [ i + 1 ] = open [ i ] ; } for ( let i = len - 2 ; i >= 0 ; i -- ) { if ( str [ i ] == ' ' ) close [ i ] = close [ i + 1 ] + 1 ; else close [ i ] = close [ i + 1 ] ; } if ( open [ len ] == 0 ) return len ; if ( close [ 0 ] == 0 ) return 0 ; for ( let i = 0 ; i <= len ; i ++ ) if ( open [ i ] == close [ i ] ) index = i ; return index ; } let str = " " ; document . write ( findIndex ( str ) ) ;

Index/key variables: i, len
Accumulator variables: i
Iterator variables: i
Javascript program:
function decimalToBinary ( num , k_prec ) { let binary = " " ; let Integral = parseInt ( num , 10 ) ; let fractional = num - Integral ; while ( Integral > 0 ) { let rem = Integral % 2 ; binary += ( String . fromCharCode ( rem + ' ' . charCodeAt ( ) ) ) ; Integral = parseInt ( Integral / 2 , 10 ) ; } binary = reverse ( binary ) ; binary += ( ' ' ) ; while ( k_prec -- > 0 ) { fractional *= 2 ; let fract_bit = parseInt ( fractional , 10 ) ; if ( fract_bit == 1 ) { fractional -= fract_bit ; binary += String . fromCharCode ( 1 + ' ' . charCodeAt ( ) ) ; } else { binary += String . fromCharCode ( 0 + ' ' . charCodeAt ( ) ) ; } } return binary ; } function reverse ( input ) { let temparray = input . split ( ' ' ) ; let left , right = 0 ; right = temparray . length - 1 ; for ( left = 0 ; left < right ; left ++ , right -- ) { let temp = temparray [ left ] ; temparray [ left ] = temparray [ right ] ; temparray [ right ] = temp ; } return temparray . join ( " " ) ; } let n = 4.47 ; let k = 3 ; document . write ( decimalToBinary ( n , k ) + " " ) ; n = 6.986 ; k = 5 ; document . write ( decimalToBinary ( n , k ) ) ;

Index/key variables: left, right
Accumulator variables: binary, fractional, k_prec, left, right
Iterator variables: left
Javascript program:
function isSmaller ( str1 , str2 ) { let n1 = str1 . length , n2 = str2 . length ; if ( n1 < n2 ) return true ; if ( n2 < n1 ) return false ; for ( let i = 0 ; i < n1 ; i ++ ) { if ( str1 [ i ] . charCodeAt ( ) < str2 [ i ] . charCodeAt ( ) ) return true ; else if ( str1 [ i ] . charCodeAt ( ) > str2 [ i ] . charCodeAt ( ) ) return false ; } return false ; } function findDiff ( str1 , str2 ) { if ( isSmaller ( str1 , str2 ) ) { let t = str1 ; str1 = str2 ; str2 = t ; } let str = " " ; let n1 = str1 . length , n2 = str2 . length ; let diff = n1 - n2 ; let carry = 0 ; for ( let i = n2 - 1 ; i >= 0 ; i -- ) { let sub = ( ( str1 [ i + diff ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) - ( str2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) - carry ) ; if ( sub < 0 ) { sub = sub + 10 ; carry = 1 ; } else carry = 0 ; str += sub . toString ( ) ; } for ( let i = n1 - n2 - 1 ; i >= 0 ; i -- ) { if ( str1 [ i ] == ' ' && carry > 0 ) { str += " " ; continue ; } let sub = ( ( str1 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ) - carry ) ; str += sub . toString ( ) ; carry = 0 ; } let aa = str . split ( ' ' ) ; aa . reverse ( ) ; return aa . join ( " " ) ; } let str1 = " " ; let str2 = " " ; document . write ( findDiff ( str1 , str2 ) ) ;

Index/key variables: i
Accumulator variables: i, str
Iterator variables: i
Javascript program:
function unique ( s ) { for ( var i = 0 ; i < s . length ; i ++ ) { if ( s . charAt ( i ) == s . charAt ( i + 1 ) ) { return false ; } } return true ; } if ( unique ( " " ) == true ) { document . write ( " " ) ; } else { document . write ( " " ) ; }

Accumulator variables: i
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function areKAnagrams ( str1 , str2 , k ) { let n = str1 . length ; if ( str2 . length != n ) return false ; let hash_str1 = Array ( MAX_CHAR ) ; hash_str1 . fill ( 0 ) ; for ( let i = 0 ; i < n ; i ++ ) hash_str1 [ str1 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] ++ ; let count = 0 ; for ( let i = 0 ; i < n ; i ++ ) { if ( hash_str1 [ str2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] > 0 ) hash_str1 [ str2 [ i ] . charCodeAt ( ) - ' ' . charCodeAt ( ) ] -- ; else count ++ ; if ( count > k ) return false ; } return true ; } let str1 = " " ; let str2 = " " ; let k = 2 ; if ( areKAnagrams ( str1 , str2 , k ) == true ) document . write ( " " ) ; else document . write ( " " ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function getDigit ( N , d ) { let str = N . toString ( ) ; return str [ d - 1 ] ; } function getNthChar ( N ) { let sum = 0 , nine = 9 ; let dist = 0 , len ; for ( len = 1 ; ; len ++ ) { sum += nine * len ; dist += nine ; if ( sum >= N ) { sum -= nine * len ; dist -= nine ; N -= sum ; break ; } nine *= 10 ; } let diff = ( Math . ceil ( ( N ) / ( len ) ) ) ; let d = N % len ; if ( d == 0 ) d = len ; return getDigit ( dist + diff , d ) ; } let N = 251 ; document . write ( getNthChar ( N ) ) ;

Accumulator variables: N, dist, len, nine, sum
Iterator variables: len
Javascript program:
function ispalindrome ( s ) { let l = s . length ; let j ; for ( let i = 0 , j = l - 1 ; i <= j ; i ++ , j -- ) { if ( s [ i ] != s [ j ] ) return false ; } return true ; } let s = " " ; let cnt = 0 ; let flag = 0 ; while ( s . length > 0 ) { if ( ispalindrome ( s ) ) { flag = 1 ; break ; } else { cnt ++ ; s = s . substring ( 0 , s . length - 1 ) ; } } s . erase ( s . begin ( ) + s . length ( ) - 1 ) ; if ( flag ) document . write ( cnt ) ;

Index/key variables: i, j
Accumulator variables: cnt, i, j
Iterator variables: i
Javascript program:
function findCount ( str ) { var result = 0 ; function findCount ( $str ) { $result = 0 ; for ( var i = 0 ; i < str . length ; i ++ ) if ( i === str [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) || i === str [ i ] . charCodeAt ( 0 ) - " " . charCodeAt ( 0 ) ) result ++ ; return result ; } var str = " " ; document . write ( findCount ( str ) ) ;

Index/key variables: i
Accumulator variables: i, result
Iterator variables: i
Javascript program:
function isPalindrome ( str , low , high ) { while ( low < high ) { if ( str . charAt ( low ) != str . charAt ( high ) ) return false ; low ++ ; high -- ; } return true ; } function possiblePalinByRemovingOneChar ( str ) { var low = 0 , high = str . length - 1 ; while ( low < high ) { if ( str . charAt ( low ) == str . charAt ( high ) ) { low ++ ; high -- ; } else { if ( isPalindrome ( str , low + 1 , high ) ) return low ; if ( isPalindrome ( str , low , high - 1 ) ) return high ; return - 1 ; } } return - 2 ; } var str = " " ; var idx = possiblePalinByRemovingOneChar ( str ) ; if ( idx == - 1 ) document . write ( " " ) ; else if ( idx == - 2 ) document . write ( " " + " " ) ; else document . write ( " " + " " + idx ) ;

Accumulator variables: high, low
Javascript program:
function print ( str , index ) { if ( index === str . length ) { document . write ( str . join ( " " ) + " " ) ; return ; } if ( str [ index ] === " " ) { str [ index ] = " " ; print ( str , index + 1 ) ; str [ index ] = " " ; print ( str , index + 1 ) ; str [ index ] = " " ; } else print ( str , index + 1 ) ; } var input = " " ; var str = input . split ( " " ) ; print ( str , 0 ) ;

Index/key variables: index
Javascript program:
function countOccurrences ( x , d ) { var count = 0 ; while ( x > 0 ) { if ( x % 10 == d ) count ++ ; x = parseInt ( x / 10 ) ; } return count ; } function maxOccurring ( x ) { if ( x < 0 ) x = - x ; var result = 0 ; var max_count = 1 ; for ( d = 0 ; d <= 9 ; d ++ ) { var count = countOccurrences ( x , d ) ; if ( count >= max_count ) { max_count = count ; result = d ; } } return result ; } var x = 1223355 ; document . write ( " " + maxOccurring ( x ) ) ;

Accumulator variables: count, d
Iterator variables: d
Javascript program:
function removeRecurringDigits ( num ) { let len = num . length ; let s = " " ; for ( let i = 0 ; i < len ; i ++ ) { s += ( num [ i ] ) ; while ( i + 1 < len && num [ i ] == num [ i + 1 ] ) { i ++ ; } } return s ; } let num = " " . split ( " " ) ; document . write ( " " + removeRecurringDigits ( num ) ) ;

Index/key variables: i
Accumulator variables: i, s
Iterator variables: i
Javascript program:
function maxSubarrayXOR ( arr , n ) { let ans = Number . MIN_VALUE ; for ( let i = 0 ; i < n ; i ++ ) { let curr_xor = 0 ; for ( let j = i ; j < n ; j ++ ) { curr_xor = curr_xor ^ arr [ j ] ; ans = Math . max ( ans , curr_xor ) ; } } return ans ; } let arr = [ 8 , 1 , 2 , 12 ] ; let n = arr . length ; document . write ( " " + maxSubarrayXOR ( arr , n ) ) ;

Index/key variables: j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function printPattern ( str , len ) { for ( var i = 0 ; i < len ; i ++ ) { for ( var j = 0 ; j < len ; j ++ ) { if ( ( i == j ) || ( i + j == len - 1 ) ) document . write ( str . charAt ( j ) ) ; else document . write ( " " ) ; } document . write ( ' ' ) ; } } var str = " " ; var len = str . length ; printPattern ( str , len ) ;

Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
let MAX_CHARS = 26 ; function isValid ( count , k ) { let val = 0 ; for ( let i = 0 ; i < MAX_CHARS ; i ++ ) { if ( count [ i ] > 0 ) { val ++ ; } } return ( k >= val ) ; } function kUniques ( s , k ) { let u = 0 ; let n = s . length ; let count = new Array ( MAX_CHARS ) ; for ( let i = 0 ; i < MAX_CHARS ; i ++ ) { count [ i ] = 0 ; } for ( let i = 0 ; i < n ; i ++ ) { if ( count [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] == 0 ) { u ++ ; } count [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; } if ( u < k ) { document . write ( " " ) ; return ; } let curr_start = 0 , curr_end = 0 ; let max_window_size = 1 ; let max_window_start = 0 ; for ( let i = 0 ; i < MAX_CHARS ; i ++ ) { count [ i ] = 0 ; } count [ s [ 0 ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; for ( let i = 1 ; i < n ; i ++ ) { count [ s [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] ++ ; curr_end ++ ; while ( ! isValid ( count , k ) ) { count [ s [ curr_start ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ] -- ; curr_start ++ ; } if ( curr_end - curr_start + 1 > max_window_size ) { max_window_size = curr_end - curr_start + 1 ; max_window_start = curr_start ; } } document . write ( " " + s . substring ( max_window_start , max_window_start + max_window_size + 1 ) + " " + max_window_size ) ; } let s = " " ; let k = 3 ; kUniques ( s , k ) ;

Index/key variables: curr_start, i
Accumulator variables: curr_end, curr_start, i, u, val
Iterator variables: i
Javascript program:
let MAX_CHAR = 26 ; function runCustomerSimulation ( n , seq ) { let seen = new Array ( MAX_CHAR ) . fill ( 0 ) ; let res = 0 ; let occupied = 0 ; for ( let i = 0 ; i < seq . length ; i ++ ) { let ind = seq [ i ] . charCodeAt ( 0 ) - ' ' . charCodeAt ( 0 ) ; if ( seen [ ind ] == 0 ) { seen [ ind ] = 1 ; if ( occupied < n ) { occupied ++ ; seen [ ind ] = 2 ; } else res ++ ; } else { if ( seen [ ind ] == 2 ) { occupied -- ; } seen [ ind ] = 0 ; } } return res ; } document . write ( runCustomerSimulation ( 2 , " " ) + " " ) ; document . write ( runCustomerSimulation ( 3 , " " ) + " " ) ; document . write ( runCustomerSimulation ( 3 , " " ) + " " ) ; document . write ( runCustomerSimulation ( 1 , " " ) + " " ) ; document . write ( runCustomerSimulation ( 1 , " " ) + " " ) ;

Index/key variables: i, ind
Accumulator variables: i, occupied, res
Iterator variables: i
Javascript program:
function canFormPalindrome ( a ) { var bitvector = 0 , mask = 0 ; for ( var i = 0 ; i < a . length ; i ++ ) { var x = a . charCodeAt ( i ) - 97 ; mask = 1 << x ; bitvector = bitvector ^ mask ; } return ( ( bitvector & ( bitvector - 1 ) ) == 0 ) ; } if ( canFormPalindrome ( " " ) ) document . write ( " " + " " ) ; else document . write ( " " + " " ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
let NO_OF_CHARS = 256 function areAnagram ( str1 , str2 ) { let count = [ ] ; for ( let i = 0 ; i < NO_OF_CHARS ; i ++ ) count [ i ] = 0 ; let i = 0 ; while ( i < ( str1 ) . length && i < ( str2 ) . length ) { count [ ord ( str1 [ i ] ) ] += 1 ; count [ ord ( str2 [ i ] ) ] -= 1 ; i += 1 ; } if ( ( str1 ) . length != ( str2 ) . length ) return false ; for ( let i = 0 ; i < NO_OF_CHARS ; i ++ ) { if ( count [ i ] ) return false ; return True ; } } function findAllAnagrams ( arr , n ) { for ( let i = 0 ; i < n ; i ++ ) { for ( let j = i + 1 ; j < n ; j ++ ) { if areAnagram ( arr [ i ] , arr [ j ] ) document . write ( arr [ i ] + " " + arr [ j ] ) } } } let arr = [ " " , " " , " " , " " , " " ] ; let n = ( arr ) . length ; findAllAnagrams ( arr , n ) ;

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
Javascript program:
function isPalindrome ( n ) { var rev = 0 ; for ( var i = n ; Math . trunc ( i ) > 0 ; i /= 10 ) { rev = ( ( rev * 10 ) + ( Math . trunc ( i ) % 10 ) ) ; } return ( n == rev ) ; } function countPal ( min , max ) { for ( var i = min ; i <= max ; i ++ ) { if ( isPalindrome ( i ) ) document . write ( i + " " ) ; } } countPal ( 100 , 2000 ) ;

Accumulator variables: i
Iterator variables: i
Javascript program:
function Minimum_Window ( s , t ) { let m = new Array ( 256 ) ; for ( let i = 0 ; i < 256 ; i ++ ) { m [ i ] = 0 ; } let ans = Number . MAX_VALUE ; let start = 0 ; let count = 0 ; for ( let i = 0 ; i < t . length ; i ++ ) { if ( m [ t [ i ] . charCodeAt ( 0 ) ] == 0 ) count ++ ; m [ t [ i ] . charCodeAt ( 0 ) ] ++ ; } let i = 0 ; let j = 0 ; while ( j < s . length ) { m [ s [ j ] . charCodeAt ( 0 ) ] -- ; if ( m [ s [ j ] . charCodeAt ( 0 ) ] == 0 ) count -- ; if ( count == 0 ) { while ( count == 0 ) { if ( ans > j - i + 1 ) { ans = Math . min ( ans , j - i + 1 ) ; start = i ; } m [ s [ i ] . charCodeAt ( 0 ) ] ++ ; if ( m [ s [ i ] . charCodeAt ( 0 ) ] > 0 ) count ++ ; i ++ ; } } j ++ ; } if ( ans != Number . MAX_VALUE ) return ( s ) . join ( " " ) . substring ( start , ( start + ans ) ) ; else return " " ; } let s = " " ; let t = " " ; document . write ( " " + " " ) ; document . write ( Minimum_Window ( s . split ( " " ) , t . split ( " " ) ) ) ;

Index/key variables: i, j
Accumulator variables: count, i, j
Iterator variables: i
Javascript program:
function printRLE ( str ) { let n = str . length ; for ( let i = 0 ; i < n ; i ++ ) { let count = 1 ; while ( i < n - 1 && str [ i ] == str [ i + 1 ] ) { count ++ ; i ++ ; } document . write ( str [ i ] ) ; document . write ( count ) ; } } let str = " " ; printRLE ( str ) ;

Index/key variables: i
Accumulator variables: count, i
Iterator variables: i
Javascript program:
function divideString ( str , n ) { let str_size = str . length ; let part_size ; if ( str_size % n != 0 ) { document . write ( " " + " " ) ; return ; } part_size = parseInt ( str_size / n , 10 ) ; for ( let i = 0 ; i < str_size ; i ++ ) { if ( i % part_size == 0 ) document . write ( " " ) ; document . write ( str [ i ] ) ; } } let str = " " ; divideString ( str , 4 ) ;

Index/key variables: i
Accumulator variables: i
Iterator variables: i
Javascript program:
function isCorner ( i , j , M , N ) { if ( ( i == 0 && j == 0 ) || ( i == 0 && j == N - 1 ) || ( i == M - 1 && j == N - 1 ) || ( i == M - 1 && j == 0 ) ) return true ; return false ; } function isValid ( i , j , M , N ) { if ( i < 0 i >= M j < 0 j >= N ) return false ; return true ; } function solve ( i , j , M , N , Dir , maze , t , ans ) { if ( isCorner ( i , j , M , N ) ) { ans . push ( t ) ; return ; } for ( let k = 0 ; k < 4 ; k ++ ) { let x = i + Dir [ k ] [ 0 ] ; let y = j + Dir [ k ] [ 1 ] ; let c = Dir [ k ] [ 2 ] ; if ( isValid ( x , y , M , N ) && maze [ x ] [ y ] == 1 ) { maze [ x ] [ y ] = 0 ; t += c ; solve ( x , y , M , N , Dir , maze , t , ans ) ; t = t . substr ( 0 , t . length - 1 ) ; maze [ x ] [ y ] = 1 ; } } return ; } function possiblePaths ( src , maze ) { let Dir = [ [ - 1 , 0 , " " ] , [ 0 , 1 , " " ] , [ 1 , 0 , " " ] , [ 0 , - 1 , " " ] , ] ; let temp = " " ; let ans = [ ] ; solve ( src [ 0 ] , src [ 1 ] , maze . length , maze [ 0 ] . length , Dir , maze , temp , ans ) ; return ans ; } let maze = [ [ 1 , 0 , 0 , 1 , 0 , 0 , 1 , 1 ] , [ 1 , 1 , 1 , 0 , 0 , 0 , 1 , 0 ] , [ 1 , 0 , 1 , 1 , 1 , 1 , 1 , 0 ] , [ 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 ] , [ 1 , 0 , 1 , 0 , 1 , 0 , 0 , 1 ] , [ 0 , 1 , 1 , 1 , 1 , 0 , 0 , 1 ] , [ 0 , 1 , 0 , 0 , 1 , 1 , 1 , 1 ] , [ 1 , 1 , 0 , 0 , 0 , 0 , 0 , 1 ] , ] ; let src = [ 4 , 2 ] ; let paths = possiblePaths ( src , maze ) ; if ( paths . length == 0 ) { document . write ( " " ) ; } else { for ( let i = 0 ; i < paths . length ; i ++ ) { if ( paths [ i ] ) document . write ( paths [ i ] + " " ) ; } }

Index/key variables: i, k, x, y
Accumulator variables: i, k, t
Iterator variables: i, k
Javascript program:
const N = 2 ; function issafe ( sudoku , i , j , n , number , region ) { for ( let x = 0 ; x < n ; x ++ ) { if ( sudoku [ x ] [ j ] == number sudoku [ i ] [ x ] == number ) { return false ; } } let r = region [ i ] [ j ] ; let q = [ ] ; q . push ( [ i , j ] ) ; let visited = new Array ( N ) . fill ( 0 ) . map ( ( ) => new Array ( N ) . fill ( 0 ) ) ; visited [ i ] [ j ] = 1 ; while ( ! q . length ) { let front = q . front ( ) ; q . pop ( ) ; if ( front [ 0 ] + 1 < N && region [ front [ 0 ] + 1 ] [ front [ 1 ] ] == r && ! visited [ front [ 0 ] + 1 ] [ front [ 1 ] ] ) { if ( sudoku [ front [ 0 ] + 1 ] [ front [ 1 ] ] == number ) { return false ; } q . push ( [ front [ 0 ] + 1 , front [ 1 ] ] ) ; visited [ front [ 0 ] + 1 ] [ front [ 1 ] ] = 1 ; } if ( front [ 0 ] - 1 >= 0 && region [ front [ 0 ] - 1 ] [ front [ 1 ] ] == r && ! visited [ front [ 0 ] - 1 ] [ front [ 1 ] ] ) { if ( sudoku [ front [ 0 ] - 1 ] [ front [ 1 ] ] == number ) { return false ; } q . push ( [ front [ 0 ] - 1 , front [ 1 ] ] ) ; visited [ front [ 0 ] - 1 ] [ front [ 1 ] ] = 1 ; } if ( front [ 1 ] + 1 < N && region [ front [ 0 ] ] [ front [ 1 ] + 1 ] == r && ! visited [ front [ 0 ] ] [ front [ 1 ] + 1 ] ) { if ( sudoku [ front [ 0 ] ] [ front [ 1 ] + 1 ] == number ) { return false ; } q . push ( [ front [ 0 ] , front [ 1 ] + 1 ] ) ; visited [ front [ 0 ] ] [ front [ 1 ] + 1 ] = 1 ; } if ( front [ 1 ] - 1 >= 0 && region [ front [ 0 ] ] [ front [ 1 ] - 1 ] == r && ! visited [ front [ 0 ] ] [ front [ 1 ] - 1 ] ) { if ( sudoku [ front [ 0 ] ] [ front [ 1 ] - 1 ] == number ) { return false ; } q . push ( [ front [ 0 ] , front [ 1 ] - 1 ] ) ; visited [ front [ 0 ] ] [ front [ 1 ] - 1 ] = 1 ; } } return true ; } function solveSudoku ( sudoku , i , j , n , region ) { if ( i == n ) { for ( let a = 0 ; a < n ; a ++ ) { for ( let b = 0 ; b < n ; b ++ ) { document . write ( sudoku [ a ] [ b ] + " " ) ; } document . write ( " " ) ; } return true ; } if ( j == n ) { return solveSudoku ( sudoku , i + 1 , 0 , n , region ) ; } if ( sudoku [ i ] [ j ] != 0 ) { return solveSudoku ( sudoku , i , j + 1 , n , region ) ; } else { for ( let number = 1 ; number <= n ; number ++ ) { if ( issafe ( sudoku , i , j , n , number , region ) ) { sudoku [ i ] [ j ] = number ; let rest = solveSudoku ( sudoku , i , j + 1 , n , region ) ; if ( rest == true ) { return true ; } } } sudoku [ i ] [ j ] = 0 ; return false ; } } let sudoku = [ [ 0 , 1 ] , [ 0 , 0 ] , ] ; let region = [ [ " " , " " ] , [ " " , " " ] , ] ; let ans = solveSudoku ( sudoku , 0 , 0 , N , region ) ; if ( ans == 0 ) { document . write ( cout + " " ) ; }

Index/key variables: a, b, i, j, x
Accumulator variables: a, b, number, x
Iterator variables: a, b, number, x