Skip to content

Instantly share code, notes, and snippets.

View pengx17's full-sized avatar
🛫

Peng Xiao pengx17

🛫
View GitHub Profile
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;
function toDec(num) {
return parseInt(num, 2);
}
/**
*
* @param {string} input
* @returns {[number, number]}
*/
function read(input, start, length) {
const input = `
1163751742
1381373672
2136511328
3694931569
7463417111
1319128137
1359912421
3125421639
1293138521
const input = `NNCB
CH -> B
HH -> N
CB -> H
NH -> C
HB -> C
HC -> B
HN -> C
NN -> C
const input = `6,10
0,14
9,10
0,3
10,4
4,11
6,0
6,12
4,1
0,13
let input = `fs-end
he-DX
fs-he
start-DX
pj-DX
end-zg
zg-sl
zg-pj
pj-he
RW-he
let input = `5483143223
2745854711
5264556173
6141336146
6357385478
4167524645
2176841721
6882881134
4846848554
5283751526`;
let raw = `[({(<(())[]>[[{[]{<()<>>
[(()[<>])]({[<{<<[]>>(
{([(<{}[<>[]}>{[]{[(<()>
(((({<>}<{<{<>}{[]{[]{}
[[<[([]))<([[{}[[()]]]
[{[{({}]{}}([{[{{{}}([]
{<[[]]>}<{[{[{[]{()[[[]
[<(<(<(<{}))><([]([]()
<{([([[(<>()){}]>(<<{{
<{([{{}}[<[[[<>{}]]]>[]]`;
const input = `2199943210
3987894921
9856789892
8767896789
9899965678`;
function run(input = "") {
const lines = input.split("\n");
const matrix = lines.map((line) => line.split(""));
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);