From 7b7bf727da3250907284368b98b0083a4b4e2386 Mon Sep 17 00:00:00 2001 From: mryouse Date: Sat, 3 Jun 2023 20:22:18 +0000 Subject: initial commit --- aoc/2021/day01/part2.neb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 aoc/2021/day01/part2.neb (limited to 'aoc/2021/day01/part2.neb') diff --git a/aoc/2021/day01/part2.neb b/aoc/2021/day01/part2.neb new file mode 100644 index 0000000..31e3c99 --- /dev/null +++ b/aoc/2021/day01/part2.neb @@ -0,0 +1,19 @@ +; return 1 if next three greater than first three +(func is-increasing (inp) + (if (< (apply + (most inp)) (apply + (rest inp))) + 1 + 0)) + +; this works, but i don't like redefining variables +(func iter-list (inp) + (def acc 0) + (for-count (- (length inp) 3) + (redef acc (+ acc (is-increasing (slice inp _idx_ 4))))) + acc) + +(def lines + (map string->int + (map strip + (read-lines "input.txt")))) + +(print (->string (iter-list lines))) -- cgit v1.2.3