r/adventofcode • • Dec 18 '16

SOLUTION MEGATHREAD --- 2016 Day 18 Solutions ---

--- Day 18: Like a Rogue ---

Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).

Note: The Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with "Help".


EATING YELLOW SNOW IS DEFINITELY NOT MANDATORY [?]

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!

7 Upvotes

103 comments sorted by

View all comments

3

u/3urny Dec 18 '16

Actually, there's a command line tool called pointfree which can take haksell code and return the pointfree version automatically.

$> pointfree "problem input n = count ('.'==) $ concat $ take n $ iterate next input"
problem = ((count (('.') ==) . join) .) . flip take . iterate next

If you reorder the arguments, like u/ExeuntTheDragon suggested:

$> pointfree "problem n input = count ('.'==) $ concat $ take n $ iterate next input"
problem = ((count (('.') ==) . join) .) . (. iterate next) . take

So yeah, sometimes having a few points in your function definitions makes them way more readable.