r/adventofcode • • 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.

14 Upvotes

161 comments sorted by

View all comments

Show parent comment

1

u/taliriktug Dec 29 '15

I'm not a Python expert, but I have a few tips.

  • readFile name is misleading - this function does many things
  • You don't need 'r' in open() - it is default.
  • You can omit parentheses in some cases:

      surface_area = 2 * sides[0] + 2 * sides[1] + 2 * sides[2]
      return surface_area + smallest_side, get_ribbons(l,w,h)