Compare commits

...

4 Commits

Author SHA1 Message Date
s00ner 8bd7ab3b2f solved part 2 2021-11-10 11:44:37 -05:00
s00ner d62dda2921 Solved part 1 2021-11-10 09:50:43 -05:00
s00ner 47f4fe1364 added input 2021-11-10 09:43:18 -05:00
s00ner 172d187492 Updated readme 2021-11-10 09:36:08 -05:00
3 changed files with 1026 additions and 2 deletions

View File

@ -1,3 +1,8 @@
# AoC2018
# Advent of Code 2018
AoC 2018 code.
This is a repo for my Advent of Code 2018 solutions.
I'll be trying to solve challenges using Ruby and editing in VS Code to learn both better.
I'm using 2018 challenges as a warm up for 2021 AoC.
Link: https://adventofcode.com/

1004
day01/input Normal file

File diff suppressed because it is too large Load Diff

15
day01/solution.rb Normal file
View File

@ -0,0 +1,15 @@
#!/bin/env ruby
# Sum all numbers in the text file.
# Part 1
sum = File.readlines('./input').map { |line| line.to_i}.sum
# Part 2
numbers = File.readlines('./input').map { |line| line.to_i}
freqs = [0]
numbers.cycle do |num|
freqs.push(freqs[-1] + num)
break if freqs[0..-2].include?(freqs[-1])
end
puts freqs[-1]