Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wheels(input){
- let m = Number(input.shift())
- let ctr = 0;
- let output = "";
- let allPass = "";
- for (let i = 1; i <= 9; i++){
- for (let j = 1; j <= 9; j++){
- for (let k = 1; k <= 9; k++){
- for (let l = 1; l < 9; l++){
- if (i < j && k > l)
- {
- let calculation = i * j + k * l;
- if (calculation == m){
- allPass += `${i}${j}${k}${l} `;
- ctr++;
- if (ctr == 4){
- output = `${i}${j}${k}${l}`;
- }
- }
- }
- }
- }
- }
- }
- if(allPass != "" && output != "") {
- console.log(`${allPass}`);
- console.log(`Password: ${output}`);
- } else if(allPass != "" && output == "") {
- console.log(`${allPass}`);
- console.log(`No!`);
- } else {
- console.log(`No!`);
- }
- }
- wheels([11]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement