mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-07 22:57:50 +00:00
20 lines
363 B
Ruby
Executable File
20 lines
363 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
class Main
|
|
def run
|
|
@sum = 0
|
|
|
|
$stdin.each_line do |line|
|
|
nums = line.chomp.each_char.map(&:to_i)
|
|
first_digit = nums[0..-2].max
|
|
second_digit = nums[nums.find_index(first_digit) + 1..].max
|
|
@sum += "#{first_digit}#{second_digit}".to_i
|
|
end
|
|
|
|
puts @sum
|
|
end
|
|
end
|
|
|
|
Main.new.run
|