From f3b7f681881fb7fae30d5ccd85423e91b144a489 Mon Sep 17 00:00:00 2001 From: Bill Rossi Date: Sat, 6 Dec 2025 06:16:20 -0500 Subject: [PATCH] Sigh --- ruby/2025/6/bin/problem | 4 +++- ruby/2025/6/lib/cephalopod_math.rb | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 ruby/2025/6/lib/cephalopod_math.rb diff --git a/ruby/2025/6/bin/problem b/ruby/2025/6/bin/problem index 610ba8c..70ba95d 100644 --- a/ruby/2025/6/bin/problem +++ b/ruby/2025/6/bin/problem @@ -1,3 +1,5 @@ #!/usr/bin/env ruby +require "cephalopod_math" -puts STDIN.read.chomp.split("\n").map(&:split).transpose.map { |p| p[..-2].map(&:to_i).reduce(&(p[-1]).to_sym) }.sum \ No newline at end of file +cephalopod_math = CephalopodMath.for STDIN.read.chomp +puts "Part 1: #{cephalopod_math.wide_column_answers.sum}" \ No newline at end of file diff --git a/ruby/2025/6/lib/cephalopod_math.rb b/ruby/2025/6/lib/cephalopod_math.rb new file mode 100644 index 0000000..d4419ae --- /dev/null +++ b/ruby/2025/6/lib/cephalopod_math.rb @@ -0,0 +1,18 @@ +class CephalopodMath + attr_reader :worksheet + def initialize(worksheet) + @worksheet = worksheet + end + + def self.for(input) + new input + end + + def wide_columns + worksheet.split("\n").map(&:split).transpose + end + + def wide_column_answers + wide_columns.map{ |column| column[..-2].map(&:to_i).reduce(&(column[-1]).to_sym) } + end +end