Add day 1 and 2 solutions in J.

This commit is contained in:
Danila Fedorin 2020-12-23 21:47:05 -08:00
parent ee819d1362
commit 4e8b636d2f
2 changed files with 9 additions and 0 deletions

3
day1.ijs Normal file
View File

@ -0,0 +1,3 @@
c =. > 0 ". each cutopen 1!:1 < jpath '~/projects/AoC/2020/year2020day1.txt.cache'
>./,(c*/c)*2020=c+/c
>./,(c*/c*/c)*2020=c+/c+/c

6
day2.ijs Normal file
View File

@ -0,0 +1,6 @@
r =: >"1 cut each cutopen 1!:1 < jpath '~/projects/AoC/2020/year2020day2.txt.cache'
rs =: >0".each'-'cut"1>(0}"1 r)
cs =: 0{"1>1{"1 r
ss =: 2{"1 r
+/1>**/|:rs-+/"1 cs=>ss
+/1=+/|:(rs-1){"1 cs=>ss