Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function count_overclaims(claims)
- fabric = zeros(1000, 1000)
- for claim in claims
- claimed_area = view(
- fabric,
- claim[:x]+1:claim[:x]+claim[:width],
- claim[:y]+1:claim[:y]+claim[:height],
- )
- claimed_area .+= 1
- end
- return count(x -> x>1, fabric)
- end
- function parse_claim(s)
- id, s = split(s, '@')
- corner, dimensions = split(s, ':')
- x, y = map(x->parse(Int,x), split(corner, ','))
- width, height = map(x->parse(Int,x), split(dimensions, 'x'))
- return (x=x, y=y, width=width, height=height)
- end
- println(count_overclaims(map(parse_claim, readlines(stdin))))
Add Comment
Please, Sign In to add comment