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
| let checkCondtion = function(condition, registers) { | |
| let test = false; | |
| switch (condition[2]) { | |
| case '>': | |
| if (registers[condition[1]] > condition[3]) { | |
| test = true; | |
| } | |
| break; | |
| case '<': | |
| if (registers[condition[1]] < condition[3]) { |
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
| let test = `llyhqfe (21) | |
| vpbdpfm (74) -> ndegtj, wnwxs | |
| dosteiu (262) -> vliyv, rfxmk, nulxd, tckql | |
| leqnli (222) -> wuttw, nckca | |
| cgztcyz (59) -> zbtmpkc, lleaucw, zxvjkqv, tqjyoj | |
| dqfti (67) | |
| vsjhe (34) -> zpbbgqh, menyi, ksasli, uahdbi, ccfiz, kdwmlx | |
| ntzuhe (98) | |
| mpjrzt (53) | |
| dnzll (23) |
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
| let memoryReallocation = function(memory) { | |
| let previousStates = [memory.join(',')]; | |
| let stateSeen = false; | |
| let loopStart = -1; | |
| console.log(previousStates.length, memory.length, memory.join(',')); | |
| while (!stateSeen) { | |
| let blocks = Math.max(...memory); | |
| let index = memory.indexOf(blocks); | |
| memory[index++] = 0; |
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
| let twistyTrampolines = function(jumps) { | |
| let steps = 0; | |
| let inside = true; | |
| let index = 0; | |
| while (inside) { | |
| if ( isNaN(index)) { | |
| inside = false; | |
| } | |
| let oldJump = jumps[index]; | |
| let oldIndex = index; |
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
| let test = `nyot babgr babgr kqtu kqtu kzshonp ylyk psqk | |
| iix ewj rojvbkk phrij iix zuajnk tadv givslju ewj bda | |
| isjur jppvano vctnpjp ngwzdq pxqfrk mnxxes zqwgnd giqh | |
| ojufqke gpd olzirc jfao cjfh rcivvw pqqpudp | |
| ilgomox extiffg ylbd nqxhk lsi isl nrho yom | |
| feauv scstmie qgbod enpltx jrhlxet qps lejrtxh | |
| wlrxtdo tlwdxor ezg ztp uze xtmw neuga aojrixu zpt | |
| wchrl pzibt nvcae wceb | |
| rdwytj kxuyet bqnzlv nyntjan dyrpsn zhi kbxlj ivo | |
| dab mwiz bapjpz jbzppa |
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
| let findMoves = function(location) { | |
| let previousSquare = Math.floor(Math.sqrt(location)); | |
| previousSquare = previousSquare % 2 == 0 ? previousSquare - 1 : previousSquare; | |
| let sideSize = previousSquare + 1; | |
| previousSquare *= previousSquare; | |
| console.log('debug', previousSquare, Math.floor(sideSize / 2), Math.floor((location - previousSquare) % (sideSize / 2))); | |
| return Math.floor(sideSize / 2) + Math.floor((location - previousSquare) % (sideSize / 2)); | |
| }; |
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
| let spreadsheet = `179 2358 5197 867 163 4418 3135 5049 187 166 4682 5080 5541 172 4294 1397 | |
| 2637 136 3222 591 2593 1982 4506 195 4396 3741 2373 157 4533 3864 4159 142 | |
| 1049 1163 1128 193 1008 142 169 168 165 310 1054 104 1100 761 406 173 | |
| 200 53 222 227 218 51 188 45 98 194 189 42 50 105 46 176 | |
| 299 2521 216 2080 2068 2681 2376 220 1339 244 605 1598 2161 822 387 268 | |
| 1043 1409 637 1560 970 69 832 87 78 1391 1558 75 1643 655 1398 1193 | |
| 90 649 858 2496 1555 2618 2302 119 2675 131 1816 2356 2480 603 65 128 | |
| 2461 5099 168 4468 5371 2076 223 1178 194 5639 890 5575 1258 5591 6125 226 | |
| 204 205 2797 2452 2568 2777 1542 1586 241 836 3202 2495 197 2960 240 2880 | |
| 560 96 336 627 546 241 191 94 368 528 298 78 76 123 240 563 |
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
| let circularMatchSum = function(numbers) { | |
| numbers = numbers | |
| .toString() | |
| .split('') | |
| .map(v => parseInt(v)); | |
| let [lastDigit] = numbers.slice(-1); | |
| return numbers.reduce((acc, v, i) => { | |
| if (v == lastDigit) { | |
| acc += v; |
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
| // Starting point was based off of an answer on StackOverflow | |
| // https://stackoverflow.com/a/3824292/187675 | |
| let grabMyGists = function(userName, linkMatch, descMatch) { | |
| let links = [...document.links].filter( | |
| link => | |
| link.hostname === location.hostname && | |
| link.href.includes(userName) && | |
| link.text.match(linkMatch) | |
| ); |
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
| let permutations = function(string) { | |
| if (Array.isArray(string)) { | |
| string = string.join(','); | |
| } | |
| if (string.length == 1) { | |
| return [string]; | |
| } else { | |
| return string.split(',').reduce((acc, l, i, arr) => { | |
| return acc.concat( | |
| permutations( |