working on part 1
parent
3153761e14
commit
29d813cf0d
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/env ruby
|
||||||
|
require 'pry'
|
||||||
|
|
||||||
|
def fill_seats (seats)
|
||||||
|
output = Array.new(seats.length, Array.new(seats[0].length, nil))
|
||||||
|
output.map!.with_index do |row, i|
|
||||||
|
row.each.with_index do |seat, j|
|
||||||
|
next if !seats[i][j]
|
||||||
|
adjecents = 0
|
||||||
|
adjecents += seats[i+1][j-1..j+1].compact.sum if i < seats.length - 1
|
||||||
|
adjecents += seats[i][j-1].to_i if j > 0
|
||||||
|
adjecents += seats[i-1][j-1..j+1].compact.sum if i > 0
|
||||||
|
adjecents += seats[i][j+1].to_i if j < seats[i].length
|
||||||
|
puts "#{i},#{j}:#{adjecents}"
|
||||||
|
adjecents >= 4 ? 0 : 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
seats = File.readlines('./input.sample').map(&:strip)
|
||||||
|
.map! {|line| line.split('') }
|
||||||
|
.map! {|line| line.map { |char| char == 'L' ? 0 : nil }}
|
||||||
|
|
||||||
|
#next = fill_seats(seats)
|
||||||
|
binding.pry
|
Loading…
Reference in New Issue