You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
regex=~r/Sensor at x=(?<sensor_x>-?\d+), y=(?<sensor_y>-?\d+): closest beacon is at x=(?<beacon_x>-?\d+), y=(?<beacon_y>-?\d+)/sensor_beacon=input|>Kino.Input.read()|>String.split("\n",trim: true)|>Enum.reduce(%{},fnline,acc->captured=Regex.named_captures(regex,line)captured=captured|>Enum.map(fn{k,v}->{k,String.to_integer(v)}end)|>Map.new()sensor={Map.get(captured,"sensor_x"),Map.get(captured,"sensor_y")}beacon={Map.get(captured,"beacon_x"),Map.get(captured,"beacon_y")}Map.put(acc,sensor,beacon)end)
{min_x,max_x}=sensor_beacon|>Enum.flat_map(fn{{sx,_},{bx,_}}->[sx,bx]end)|>Enum.min_max()row=2_000_000min_x..max_x|>Enum.map(fnx->polygons|>Enum.any?(fnpolygon->Topo.intersects?(polygon,{x,row})end)end)|>Enum.reject(&(&1==false))|>Enum.count()# for some reason|>Kernel.-(1)