Skip to content

Instantly share code, notes, and snippets.

@bougyman
Created December 7, 2022 01:35
Show Gist options
  • Save bougyman/b72d3fe64dc687dd8df42e07e6438b3a to your computer and use it in GitHub Desktop.
Save bougyman/b72d3fe64dc687dd8df42e07e6438b3a to your computer and use it in GitHub Desktop.
# 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