You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/2023/ruby/day_14.rb

10 lines
269 B

11 months ago
input = ARGF.readlines(chomp: true).map(&:chars)
p input.transpose
.map {|col| col.chunk_while { [_1, _2].tally.fetch(?#, 0).even? }}
.map {|col| col.flat_map { _1.sort.reverse }}
.transpose
.reverse
.each.with_index
.sum {|row, i| row.count(?O) * (i+1) }