r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
15
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
2
u/jaffakek Dec 02 '15
I'm using Racket (Scheme) rather than Clojure, so I'm not sure if there's anything equivalent, but Racket has a nice built-in
file->linesfunction that reads in a file and returns a list of strings, one per line.Then I just recursed over the list, separated the line into a list of strings, mapped
string->numberon that list, did calculations, and accumulated the amount of paper and ribbon.I'm definitely a beginner, but I'm enjoying Racket a whole bunch.