Day 9: 325
This commit is contained in:
parent
0ae63bb4e9
commit
461f2b5e15
4 changed files with 2028 additions and 0 deletions
12
day9.hs
Normal file
12
day9.hs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
import Data.List
|
||||||
|
s=scanl
|
||||||
|
v=[-1..1]
|
||||||
|
r=replicate
|
||||||
|
h%t=t+signum(h-t)
|
||||||
|
p(d:_:i)=r(read i)d
|
||||||
|
(h:l)&d=s(?)(zipWith(+)(z[d])h)l
|
||||||
|
[x,y]!t=elem t[[x+n,y+m]|n<-v,m<-v]
|
||||||
|
h@[x,y]?t@[a,b]|h!t=t|let=[x%a,y%b]
|
||||||
|
w i=length.nub.map last.(s(&)$r i[0,0])
|
||||||
|
z"U"=[1,0];z"D"=[-1,0];z"L"=[0,-1];z"R"=[0,1]
|
||||||
|
main=interact$show.((,).w 10<*>w 2).(p=<<).lines
|
8
day9short
Normal file
8
day9short
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R 4
|
||||||
|
U 4
|
||||||
|
L 3
|
||||||
|
D 1
|
||||||
|
R 4
|
||||||
|
D 1
|
||||||
|
L 5
|
||||||
|
R 2
|
8
day9short2
Normal file
8
day9short2
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
R 5
|
||||||
|
U 8
|
||||||
|
L 8
|
||||||
|
D 3
|
||||||
|
R 17
|
||||||
|
D 10
|
||||||
|
L 25
|
||||||
|
U 20
|
Loading…
Add table
Reference in a new issue