r/adventofcode • u/taliriktug • Dec 02 '15
Spoilers Day 2 solutions
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
15
Upvotes
r/adventofcode • u/taliriktug • Dec 02 '15
Hi! I would like to structure posts like the first one in r/programming, please post solutions in comments.
View all comments
Show parent comment
1
u/FuriousProgrammer Dec 02 '15 edited Dec 02 '15
since you don't need to know which two give you the minimum perimeter or surface area, only the actual minimum, you can simply use
math.min()with the three possible minimums.Also, your main loop can be significantly shorter of you use string pattern captures instead of gmatch: