Advertisement
AlexandrP

Untitled

Dec 11th, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function x(input) {
  2.   let k = input[0];
  3.   let l = input[1];
  4.   let m = input[2];
  5.   let n = input[3];
  6.  
  7.   let counterValid = 0;
  8.   for (i = k; i <= 8 && counterValid != 6; i++) {
  9.     if (i % 2 != 0) {
  10.       continue;
  11.     }
  12.  
  13.     for (j = 9; j >= l && counterValid != 6; j--) {
  14.       if (j % 2 == 0) {
  15.         continue;
  16.       }
  17.       let sum = Number(i + `${j} `);
  18.  
  19.       for (y = m; y <= 8 && counterValid != 6; y++) {
  20.         if (y % 2 != 0) {
  21.           continue;
  22.         }
  23.  
  24.         for (z = 9; z >= n; z--) {
  25.           if (z % 2 == 0) {
  26.             continue;
  27.           }
  28.           let sum2 = Number(y + `${z} `);
  29.  
  30.           if (sum == sum2) {
  31.             console.log(`Cannot change the same player.`);
  32.           } else {
  33.             counterValid++;
  34.  
  35.            
  36.        
  37.             console.log(`${sum} - ${sum2}`);
  38.  
  39.             if(counterValid == 6){
  40.                 break
  41.             }
  42.          
  43.           }
  44.         }
  45.       }
  46.     }
  47.   }
  48. }
  49.  
  50. x(["6", "7", "5", "6"]);
  51.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement