Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 1x 1x 1x 1x 9x 9x 9x 9x 4x 4x 5x 5x 5x 5x 5x 5x 1x 1x | // You want to divide a farm evenly into squares // the plots to be big as possible const solution = (farm: number[]): number => { const length = Math.max(farm[0], farm[1]); const width = Math.min(farm[0], farm[1]); // base case if (length % width === 0) { return width; } // recursion case // make the farm smaller const newFarm: [number, number] = [width, length - width]; return solution(newFarm); }; export default solution; |