Advertisement
Spocoman

12. The song of the wheels

Jan 1st, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function  theSongOfTheWheels(input) {
  2.     let number = Number(input[0]);
  3.     let print = '';
  4.     let password = 'No!';
  5.     let counter = 0;
  6.  
  7.     for (let a = 1; a <= 9; a++) {
  8.         for (let b = 1; b <= 9; b++) {
  9.             for (let c = 1; c <= 9; c++) {
  10.                 for (let d = 1; d <= 9; d++) {
  11.                     if (a * b + c * d === number && a < b && c > d) {
  12.                         print += `${a}${b}${c}${d} `;
  13.                         counter++;
  14.                         if (counter === 4) {
  15.                             password = `Password: ${a}${b}${c}${d}`;
  16.                         }
  17.                     }
  18.                 }
  19.             }
  20.         }
  21.     }
  22.     console.log(`${print}\n${password}`);
  23. }
  24.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement