Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
391 B · 15 lines
Ruby
at rust
12345678910111213141516#!/usr/bin/env ruby# frozen_string_literal: true
counts = []
$stdin.readlines.map(&:strip).tap do |input| input.first.size.times { counts << Hash.new(0) }end.each do |message| message.chars.each.with_index { |c, i| counts[i][c] += 1 }end
sorted = counts.map { |p| p.keys.sort { |a, b| p[b] <=> p[a] } }
puts "(1) #{sorted.map(&:first).join}"puts "(2) #{sorted.map(&:last).join}"