r/adventofcode • • Dec 07 '15

SOLUTION MEGATHREAD --- Day 7 Solutions ---

--- Day 7: Some Assembly Required ---

Post your solution as a comment. Structure your post like previous daily solution threads.

Also check out the sidebar - we added a nifty calendar to wrangle all the daily solution threads in one spot!

23 Upvotes

226 comments sorted by

View all comments

Show parent comment

3

u/_jonah Dec 07 '15

Very nice. Just learned a couple new tricks from this. Thanks.

4

u/0x0dea Dec 07 '15

My pleasure. I count seven things that might be considered "tricks" by an intermediate Ruby programmer. For the sake of my curiosity, would you mind sharing?

6

u/_jonah Dec 07 '15
  1. Using a hash as 2nd arg to gsub
  2. Regexp.union method -- not really a trick but something I never think of
  3. ?; for golfed single char string

2

u/5ef23132-c4a0-49a0-8 Dec 07 '15

nice solution, I didn't event think about the replace/eval trick.

This solution doesn't work for all inputs right, wouldn't c -> b throw a NameError?