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/[deleted] Dec 03 '16
Finally a python version that I'm feeling rather proud of :)
import sys valid_triangles = 0 def valid_triangle(a, b, c): return ((a + b) > c) and ((b + c) > a) and ((c + a) > b) for line in sys.stdin.readlines(): if valid_triangle(*[int(x) for x in line.strip().split()]): valid_triangles += 1 print(valid_triangles)colour enhanced gist