From c8d09f9eab33a90d04038a62b36c280a005d12b9 Mon Sep 17 00:00:00 2001 From: s00ner Date: Mon, 30 Dec 2024 09:27:55 -0500 Subject: [PATCH] ran rubocop --- day01/solution.rb | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/day01/solution.rb b/day01/solution.rb index ca7f70c..4789804 100755 --- a/day01/solution.rb +++ b/day01/solution.rb @@ -1,29 +1,23 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require 'pry' # Part 1 -real_input = File.read("./input") -sample = '3 4 -4 3 -2 5 -1 3 -3 9 -3 3' +real_input = File.read('./input') input = real_input -col1 = input.split("\n").map(&:split).map{ | pair | pair[0].to_i}.sort -col2 = input.split("\n").map(&:split).map{ | pair | pair[1].to_i}.sort +col1 = input.split("\n").map(&:split).map { |pair| pair[0].to_i }.sort +col2 = input.split("\n").map(&:split).map { |pair| pair[1].to_i }.sort -#binding.pry +# binding.pry -solution = col1.zip(col2).map{ | left, right | (right - left).abs }.sum +solution = col1.zip(col2).map { |left, right| (right - left).abs }.sum puts solution # Part 2 -p2 = col1.map{ | value | value * col2.count(value)}.sum +p2 = col1.map { |value| value * col2.count(value) }.sum puts p2 -