[2023][ruby][14.1]

main
Alpha Chen 1 year ago
parent 06068a3114
commit cba5517ee9
Signed by: alpha
SSH Key Fingerprint: SHA256:3fOT8fiYQG/aK9ntivV3Bqtg8AYQ7q4nV6ZgihOA20g

@ -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) }
Loading…
Cancel
Save