24 lines
376 B
Ruby
Executable File
24 lines
376 B
Ruby
Executable File
#!/bin/env ruby
|
|
|
|
input = Array.new
|
|
File.readlines('./input').each.with_index do |line, i|
|
|
line.strip!
|
|
input[i] = line.split('')
|
|
end
|
|
|
|
input.each do |x|
|
|
x.map! do |y|
|
|
y == '#' ? true : false
|
|
end
|
|
end
|
|
|
|
i = 0
|
|
trees = 0
|
|
len = input[0].length
|
|
input.each do |row|
|
|
trees += 1 if row[i]
|
|
i +=3
|
|
i = i - len if i >= len
|
|
end
|
|
|
|
puts "We hit #{trees} trees" |