ran rubocop

main
s00ner 2024-12-30 09:27:55 -05:00
parent 40b1d482a8
commit c8d09f9eab
1 changed files with 7 additions and 13 deletions

View File

@ -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