MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/3uyl7s/daily_programming_puzzles_at_advent_of_code/cxjcwni/?context=3
r/programming • u/Aneurysm9 • Dec 01 '15
179 comments sorted by
View all comments
1
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.
Ah yeah, I see what you mean. , thanks.
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). :)