day-19.rb
# Class-level cache since we have per-instance solving
Class-level cache since we have per-instance solving
Class - level cache since we have per - instance solving
def first_part
    absolute_positions = CACHE[input] ||= compute_absolute_positions
    absolute_beacons = input.map.with_index do |beacons, i|
      beacons.map { |beacon| add(orient(beacon, absolute_positions[i].first), absolute_positions[i].last) }
    end
    absolute_beacons.flatten(1).uniq.count
  end
def first_part absolute_positions = CACHE [ input ] ||= compute_absolute_positions absolute_beacons = input . map . with_index do | beacons , i | beacons . map { | beacon | add ( orient ( beacon , absolute_positions [ i ] . first ) , absolute_positions [ i ] . last ) } end absolute_beacons . flatten ( 1 ) . uniq . count end
Class-level cache since we have per-instance solving
Class - level cache since we have per - instance solving