Compare commits
4 Commits
4358ca34b3
...
8bd7ab3b2f
Author | SHA1 | Date |
---|---|---|
s00ner | 8bd7ab3b2f | |
s00ner | d62dda2921 | |
s00ner | 47f4fe1364 | |
s00ner | 172d187492 |
|
@ -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/
|
File diff suppressed because it is too large
Load Diff
|
@ -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]
|
Loading…
Reference in New Issue