Created
April 26, 2023 18:25
-
-
Save gkucmierz/56cedbbaf9e9b93b51ab0b93c0ca5e16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://youtu.be/HDre_o2qz1o?t=238 | |
// Dziadek i babcia mają razem 126 lat, a dziadek ma dwa razy tyle, | |
// ile babcia miała wtedy kiedy dziadek miał tyle ile babcia ma obecnie. | |
// Ile lat ma babcia? | |
const test = (x, diff) => { | |
const bago = x; | |
const d = bago * 2; | |
const b = bago + diff; | |
const dago = b; | |
return dago + diff === d ? [d, b, d + b] : []; | |
}; | |
for (let i = 0; i < 100; ++i) { | |
for (let j = 0; j < 100; ++j) { | |
const [d, b, res] = test(i, j); | |
if (res === 126) { | |
console.log(d, b, res); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment