Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function substitute(input) {
- let index = 0;
- let num1IntBegin = Number(input[index]);
- index++;
- let num2IntBegin = Number(input[index]);
- index++;
- let num1Int2Begin = Number(input[index]);
- index++;
- let num2Int2Begin = Number(input[index]);
- index++;
- let swapsCounter = 0;
- let swapsLimit = false;
- for (let i = num1IntBegin; i <= 8; i++) {
- for (let i2 = 9; i2 >= num2IntBegin; i2--) {
- for (let i3 = num1Int2Begin; i3 <= 8; i3++) {
- for (let i4 = 9; i4 >= num2Int2Begin; i4--) {
- let result = "";
- let result2 = "";
- if (i % 2 === 0 && i2 % 2 !== 0 && i3 % 2 === 0 && i4 % 2 !== 0) {
- result += "" + i + i2;
- result2 += "" + i3 + i4;
- if (swapsCounter < 6) {
- if (result !== result2) {
- swapsCounter++;
- console.log(`${result} - ${result2}`);
- } else {
- console.log("Cannot change the same player.");
- }
- } else {
- break;
- }
- }
- }
- }
- }
- }
- }
- substitute(["6", "7", "5", "6"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement