Skip to content

Commit

Permalink
Day 21
Browse files Browse the repository at this point in the history
  • Loading branch information
ariejan committed Dec 23, 2024
1 parent d9a341b commit 4e88a34
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
12 changes: 9 additions & 3 deletions lib/solutions/day_21.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ def part_one(input)
sim.run!
end

def part_two(input)
sequences = input.split("\n")
sim = DayOne.new(sequences, 26)
sim.run!
end

class DayOne

def initialize(sequences)
def initialize(sequences, direction_keypads = 3)
@sequences = sequences

@direction_keypads = direction_keypads
@moves_cache = {}
@scores_cache = {}
end
Expand Down Expand Up @@ -59,7 +65,7 @@ def run!
500.times do
@moves_cache.clear
@scores_cache.clear
value = [value, score(sequence, 3, 0) * sequence[0..-2].to_i].min
value = [value, score(sequence, @direction_keypads, 0) * sequence[0..-2].to_i].min
end
result += value
end
Expand Down
6 changes: 0 additions & 6 deletions spec/solutions/day_21_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,5 @@
expect(subject.part_one(input)).to eq(126384)
end
end

describe '#part_two' do
xit 'calculates the correct solutions for part two' do
expect(subject.part_two(input)).to eq(0)
end
end
end

0 comments on commit 4e88a34

Please # to comment.