Advertisement
icarussiano

day14p1 Julia

Dec 14th, 2024 (edited)
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Julia 0.51 KB | None | 0 0
  1. wide, tall=101,103
  2. parse_coords(coord_str) = parse.(Int, split(split(coord_str, "=")[2], ","))
  3. robots = split.(readlines("input"))
  4. positions = [mod.(pos .+ vel .* 100, [wide, tall]) for robot in robots]
  5. quadrants = [
  6.     count(el -> el[1] > wide ÷ 2 && el[2] > tall ÷ 2, positions),
  7.     count(el -> el[1] > wide ÷ 2 && el[2] < tall ÷ 2, positions),
  8.     count(el -> el[1] < wide ÷ 2 && el[2] > tall ÷ 2, positions),
  9.     count(el -> el[1] < wide ÷ 2 && el[2] < tall ÷ 2, positions)
  10. ]
  11. println(prod(quadrants))
  12.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement