r/programming • • Dec 01 '15

Daily programming puzzles at Advent of Code

http://adventofcode.com/
320 Upvotes

179 comments sorted by

View all comments

Show parent comment

3

u/OffPiste18 Dec 01 '15

I did it largely the same way, except I think

.takeWhile(_ != -1).length

can be improved to

.indexWhere(_ < 0)

or even

.indexOf(-1)

2

u/xkufix Dec 02 '15

Ah, I didn't know about indexWhere/indexOf. One gotcha is that you have to add +1 to the returned index.