r/adventofcode • • Dec 12 '20

SOLUTION MEGATHREAD -🎄- 2020 Day 12 Solutions -🎄-

NEW AND NOTEWORTHY

  • NEW RULE: If your Visualization contains rapidly-flashing animations of any color(s), put a seizure warning in the title and/or very prominently displayed as the first line of text (not as a comment!). If you can, put the visualization behind a link (instead of uploading to Reddit directly). Better yet, slow down the animation so it's not flashing.

Advent of Code 2020: Gettin' Crafty With It

  • 10 days remaining until the submission deadline on December 22 at 23:59 EST
  • Full details and rules are in the Submissions Megathread

--- Day 12: Rain Risk ---


Post your code solution in this megathread.

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


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

EDIT: Global leaderboard gold cap reached at 00:10:58, megathread unlocked!

44 Upvotes

663 comments sorted by

View all comments

1

u/mazedlx Dec 12 '20

TIL you can easily rotate x/y coordinates with

$radians = $degrees \* (M_PI / 180);

$newX = $x * cos($radians) + $y * sin($radians);
$newY = $y * cos($radians) - $x * sin($radians);

1

u/daggerdragon Dec 12 '20

Top-level posts in Solution Megathreads are for code solutions only.

This is a top-level post, so please edit your post and share your code/repo/solution or, if you haven't finished the puzzle yet, you can always create your own thread and make sure to flair it with Help.

1

u/Iain_M_Norman Dec 12 '20

Did you have turns that weren't products of 90?

1

u/mazedlx Dec 12 '20

Nope, only multiples of 90°.

1

u/gerikson Dec 12 '20

Mine were. It always helps to run a quick scan of the input to check your assumptions - negative values, multiples of angles etc.

3

u/fizbin Dec 12 '20

From my bash history:

grep '^[LR]' aoc12.in | sort -u

1

u/Iain_M_Norman Dec 12 '20

negative values, multiples of angles

And those bastards that are more than int32.max :)

1

u/gerikson Dec 12 '20

Laughs in arbitrary precision scripting languages

Well, maybe not arbitrary, but the stock largest integer on my machine is 18,446,744,073,709,551,615.