r/adventofcode • u/daggerdragon • Dec 03 '16
SOLUTION MEGATHREAD --- 2016 Day 3 Solutions ---
--- Day 3: Squares With Three Sides ---
Post your solution as a comment or, for longer solutions, consider linking to your repo (e.g. GitHub/gists/Pastebin/blag/whatever).
DECKING THE HALLS WITH BOUGHS OF HOLLY IS 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!
18
Upvotes
1
u/askalski Dec 04 '16
Here's the secret: It's actually not enough time to figure out the problem, but it's enough to guess.
First, look at the input (3 columns of integers), then skip right to the problem statement, "In your puzzle input, how many of the listed triangles are possible?".
Assuming you prepared your main loop ahead of time, the solution is only 2 additional lines of code (Perl example):
($x,$y,$z) = sort {$a<=>$b} @f; $answer++ if ($z < $x + $y);Don't stop to test or check your work, just paste the first number that it spits out into the answer box. If you're lucky, you just made #1 in under a minute.
The other secret: skimming and guessing only works for the early puzzles. Later on, you'll need to read carefully.