Compare commits
No commits in common. "7bcab0b085b705d9d77180f5fda28feeb1e858f9" and "66f04ed8897a5e8df11611504cf2a2fe2aa62bc8" have entirely different histories.
7bcab0b085
...
66f04ed889
BIN
progress.png
BIN
progress.png
Binary file not shown.
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 110 KiB |
@ -3,6 +3,4 @@
|
|||||||
2:
|
2:
|
||||||
stars: 2
|
stars: 2
|
||||||
3:
|
3:
|
||||||
stars: 2
|
|
||||||
4:
|
|
||||||
stars: 2
|
stars: 2
|
@ -1,10 +0,0 @@
|
|||||||
MMMSXXMASM
|
|
||||||
MSAMXMSMSA
|
|
||||||
AMXSXMAAMM
|
|
||||||
MSAMASMSMX
|
|
||||||
XMASAMXAMM
|
|
||||||
XXAMMXXAMA
|
|
||||||
SMSMSASXSS
|
|
||||||
SAXAMASAAA
|
|
||||||
MAMMMXMMMM
|
|
||||||
MXMXAXMASX
|
|
@ -1,57 +0,0 @@
|
|||||||
#import "/src/utils.typ": *
|
|
||||||
|
|
||||||
#let check-xmas(lines, ox, oy) = {
|
|
||||||
let w = lines.first().len()
|
|
||||||
let h = lines.len()
|
|
||||||
|
|
||||||
let total = 0
|
|
||||||
for dy in (-1, 0, 1) {
|
|
||||||
for dx in (-1, 0, 1) {
|
|
||||||
if dx == 0 and dy == 0 {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
let buffer = ""
|
|
||||||
let x = ox
|
|
||||||
let y = oy
|
|
||||||
for i in range(4) {
|
|
||||||
buffer += lines.at(y).at(x)
|
|
||||||
x += dx
|
|
||||||
y += dy
|
|
||||||
if (
|
|
||||||
not "XMAS".starts-with(buffer) or
|
|
||||||
x < 0 or x >= w or
|
|
||||||
y < 0 or y >= h
|
|
||||||
) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if buffer == "XMAS" {
|
|
||||||
total += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return total
|
|
||||||
}
|
|
||||||
|
|
||||||
#let solve(input) = {
|
|
||||||
let lines = input.split("\n")
|
|
||||||
let w = lines.first().len()
|
|
||||||
let h = lines.len()
|
|
||||||
|
|
||||||
let total = 0
|
|
||||||
for y in range(h) {
|
|
||||||
for x in range(w) {
|
|
||||||
if lines.at(y).at(x) == "X" {
|
|
||||||
total += check-xmas(lines, x, y)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return total
|
|
||||||
}
|
|
||||||
|
|
||||||
#show-puzzle(
|
|
||||||
4, 1,
|
|
||||||
solve,
|
|
||||||
example: 18
|
|
||||||
)
|
|
@ -1,33 +0,0 @@
|
|||||||
#import "/src/utils.typ": *
|
|
||||||
|
|
||||||
#let solve(input) = {
|
|
||||||
let lines = input.split("\n")
|
|
||||||
let w = lines.first().len()
|
|
||||||
let h = lines.len()
|
|
||||||
|
|
||||||
let perms = (("M", "S"), ("S", "M"))
|
|
||||||
let total = 0
|
|
||||||
for y in range(1, h - 1) {
|
|
||||||
for x in range(1, w - 1) {
|
|
||||||
if lines.at(y).at(x) == "A" {
|
|
||||||
let tl = lines.at(y - 1).at(x - 1)
|
|
||||||
let tr = lines.at(y - 1).at(x + 1)
|
|
||||||
let bl = lines.at(y + 1).at(x - 1)
|
|
||||||
let br = lines.at(y + 1).at(x + 1)
|
|
||||||
let tlbr = (tl, br)
|
|
||||||
let bltr = (bl, tr)
|
|
||||||
if tlbr in perms and bltr in perms {
|
|
||||||
total += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return total
|
|
||||||
}
|
|
||||||
|
|
||||||
#show-puzzle(
|
|
||||||
4, 2,
|
|
||||||
solve,
|
|
||||||
example: 9
|
|
||||||
)
|
|
BIN
src/main.pdf
BIN
src/main.pdf
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user