1
0
Fork 0
This commit is contained in:
Andrew Tomaka 2024-12-01 16:21:27 -05:00
commit 9b78a63fba
Signed by: atomaka
GPG key ID: 61209BF70A5B18BE
3 changed files with 1027 additions and 0 deletions

14
1-1.rb Executable file
View file

@ -0,0 +1,14 @@
#!/usr/bin/env ruby
require "debug"
input = File.readlines("1.input").map(&:split)
first = input.map(&:first).compact.sort
last = input.map(&:last).compact.sort
result = first.map.with_index do |v, i|
(v.to_i - last[i].to_i).abs
end.sum
puts result

12
1-2.rb Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env ruby
input = File.readlines("1.input").map(&:split)
first = input.map(&:first).compact
last = input.map(&:last).compact
result = first.map do |v|
v.to_i * last.select { _1.match?(v) }.size
end.sum
puts result

1001
1.input Normal file

File diff suppressed because it is too large Load diff