Code for the Advent of Code event
aoc advent-of-code
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add Ruby solution for 2025 day 2 part 1

sharparam.com 950b12f0 cb5b78cf

verified
+8
+8
src/y2025/d02/solve.rb
··· 1 + #!/usr/bin/env ruby 2 + # frozen_string_literal: true 3 + 4 + ranges = ARGF.read.scan(/(\d+)-(\d+)/).map { |(a, b)| (a.to_i)..(b.to_i) } 5 + 6 + puts ranges.flat_map { |range| 7 + range.select { |n| n.size.even? && n.to_s.then { |s| s[0...(s.size / 2)] == s[(s.size / 2)..] } } 8 + }.sum