Sha256: 9deb55d6025ccff62a89638c8e0d5020dfa8372b01a414b7850e97a579901eed
Contents?: true
Size: 621 Bytes
Versions: 4
Compression:
Stored size: 621 Bytes
Contents
# # https://adventofcode.com/2018/day/1 Part 2 # # Does not use any cem functions \o/ but did you know: # # - Set provides #[] as a class method: Set[1,2,3] is the same as Set.new() and then Set.add(...) # - Set provides #add?() to add and check if the object added was already in the Set (returns nil in case). # # For example: Set[0,1].add?(1) => nil # require 'set' cur = 0 seen_before = Set[0] while true File.read("inputs/day1_input.txt").each_line { |line| cur += line.to_i if !seen_before.add?(cur) puts cur exit end } end # Unreachable!
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cem-0.1.7 | examples/aoc2018/day1_part2.rb |
cem-0.1.6 | examples/aoc2018/day1_part2.rb |
cem-0.1.5 | examples/aoc2018/day1_part2.rb |
cem-0.1.4 | examples/aoc2018/day1_part2.rb |