You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
advent-of-code/etc/total-time.rb

13 lines
323 B

seconds = ARGF.read.strip.lines(chomp: true)
.sum {|line|
line.strip.split(/\s+/).fetch(4)
.split(?:).map(&:to_i)
.zip([60*60, 60, 1])
.sum { _1 * _2 }
}
hours, seconds = seconds.divmod(60 * 60)
minutes, seconds = seconds.divmod(60)
puts "#{hours} hours, #{minutes} minutes, #{seconds} seconds"