mirror of
https://github.com/onyx-and-iris/aoc2025.git
synced 2025-12-08 11:47:47 +00:00
25 lines
421 B
Ruby
Executable File
25 lines
421 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
class Main
|
|
def run
|
|
@sum = 0
|
|
|
|
line = $stdin.gets.chomp
|
|
line.split(",").each do |range|
|
|
lo, hi = range.split("-")
|
|
(lo..hi).each do |num|
|
|
if num.length.even?
|
|
if num[0..(num.length / 2) - 1] == num[(num.length / 2)..]
|
|
@sum += num.to_i
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
puts @sum
|
|
end
|
|
end
|
|
|
|
Main.new.run
|