TZinovieva

The song of the wheels JS

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