r/adventofcode • • Dec 17 '19

SOLUTION MEGATHREAD -🎄- 2019 Day 17 Solutions -🎄-

--- Day 17: Set and Forget ---


Post your full code solution using /u/topaz2078's paste or other external repo.

  • Please do NOT post your full code (unless it is very short)
  • If you do, use old.reddit's four-spaces formatting, NOT new.reddit's triple backticks formatting.

(Full posting rules are HERE if you need a refresher).


Reminder: Top-level posts in Solution Megathreads are for solutions only. If you have questions, please post your own thread and make sure to flair it with Help.


Advent of Code's Poems for Programmers

Click here for full rules

Note: If you submit a poem, please add [POEM] somewhere nearby to make it easier for us moderators to ensure that we include your poem for voting consideration.

Day 16's winner #1: "O FFT" by /u/ExtremeBreakfast5!

long poem, see it here

Enjoy your Reddit Silver, and good luck with the rest of the Advent of Code!


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 at 00:45:13!

23 Upvotes

201 comments sorted by

View all comments

Show parent comment

1

u/jeroenheijmans Dec 19 '19

Suppose you have R4,R2,L10,R4,R2,L10,R4,R2 in your file. Now select (shift+arrows) R4,R2 and hit CTRL+D twice. You now have all three occurrences selected.

Hit CTRL+X to cut all three sections. Hit enter to insert a newline at their locations. Then finally hit CTRL+V to insert them at three locations but this time at their own lines.

That's the basis for how I got three "functions" out of the total thing, and placed each instance of a function on its own line.

I'm not sure what you mean by "rotated" regions, I created the initial string by just manually listing all instructions, that are not "rotated", they already accounted for the direction you were going in when noting a corner turn.

On a (to me unrelated) side note, VSCode does support vertical selections across multiple lines. Use CTRL+ALT+ARROWS (up/down) to put a cursor on multiple lines, then use e.g. SHIFT to select (arrow keys but also end/home or ctrl+arrows works), and type over those sections. Real productivity boost!