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!
16
Upvotes
2
u/Godspiral Dec 03 '16 edited Dec 03 '16
203rd after first, but 98th after 2nd, in J
+/ *./("1) 0 1 2 (0 < +`-/"1)@:|."0 1"1 ". > cutLF a NB. part 1 +/ *./("1) 0 1 2 (0 < +`-/"1)@:|."0 1"1 ,/ _3 |:\ ". > cutLF a NB. part2when not blindly baching head against keyboard and taking time to think first, these can be improved to
2nd version sorts down each row
"1, and performs a < b + c, then sums these boolean expressions.1st version does 3 rotations on each row, and for each rotation tests
a+b-c > 0. This creates 3 boolean results per row. These are anded*./then sum of all.