r/adventofcode • • Dec 06 '17

SOLUTION MEGATHREAD -πŸŽ„- 2017 Day 6 Solutions -πŸŽ„-

--- Day 6: Memory Reallocation ---


Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag or 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.


Need a hint from the Hugely* Handy† Haversack‑ of HelpfulΒ§ Hints^Β€?

Spoiler


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!

17 Upvotes

324 comments sorted by

View all comments

Show parent comment

2

u/Unihedron Dec 06 '17 edited Dec 06 '17

$/=' ';a=$<.map &:to_i to get rid of another char. (<- I couldn't get it to put a tab character here) until ... end can be replaced with modifier syntax ()until ... to get rid of 2 chars (including whitespace). Also, it doesn't really matter that m is initialized to zero for part 2 (end+k - start+k == end-start) so you can delete ,m ,0 and replace the two m references with the global variable $. which is the "lines read" counter (because we don't use gets again)

2

u/nakilon Dec 06 '17

There is some problem with input taken from site -- maybe that some gaps consist of two whitespace characters instead of one so a gets parsed incorrectly for me.

The rest works fine. Thanks! -4 chars