Initial commit
This commit is contained in:
commit
f242d2b0df
420 changed files with 62521 additions and 0 deletions
7
2018/day01/day01.dyalog
Normal file
7
2018/day01/day01.dyalog
Normal file
|
@ -0,0 +1,7 @@
|
|||
⎕IO←0
|
||||
x←,⍎¨⎕csv'input.txt'
|
||||
+/x
|
||||
|
||||
y←+\(200×⍴x)⍴x
|
||||
pos←{⍸⍵=y}¨y
|
||||
y[1⌷{⍵[⍋⍵]}{1⌷⍵}¨(⊃¨1<⍴¨pos)/pos]
|
23
2018/day01/day01.ss
Normal file
23
2018/day01/day01.ss
Normal file
|
@ -0,0 +1,23 @@
|
|||
(import :gerbil/gambit/ports)
|
||||
|
||||
(export main)
|
||||
|
||||
(def freqs (with-input-from-file "input.txt" read-all))
|
||||
|
||||
(def (repeat n l)
|
||||
(match n
|
||||
(0 [])
|
||||
(else (append l (repeat (1- n) l)))))
|
||||
|
||||
(def (main . args)
|
||||
(displayln (apply + freqs))
|
||||
|
||||
(let/cc exit
|
||||
(foldl
|
||||
(lambda (x acc)
|
||||
(let ((new-x (+ x (car acc))))
|
||||
(if (memq new-x acc)
|
||||
(begin (displayln new-x) (exit))
|
||||
(cons new-x acc))))
|
||||
[0]
|
||||
(repeat 200 freqs))))
|
1029
2018/day01/input.txt
Normal file
1029
2018/day01/input.txt
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue