This file contains hidden or 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
| // Eulers bricks (brute force) | |
| const check = (a, b, c) => { | |
| if (Math.hypot(a, b) % 1 !== 0) return false; | |
| if (Math.hypot(b, c) % 1 !== 0) return false; | |
| if (Math.hypot(c, a) % 1 !== 0) return false; | |
| return Math.hypot(a, b, c); | |
| } | |
| const MAX = 1e3; |
This file contains hidden or 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; |
This file contains hidden or 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
| $names = array('Apollona', | |
| 'Apollina', | |
| 'Apolonia', | |
| 'Arabella', | |
| 'Ariadna', | |
| 'Arleta', | |
| 'Arnolda', | |
| 'Astryda', | |
| 'Atena', | |
| 'Augusta', |
This file contains hidden or 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
| [ | |
| "Kij bejsbolowy i piłka łącznie kosztują 1,10. Kij kosztuje o 1 dolar więcej niż piłka. Jaka w takim razie jest cena piłki?", | |
| "5 urzqdzen produkuje 5 gadżetów w 5 minut. Jak długo zajmie 100 maszyn zrobienie 100 gadżetów?", | |
| "W jeziorze znajdują sie liliowce. Każdego dnia stają się większe, podwajając swoją objętość. Jesli w 48 dni lisć pokryje całe jezioro, to ile czasu zajmie, by liść zakrył połowę jeziora?" | |
| ] |
This file contains hidden or 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://hackernoon.com/how-does-rsa-work-f44918df914b | |
| const key = { | |
| mod: 14, | |
| pub: 5, | |
| prv: 11, | |
| }; | |
| const msg = 'hello'; |
This file contains hidden or 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
| // http://www.pleacher.com/handley/puzzles/blackhol.html | |
| const randBI = () => { | |
| const maxLen = 10_000; | |
| return BigInt(new Array(Math.round(Math.random() * maxLen)) | |
| .fill(0) | |
| .map(_ => Math.round(Math.random() * 10) % 10) | |
| .join('')) | |
| }; |
This file contains hidden or 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
| const kaprekarNext = n => { | |
| const a = [...n + ''].map(n => +n); | |
| a.sort((a, b) => b - a); | |
| return +a.join('') - +a.reverse().join(''); | |
| }; | |
| const kaprekarLoop = n => { | |
| let last; | |
| while (last !== n) { | |
| last = n; |
This file contains hidden or 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
| // usefull object, to clip array in O(1) when we don't want to make copies of it (slice) | |
| const ClipArray = arr => { | |
| let low = 0; | |
| let up = arr.length; | |
| const length = () => up - low; | |
| return { | |
| clipHead: n => { | |
| low += n; | |
| if (low > up) low = up; |
This file contains hidden or 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
| const collatz = n => { | |
| const res = [n]; | |
| while (n !== 1) { | |
| if (n % 2 === 0) { | |
| n /= 2; | |
| } else { | |
| n = n * 3 + 1; | |
| } | |
| res.push(n); |
This file contains hidden or 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
| var silent = false; | |
| var mute = () => silent = true; | |
| var unmute = () => silent = false; | |
| var loop = () => { | |
| const play = (frequency = 300, duration = 1e3) => { | |
| const context = new AudioContext(); | |
| const gainNode = context.createGain(); | |
| const oscillator = context.createOscillator(); |