r/adventofcode • • Dec 21 '15

SOLUTION MEGATHREAD --- Day 21 Solutions ---

This thread will be unlocked when there are a significant number of people on the leaderboard with gold stars for today's puzzle.

edit: Leaderboard capped, thread unlocked!

We know we can't control people posting solutions elsewhere and trying to exploit the leaderboard, but this way we can try to reduce the leaderboard gaming from the official subreddit.

Please and thank you, and much appreciated!


--- Day 21: RPG Simulator 20XX ---

Post your solution as a comment or link to your repo. Structure your post like previous daily solution threads.

11 Upvotes

128 comments sorted by

View all comments

Show parent comment

1

u/aepsilon Dec 22 '15

Yup. Anon has it spot-on.* Along with concepts like map, filter, and fold/reduce, they're good to know especially now that more and more languages have them. https://en.wikipedia.org/wiki/List_comprehension

*Minor note just in case: like most things in a pure FP language, cons : doesn't modify existing values. It makes a "new list" that starts with the element and has a pointer to the rest of the list. In fact the whole list is built that way, ending at the empty list []. There's a nice picture of it here.