Something went wrong. Try again.
Code for the Advent of Code event
aoc advent-of-code
Something went wrong. Try again.
310 B · 9 lines
Ruby
at rust
12345678910#!/usr/bin/env ruby# frozen_string_literal: true
input = $stdin.each_line.map { |l| l.split.map(&:to_i) }part1 = input.reduce(0) { |a, e| a + e.max - e.min }part2 = input.reduce(0) { |a, e| a + e.permutation(2).find { |p| p.reduce(&:%) == 0 }.reduce(&:/) }
puts "Part 1: #{part1}"puts "Part 2: #{part2}"