diff --git a/2023/ruby/day_14.rb b/2023/ruby/day_14.rb new file mode 100644 index 0000000..be5d668 --- /dev/null +++ b/2023/ruby/day_14.rb @@ -0,0 +1,9 @@ +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) }