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

171 comments sorted by

View all comments

Show parent comment

1

u/hutsboR Dec 06 '15

That's a good point about Dict.update. The issue with my implementation is that my map stores coordinate -> atom and not coordinate -> boolean. I'm definitely going to change the values to booleans so I can negate it to invert the value. Thanks!

You can change your generate_coordinates function to use list comprehensions instead of using nested maps:

for x <- x_lower..x_upper, y <- y_lower..y_upper, do: {x, y}

1

u/ignaciovaz Dec 06 '15

Yeah, after I saw your solution I was tempted to change it, but it felt like cheating ;)

I've changed the generate_coordinates funcion to use list comprehensions in my local version, though.