about summary refs log tree commit diff
path: root/day05.k
blob: fc4e5e264fe313069171b1724869437dcedfeb51 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
d:.:'0:`day05
w:v:0
/ {(#d)>*|x}{v+:1;(@[*x;*|x;1+];((*x)@*|x)+*|x)}/(d;0);
/ {(#d)>*x}{v+:1;(((*|x)@*x)+*x;@[*|x;*x;1+])}/(0;d);
{(#d)>*x}{v+:1;(*x+(*|x)@*x;@[*|x;*x;1+])}/(0;d);
v    / 358309

d:.:'0:`day05;-1+#{x<#d}{x-1-d[x]+:1}\0     / thanks @vectorprocessing

/ {(#d)>*|x}{w+:1;(@[*x;*|x;$[((*x)[*|x])>2;-1+;1+]];((*x)@*|x)+*|x)}/(d;0);

d:.:'0:`day05
v:0
{(#d)>*x}{v+:1;(*x+(*|x)@*x;@[*|x;*x;{$[x>2;x-1;x+1]}])}/(0;d);
v    / 28178177

d:.:'0:`day05;-1+#{x<#d}{d[x]+:1 -1@2<r:d@x;x+r}\0   / thx @vectorprocessing, inr

\\

/ rlwrap k day05.k  149.90s user 0.01s system 99% cpu 7M memory 2:30.51 total