advent-of-code/2015/day-02/part_two.rb
Patrick Auernig 3c57921438 Refactor 2015 days 01 to 10
Split parts into separate files and remove some unused files
2021-12-08 01:05:17 +01:00

18 lines
383 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "common"
def part_two(dims)
dims.sum do |sides, length, width, height|
circumference =
case sides.map.with_index.min.last
when 0 then length * 2 + width * 2
when 1 then width * 2 + height * 2
when 2 then height * 2 + length * 2
end
circumference + length * width * height
end
end
puts part_two(INPUT)