Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Untitled

a guest Dec 6th, 2018 70 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. function count_overclaims(claims)
  2.     fabric = zeros(1000, 1000)
  3.     for claim in claims
  4.         claimed_area = view(
  5.             fabric,
  6.             claim[:x]+1:claim[:x]+claim[:width],
  7.             claim[:y]+1:claim[:y]+claim[:height],
  8.         )
  9.         claimed_area .+= 1
  10.     end
  11.     return count(x -> x>1, fabric)
  12. end
  13.  
  14. function parse_claim(s)
  15.     id, s = split(s, '@')
  16.     corner, dimensions = split(s, ':')
  17.     x, y = map(x->parse(Int,x), split(corner, ','))
  18.     width, height = map(x->parse(Int,x), split(dimensions, 'x'))
  19.     return (x=x, y=y, width=width, height=height)
  20. end
  21.  
  22. println(count_overclaims(map(parse_claim, readlines(stdin))))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top