#### Category : backtracking

I was trying to calculate the maximum product that can be achieved when traveling from the top left of a 2D array to the bottom right. I know there is a solution here that uses dynamic programming in a bottom up manner (i.e. iterative for loops here: https://www.byte-by-byte.com/matrixproduct/) I was attempting to do this using ..

Im trying to make a sudoku solver algorithm to practice recursion and backtracking, so made this function ‘backtrack’ which is the main function that’s supposed to solve it , and four other ‘utility/helper’ functions;the first one is ‘getSubGrid’ which returns the subgrid where the current number belongs,and then ‘getColumn’ which returns the column where the ..

In trying to solve the following problem: Generate all combinations of an array of string. Ex: Input: [‘A’, ‘T’, ‘C’, ‘K’] Output: [ ‘ATCK’, ‘ATC’, ‘ATK’, ‘AT’, ‘ACK’, ‘AC’, ‘AK’, ‘A’, ‘TCK’, ‘TC’, ‘TK’, ‘T’, ‘CK’, ‘C’, ‘K’, ” ] I have the following code: function getSpellableWords(arr) { const res = []; // helper(arr, res, ..

let row = this.findEmpty(puzzleString); let col = this.findEmpty(puzzleString); let i = this.findEmpty(puzzleString); if(!this.findEmpty(puzzleString)) return puzzleString for(let num = 1; num < 10; num++){ if(this.checkValue(puzzleString, row, col, num)){ puzzleString[i] = num; this.solve(puzzleString) } } findEmpty(puzzleString) iterates over the puzzle string and returns the row (A-I), column (1-9), and index of a blank grid. checkValue() contains 3 ..

I am trying to implement a backtracking algorithm in JS to find the minimum value possible by swapping k digits. I can’t see why my code doesn’t work. If I log out the values for num, it goes down to 159 but that doesn’t get returned as the minSoFar, for some reason. Any ideas please? ..