Created
December 7, 2022 01:35
-
-
Save bougyman/b72d3fe64dc687dd8df42e07e6438b3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require_relative 'advent_helper' | |
# AoC 2022, day 6 | |
class Day6 | |
include AdventHelper # For #file_to_array | |
attr_reader :input_file | |
def initialize(input_file = 'day6.input', move_type: :multiple) | |
@move_type = move_type | |
@input_file = input_file | |
end | |
def find_start(start_sequence = 14) | |
line = input.first | |
count = 0 | |
seen = [] | |
line.chars.each do |char| | |
break if seen.count == start_sequence | |
if seen.include? char | |
seen = [char] | |
else | |
seen << char | |
end | |
count += 1 | |
end | |
count - 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment