Created
January 10, 2020 23:48
-
-
Save amejiarosario/90512b1a6489d97e9b24439c10a4fdf7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function findXYZ(n) { | |
const solutions = []; | |
for(let x = 0; x < n; x++) { | |
for(let y = 0; y < n; y++) { | |
for(let z = 0; z < n; z++) { | |
if( 3*x + 9*y + 8*z === 79 ) { | |
solutions.push({x, y, z}); | |
} | |
} | |
} | |
} | |
return solutions; | |
} | |
console.log(findXYZ(10)); // => [{x: 0, y: 7, z: 2}, ...] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment