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
const assert = require("assert"); | |
let xrange = [241, 273]; | |
let yrange = [-97, -63]; | |
function check([x, y], [vx, vy], maxHeight = 0, inShoot = false) { | |
[x, y] = [x + vx, y + vy]; | |
// console.log([x, y], [vx, vy], maxHeight, inShoot); | |
vx = vx > 0 ? vx - 1 : vx < 0 ? vx + 1 : 0; |
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
function toDec(num) { | |
return parseInt(num, 2); | |
} | |
/** | |
* | |
* @param {string} input | |
* @returns {[number, number]} | |
*/ | |
function read(input, start, length) { |
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
const input = ` | |
1163751742 | |
1381373672 | |
2136511328 | |
3694931569 | |
7463417111 | |
1319128137 | |
1359912421 | |
3125421639 | |
1293138521 |
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
const input = `NNCB | |
CH -> B | |
HH -> N | |
CB -> H | |
NH -> C | |
HB -> C | |
HC -> B | |
HN -> C | |
NN -> C |
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
const input = `6,10 | |
0,14 | |
9,10 | |
0,3 | |
10,4 | |
4,11 | |
6,0 | |
6,12 | |
4,1 | |
0,13 |
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
let input = `fs-end | |
he-DX | |
fs-he | |
start-DX | |
pj-DX | |
end-zg | |
zg-sl | |
zg-pj | |
pj-he | |
RW-he |
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
let input = `5483143223 | |
2745854711 | |
5264556173 | |
6141336146 | |
6357385478 | |
4167524645 | |
2176841721 | |
6882881134 | |
4846848554 | |
5283751526`; |
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
let raw = `[({(<(())[]>[[{[]{<()<>> | |
[(()[<>])]({[<{<<[]>>( | |
{([(<{}[<>[]}>{[]{[(<()> | |
(((({<>}<{<{<>}{[]{[]{} | |
[[<[([]))<([[{}[[()]]] | |
[{[{({}]{}}([{[{{{}}([] | |
{<[[]]>}<{[{[{[]{()[[[] | |
[<(<(<(<{}))><([]([]() | |
<{([([[(<>()){}]>(<<{{ | |
<{([{{}}[<[[[<>{}]]]>[]]`; |
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
const input = `2199943210 | |
3987894921 | |
9856789892 | |
8767896789 | |
9899965678`; | |
function run(input = "") { | |
const lines = input.split("\n"); | |
const matrix = lines.map((line) => line.split("")); |
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
function permutate(arr = []) { | |
let res = []; | |
if (arr.length === 1) { | |
return [arr]; | |
} | |
for (let i = 0; i < arr.length; i++) { | |
let c = arr[i]; | |
let rest = arr.slice(); | |
rest.splice(i, 1); |