-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sooo many off by ones again --------Part 1-------- --------Part 2-------- Day Time Rank Score Time Rank Score 14 10:47:42 22765 0 12:53:42 17267 0 Adjusted: 8:45, 2:14:45
- Loading branch information
1 parent
d49995a
commit b2d8082
Showing
5 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
O....#.... | ||
O.OO#....# | ||
.....##... | ||
OO.#O....O | ||
.O.....O#. | ||
O.#..O.#.# | ||
..O..#O..O | ||
.......O.. | ||
#....###.. | ||
#OO..#.... |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
...O..O.O.O.#.OO....#..O.O#.#O...#.OO.##.#...O#...#.##........##.#O#..#......#.OO......#.....O.#..O. | ||
..OO...O.##.#...O.....OO#.O..O......O#...........#.O.#..#.###O....O..........#...O..#..#....O..#OO.O | ||
.#OO.......#.#....O..O.#......#...#O......#...O.OO..........O..O.#.O.OO.O#OO.O....#..O#..O..O.....#. | ||
OO..O#..OO.....#..OO..#..OOO#..O......O.##..O#....OOO.##........O.#.O....#..O.O...#....#..O#..#.O.## | ||
#O.O.....O.#.#.#.#.#......O#..O..O.#...O..O.O.O...O.O.O.OOO.....O...O..O...###O.OOO...#..OO..O#O#... | ||
.......O...OO.O.O.OO.OO..O....#O...O.#O........##.O...#....#O...#.....O..OO.O.##...O#####.OO.O....#. | ||
##.....O#...O..O....OO....OO#.O....O.#..O.#.O.....OO......OO...OO#....#.........#.....#..O.O....O... | ||
O#.#.OO........O....#.O...O.##..###.#.O.#......#.....O.....O#...#.#O..O....O##O#..O..O#.#..#.....O.. | ||
O..O#....#...O#......OO.#...#OOOO...O..O...O###O.O###.....#....#O#O#OOO....O.#....OO..O....O...##.O. | ||
.......O#O..........#...OOO..OO##..O...O#...#O.O..O..O...#O.....O#O.#........OO.#OO....#O.O.#.O...O# | ||
.#.#.....O.#.O.#.##..#O.....#O.##O....O#O.O#.....#...O..##O............O.O#.#....O....O.O.........O. | ||
....O#..O#.#.O.........OO..O#O..#.....#.#..O..O....#.#...OO......#...#..#..O##O..O.#...........O#..# | ||
...O..........O..#O#..OO#.#...OO.O.O#.O.OO..#........#..OO..O.OO.....#.#O....O.O#O.OO.#...O.#O...O.. | ||
..O..OO..#O..O#..O..O#.#..OO...O.O...#.O..O.......O...OOO.........OO..O......#..#..O...O..O##.#OO... | ||
........OO.O.O...O..##...O##...O..O..O.OO..O.#.#.....#.O.O.O.....O.##...O#O..#......##.#...O.O...O.. | ||
OO#..............#...O.......#.O.....O..##.......O.O##....#O..#.O...#O#.O.##.O#....#...O..O..#....O. | ||
..#.O...#.....O...O..#.##O..O....O.O.....O..O........O...#O...#..O...O....O..O....#.O..O.O......#... | ||
...OO.O...#..#...O.OO#......O..O.O.#..#..........###..#.#.......#.O..#.O......OO.#.O#..O..O.O..#..O. | ||
...#.......O##O..#O...#.#.#..#..#...#.....OOO#.O#O#.....O......OO....#.#.OO....O.O.##O..O....O#O.#.O | ||
##O#.OO.O#....O.#..O..O..##...O..#O.O...........#O.##....#...O....#OO.OO....O....#OO#O.......O...... | ||
#O..#.....O....O.O#O..O.O.O....O.O#.OOO...#.#.O.OOO#.O#....#.OO#.###.....#...O#O.#.....OO..O.....O.O | ||
##..#....#.O.#.#...OO.O.....#.#.#.###......##.....O....#...O##OO.O.OO.OO##.O.......#..O##.....OOO.#O | ||
......O.#..OO..O......#OO....O..O...O....O.....OO......##.#.OO....O.....O..O..O.#.#..#..OO#.O..OO... | ||
....##...O.O.O.O.O..O..#O..#........#.O..O...#.O.....###.O..O.#..O......O##....O.....O.#.....#....OO | ||
#....#..........#.......O.O#.........#.#..O......O..O#.O..O.##.##..O..#OO.O#...............O#.#O.... | ||
..##..O#O.#......O#..#....#.O...O...O.O.O#....##.#...O..O#......#.O#.#.......O#O...#.##..#..OO..O... | ||
...O.#..O.....OO##.....OO.#......O.OO..#.O##.#....O#.O.#....#..O#.O.#...#........#.#.#O..O...#O..#.. | ||
...##..........O#.#......O.......OOO...O..............O.O##........#........O.....O....#O#.#.....#O. | ||
.#......O...O..#...#..#.O#.....O..OO#O...O.....##.#.#......OO..O##......#...O.O....O..##...O....#O.. | ||
..#O.O...#..O..OO.#..OO...##...#..O#O....O...O.....#O#..#.O.......O........#OO..O....#.#O.........#O | ||
.#.....O.##...#....O..O..#.O.#.#OO...#........#..O.#.#....#.O..O.#O.#..#.......#..............##.O.# | ||
...O..#...#.O....O.O#.#...#.#...........O.O..#.#..O.......#O.OOO.#.....#.O.#...#O....#O.O.......##.. | ||
.#....OOOO..O.....O.OO#O..#...#.....O....O...#..##.O..O.#..O..#.O#..O.O...O#.....OO........O..OO#..O | ||
O.#.O.#...#O...#O.#......#O...O.#.O.O#O#..#.........##.O.OO..#....OOO##...O##.##.#.O...#.O.#O#...... | ||
O..##..O...O#OO#O..O..O...###..OOO...#O#......##..O.........O#.....O..#...#O......#.#..O....O......O | ||
........#O#..##O....OO..#..#.#...#.#.#...OO...O###.#O.#OO.#..#.O.......O..O..O..OO...O....O..#...#.. | ||
.....O...O....#.#.O#...O..O.#.#O.OO#OO.O.#.....#.#..#..O.#O....##......O##O##.O#..O.###....O#O.O.#.. | ||
..##....#.O.#.#O#.O..O....OO#O..O....#....#.O.O.#...#OO....#O.#..#O.......O.O.O.#.....#O..O.O......# | ||
.O..#..........#..O.#..#.#..O..O.O#..#..O..#.....O#..#..#OO...O#.O..OOO.....O..O..OOO..#..O..#....O. | ||
.....O..#.#..#......OO...#..O.#..##....#O..O.O.O..O.#..OOO..O.OO......###..#..O#.OO####..#..OO.#.... | ||
#.#...O.....O....#O..#..##.O.#...O.#.##.OO...#..#O.O...#.....#...O.O.O...O.#.#..#..O.....O..OO.O..OO | ||
..#O..O.O...O##O.O..#..O.##O##..O.OOO#O...O....#.O#............OO.#.O..#...........O......O.#..##... | ||
.....O.O...#O.O...O#....#..#...O.#..OOO.O.OO.O##..#...#..O#O#..O..##...#....OO........#..O.O.#...#O# | ||
O#..O....O.#...#...#...O#.#..OO#.#..O...O.OO....O...#.#O.###.#...##..OO..##....O.OO...OOO.O.#....... | ||
O.O.#.........#####..O..#.OO..O.OOO...#O#..O.............OOO...O.....#..OO...O......#O....OO...OO.O. | ||
#.O#...O##.O.#.........#.#.#..O......#.#....O...OOO.O...#....#.O#....O.....O.....#.O..#..#.#O....... | ||
#..O......#.......O#O.OO#......#...#.....O#..O.O.#.....O..#.#.....##...#...O...#.#.O..O.O.....O...#. | ||
.OOO.O...#O.#..O#O...#..#O#..#.......###...#.#......#O###.....#...#....###O#.O....##O...#.#...O..#.. | ||
.O...OO.......O.O#O#.O.#O.O...O....OO#.....#..#.....O....OO.#......O#OO...O##.#..#.#..O..O...#...#.. | ||
...O....O..O#O....#.........###..O.....O...O#....O#.....#.#.....#.O.#.OO..#.O###.....#O#...#.OO#.... | ||
#.#.....O#O....O......O#..##OO......O#..#O.O#..#...O.O##OO#.......O...#...OO.....#.O.....O#O#.....#. | ||
..OO##.#..OO#O.......O.O..OO#..O....O#.O.O.#.#..#........O.....#...........#O.......O.#.#.......#.O. | ||
.##O.....O....#...O..O.OOO.O.OO..#.#..O.........#...##..#..O#....#..O..#O....O......#O..O#..#O..#O.. | ||
#O.......O#......O.......O.O.#.......OO....#.....#O.#......O#OO...O.....O......O...#..O........#.OO. | ||
O....#...OO.O..O......#O.O...#.OOO.OO....#....O.O#..O#..#...O.O...O..#O....#O...O..OO........#O.O.#O | ||
#O#..O.........#......#OO..O#.OO#O##..#.O...O#.....#..#O#..OO.#.O#....O.O..##O#O..#O......#.O.OO.O.O | ||
...##.....#..........#..O.O#....#..O...O......##.O.....#.OO#..OO...O..#..#O#..#.O.#..O#O..#......#.. | ||
#OO.O##..##O...#..O.O#OO#OO....##.#...O.#.#.#.#O#....O.......O.....#..#.O.#.#...........#........O.. | ||
#....O..#O#O............O#O..O.......O#.O.O##..###.#.O#O.#O....O............O..O....#.....O.OOOO.... | ||
.OO.OO..#O....#O....O.O..OOO..#..O..OO.....O...#.O.#.O.O.............O..#.O....O##..OO#.O.O.#O..O.#O | ||
.....O......O...#.#....#.....OO...O....#O...#.#.O..##......O...O#.....O.O...#....................... | ||
O..........#O...O#.OO..O.O.#.......#...............#....O...#.O.O..#..O....O....#...#O#.O....O.#.... | ||
#..O....O...O#..#OO.O....OO.#..O.O.O.O......O.O.....O....#..O#..O.OO....#..#.#...#......#...O#..O.OO | ||
.......#..O....O.O........#O#OO.#O.O.OO....#..O.....O.#....O...#O.#.O.O.O....##..OO.#O..O#.......#.O | ||
....O....O.O.##O..O..OO####O....O..O.........O.#...OO...#..#..#...#......#......O..#...O.....##...O. | ||
.#OO#..O..O...O.OO....O.O....OO#..#O.O....O..OOO..##..................O....#....O..O...O......#.OO.O | ||
.#.........O#.O#...#...O##.....O.OO.O.##O...O.#.##...OO.....##....#..O.OO#..O....#.#...O...O..OO.... | ||
.#.O...OO.OO.O.O#...#.#O.........#O..OO#O#.#.......#..O##....O#..#...#O......O.......O.....#..O..#.. | ||
.##..OO....O.....#O.....O..#..#O#..#......#..O.........O.........O#O..........#OOOO.......#.###.#.#O | ||
.O..O..O...OO...OO......O.O..O.#O...#O#.O#..O#......#.O#O.......#..O##.O.O....OO#.O......##OO#.#...O | ||
..#.O..#......#..#O.OO..O...#....O.##......#....O.O.O.....O.#...##....##....OO.O#.....O....O..#....# | ||
O..#.OOO......O.O.OO...O......O.#.#OO.#.....##....#.##..O.....#.....O....#...OO....O#.#.#.........#. | ||
.O......#O.......O..#.##...#.#.O....O.##..O#.OO.O.O#.#O#..##..O..##.O#O.O...#.OO.#.O..#.O.#.O.#.#O.O | ||
.O..O.O..O.O...............OO...O.O.#..#...#.....#..O#.O.OO#.O......##O...O.....O.O.#.#..O..O.O.O.#. | ||
O.........#...O#.O....O...O......#O..##..#O.O.#O..O..OO...#..#.#.#O.........O..OO..O.O.O#.O......#.. | ||
OO...........#.....O.O.#.#...O..#.#.#O.#.O#...#O.....O.OO.O..##.....##OO.........O...#OO#O...O....O. | ||
.#.......O.#OO.#OO.O#.OOO...#..##.OO..O...OO.......O.#..OO.O.O..#...O...O.....O.##OOO#..O.....O.O.#O | ||
O#.O.O.OO...#..O.....O#......#..O#OOO.OO#..O...O...O.#..O..#.O..#O.OO##...##.#.#O.#O.O.....##O..O#.# | ||
O.#.#........#...O...#...O.O.O.#.O.....O.......#....#O..OO.#.......#.O...#.O.#..#...#O.###...#.....O | ||
........OOO...O.OO.##O.O..#.O...O..#.......#OO#OO..O##O.......##.........O...OO.......#...#..O#O.#O# | ||
..O#OOO.O#..##........O.......O.....#.O....OOO..O......#.......OO.......#..#.#.#.#....O#...#.O.....# | ||
....O....#..#..O.O.O.O..O........O#....#..#.O..#OO.....OOOO....O#.O......#O..OOO#.O..#....#...O...OO | ||
O#...O#......O...#..#......#.........O.#........#.O#.#...###.#O.O....#O.....#...#.##....O..##...OO.. | ||
....O....O........##.O.....#....O.....#..#........#OO.O.#OOO....#..#.#...###......O.O..#....OO...... | ||
.O#O....#OO#OOO.#.....O.O......##....#..OO.OOO.O##..#O.#.#...#.#....O..O#...O..OO.#.O...O..##...#... | ||
.O#OO#..O.#OO.......##O#O.#.O..#.O#OO.OO.O.#.O#........#...O.#.O.O##O.........OO..O...O.O.O.....O#.. | ||
..##....###.O#.....O....OOO.O.....OO...O....OOOO.#........#.....#.#..O.#.....#...OOO.....OOO..#.O..# | ||
.OO##.#.#....O..#..#.#..O.#..O.OO....O.O..O.OO.O.O.....#..#.............OOOO.O....O.O.O.#..#.......O | ||
#.O.#.O#O.O.O.O.#.#......O#O..OO..O.....#....O..#..#O.............#....#OO....O##...#..O....O...#..O | ||
....#...##...#...#....#.O.O#....#O.O.##.#.O...O#...O#....#.......O.#.#.....O....#.#O.O..O...O..O..#. | ||
.O.##.#...O#OO.....O.........#O.O.O#..........OO.O...#..#.OO....O..#..#...O...OO......O##O.....O#O.. | ||
O#...........O....#O...O...O#..#.....#OO...OO..OO#OO..O.#.O#.OOO...O.....O..O...O...O.#O#.#O.....O.. | ||
O.OO.O.OOO.O##.#..OO....#....#O.#...O...OO..OO..O#O.....#...O...O...........O....#.O....O.O..#O#..## | ||
#..#......O..OO#.......O..#......#O##....O...O.#.O#.#.O..#.#O..O..O#..O.O.#.OOO...OOO.#.#O.#....#.#. | ||
O##..O......#OOO.#..O.O#.#...O...#...O...#O..OO..#.##O.......#O.#..#...#.O.....#.O.O.#..#.O.O..O...# | ||
.#OOO.....O...#.......OOO.O.#.O.O#.#..#O.#....#O.#....#......#.O...OO..O..O..#O.##.OOO........O.O#.. | ||
...O.OO.O....#O...#...#OOO..O...#....OO....O...#..#O...#.#OO......O......O#.O#....#..#OOO.#....O.#.. | ||
..#.OOO....#.O..#.O#.#O...O.O.......#..OO.##.#.#..O..O....O#.#.....#..##.#O.......O#O##OO.O......OOO | ||
..O.#...##O##O.O#...O.O#.#O.#...O........#.OO.O...##...O..O..##..O...O.#.....O...#O.#O#O.O......O.#O | ||
..O.#..O.#.....O...#OO##..O.OOO...O.##O..O.O.......#.....O..O.##......O.....O#.........#.........O.# |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import input from "./input.txt"; | ||
import { transpose } from "@utils"; | ||
|
||
const lines = input.trim().split("\n"); | ||
const grid = lines.map((l) => [...l]); | ||
const transp = transpose(grid); | ||
|
||
let r = 0; | ||
for (let i = 1; i < grid.length; i++) { | ||
for (let j = 0; j < grid[0].length; j++) { | ||
if (grid[i][j] === "O") { | ||
for (let k = 0; k < i; k++) { | ||
if (grid[k][j] === ".") { | ||
const t = transp[j].slice(k, i); | ||
if (!t.includes("#")) { | ||
grid[i][j] = "."; | ||
grid[k][j] = "O"; | ||
|
||
transp[j][i] = "."; | ||
transp[j][k] = "O"; | ||
|
||
break; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
for (let i = 0; i < grid.length; i++) { | ||
for (let j = 0; j < grid[0].length; j++) { | ||
if (grid[i][j] === "O") { | ||
r += grid.length - i; | ||
console.log(r); | ||
} | ||
} | ||
} | ||
console.log(grid.map((l) => l.join("")).join("\n")); | ||
console.log(r); | ||
console.log("------"); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import input from "./input.txt"; | ||
import { transpose } from "@utils"; | ||
|
||
const lines = input.trim().split("\n"); | ||
let grid = lines.map((l) => [...l]); | ||
|
||
const getRocks = (part: string): string => { | ||
const amt = [...part].filter((n) => n === "O").length; | ||
const newStr = "O".repeat(amt); | ||
|
||
return newStr + ".".repeat(part.length - newStr.length); | ||
}; | ||
|
||
const roll = (arr: string[]): string[] => { | ||
const parts = arr.join("").split("#"); | ||
|
||
const newParts = []; | ||
for (const part of parts) { | ||
const newStr = getRocks(part); | ||
newParts.push(newStr); | ||
} | ||
|
||
return [...newParts.join("#")]; | ||
}; | ||
|
||
const revRoll = (arr: string[]): string[] => roll(arr.reverse()).reverse(); | ||
|
||
const cycle = (grid: string[][]): string[][] => { | ||
let transp = transpose(grid); | ||
for (let i = 0; i < transp.length; i++) { | ||
transp[i] = roll(transp[i]); | ||
grid = transpose(transp); | ||
} | ||
|
||
for (let i = 0; i < grid.length; i++) { | ||
grid[i] = roll(grid[i]); | ||
transp = transpose(grid); | ||
} | ||
|
||
for (let i = 0; i < transp.length; i++) { | ||
transp[i] = revRoll(transp[i]); | ||
grid = transpose(transp); | ||
} | ||
|
||
for (let i = 0; i < grid.length; i++) { | ||
grid[i] = revRoll(grid[i]); | ||
} | ||
return grid; | ||
}; | ||
|
||
const getSum = (grid: string[][]): number => { | ||
let r = 0; | ||
for (let i = 0; i < grid.length; i++) { | ||
for (let j = 0; j < grid[0].length; j++) { | ||
if (grid[i][j] === "O") { | ||
r += grid.length - i; | ||
} | ||
} | ||
} | ||
return r; | ||
}; | ||
|
||
const prettyHash = (grid: string[][]): string => | ||
grid.map((l) => l.join("")).join("\n"); | ||
|
||
let n = 0; | ||
const MAX = 1e9; | ||
const hashes: string[] = []; | ||
let idx = -1; | ||
while (idx === -1 && n < MAX) { | ||
hashes.push(prettyHash(grid)); | ||
n++; | ||
|
||
grid = cycle(grid); | ||
idx = hashes.indexOf(prettyHash(grid)); | ||
} | ||
|
||
const jmp = n - idx; | ||
|
||
let rem = (MAX - idx) % jmp; | ||
console.log(`got cycle from ${idx} to ${n}, ${rem} remaining`); | ||
for (let i = 0; i < rem; i++) { | ||
grid = cycle(grid); | ||
} | ||
//console.log(prettyHash(grid)); | ||
console.log(getSum(grid)); | ||
console.log("------"); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2023-12-14T23:38:57+08:00 |