2023 Day 1 in Ruby

This commit is contained in:
2023-12-01 20:03:52 -05:00
commit d00e27d271
11 changed files with 1101 additions and 0 deletions

11
2023/day1/p1.rb Normal file
View File

@@ -0,0 +1,11 @@
res = 0
File.foreach("./2023/day1/data") do |line|
first_int = -1
last_int = -1
line.each_byte do |b|
first_int = b - 48 if first_int == -1 and b > 47 and b < 58
last_int = b - 48 if b > 47 and b < 58
end
res += first_int * 10 + last_int
end
puts res