Sigh
This commit is contained in:
parent
9ca8885fbc
commit
f3b7f68188
@ -1,3 +1,5 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/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
|
cephalopod_math = CephalopodMath.for STDIN.read.chomp
|
||||||
|
puts "Part 1: #{cephalopod_math.wide_column_answers.sum}"
|
||||||
18
ruby/2025/6/lib/cephalopod_math.rb
Normal file
18
ruby/2025/6/lib/cephalopod_math.rb
Normal file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user