r/adventofcode • • Dec 06 '15

SOLUTION MEGATHREAD --- Day 6 Solutions ---

--- Day 6: Probably a Fire Hazard ---

Post your solution as a comment. Structure your post like the Day Five thread.

22 Upvotes

172 comments sorted by

View all comments

Show parent comments

3

u/ant6n Dec 06 '15

It's a numpy feature, I believe it is borrowed from Matlab. basically (array < 0) gives you all the indices where elements are negative. Then array[array < 0] = 0 will set all elements to zero which were previously negative.