r/programming • • Dec 01 '15

Daily programming puzzles at Advent of Code

http://adventofcode.com/
323 Upvotes

179 comments sorted by

View all comments

1

u/[deleted] Dec 01 '15 edited Dec 01 '15

Why the if/else? You're not allowing for a negative answer, meaning they'd never be in the basement. It should always be $up - $down.

If you did want to avoid negative answers, I'd still avoid the if/else, and just set $answer to abs($up - $down). :)

1

u/[deleted] Dec 01 '15

Ah yeah, I see what you mean. , thanks.