mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-08 11:47:47 +00:00
use deletaged methods
use single instance of Grid
This commit is contained in:
parent
c8c523dd66
commit
432d14e248
@ -15,15 +15,15 @@ class Main
|
||||
grid = Grid.new(data)
|
||||
loop do
|
||||
grid_updated = false
|
||||
(0...grid.rows.size).each do |row_index|
|
||||
(0...grid.columns.size).each do |column_index|
|
||||
(0...grid.size).each do |row_index|
|
||||
(0...grid[row_index].size).each do |column_index|
|
||||
cell = grid.cell_at(row_index, column_index)
|
||||
next unless cell.value == "@"
|
||||
|
||||
if cell.neighbours.count do |neighbour|
|
||||
neighbour.value == "@"
|
||||
end < 4
|
||||
data[row_index][column_index] = "x"
|
||||
grid[row_index][column_index].value = "x"
|
||||
@sum += 1
|
||||
grid_updated = true
|
||||
end
|
||||
@ -31,7 +31,6 @@ class Main
|
||||
end
|
||||
|
||||
break unless grid_updated
|
||||
grid = Grid.new(data)
|
||||
end
|
||||
|
||||
puts @sum
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user