Advertisement
Guest User

Untitled

a guest
Mar 4th, 2019
423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function wheels(input){
  2.     let m = Number(input.shift())
  3.     let  ctr = 0;
  4.     let output = "";
  5.     let allPass = "";
  6.    
  7.     for (let i = 1; i <= 9; i++){
  8.         for (let j = 1; j <= 9; j++){
  9.             for (let k = 1; k <= 9; k++){
  10.                 for (let l = 1; l < 9; l++){
  11.                     if (i < j && k > l)
  12.                     {
  13.                         let calculation = i * j + k * l;
  14.                         if (calculation == m){  
  15.                             allPass += `${i}${j}${k}${l} `;                                                
  16.                             ctr++;
  17.                             if (ctr == 4){
  18.                                 output = `${i}${j}${k}${l}`;
  19.                             }
  20.                         }                                          
  21.                     }
  22.                 }
  23.             }
  24.         }
  25.            
  26.     }
  27.         if(allPass != "" && output != "") {
  28.             console.log(`${allPass}`);  
  29.             console.log(`Password: ${output}`);      
  30.         } else if(allPass != "" && output == "") {
  31.             console.log(`${allPass}`);  
  32.             console.log(`No!`);  
  33.         } else {
  34.             console.log(`No!`);
  35.         }
  36.     }
  37.     wheels([11]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement