i:(1:"i/12.in"),"\n"
n:(!#i)+/:d:(-1;-w;1;w:1+_%#i)  / neighbours
m:i=/:i@n                       / mask out different groups
g:{x|/m*x@n}/!#i                / groups
r:g=/:("\n"=i@)_?g              / regions
A:+/'r                          / areas
+/A*{+//x&/:1>x n}'r            / part 1: areas * perimeters
s:(0;1;w;w+1)+\:(-w+1)+!w*w     / all squares
c:c,|c:0 1 1 0 1 0 2 1          / binary square -> # of corners
+/A*{+/c@2/0^x s}'r             / part 2: areas * corners

I am sensing a pattern: annoying days (12, 9, 6) after 2 easy ones.

For some reason, I found this to be the hardest day in all of AoC. I initially finished it at 10:00 pm with horrible code that would make ngn cry. Later, after AoC, I revisited it and wrote this.

Shadow and rak bothave clean solutions, stop reading my atrocious code and look there instead!


~/aoc24k/12.html