Skip to content

Instantly share code, notes, and snippets.

@Caleb-T-Owens
Last active December 5, 2022 15:22
Show Gist options
  • Select an option

  • Save Caleb-T-Owens/5d00ffdce0cb56efbb9216d7ebe8c011 to your computer and use it in GitHub Desktop.

Select an option

Save Caleb-T-Owens/5d00ffdce0cb56efbb9216d7ebe8c011 to your computer and use it in GitHub Desktop.
class One < Day
def initialize
file = File.open('one.txt').read
@sums = file # 1\n2\n\n3\n4
.split("\n\n") # 1\n2, 3\n4
.map { _1.split.sum(&:to_i) }
.max(3)
end
def part_a
@sums.max
end
def part_b
@sums.sum
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment