Skip to content

Commit

Permalink
day 4 part 2 wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aws-donco committed Dec 4, 2023
1 parent 631da86 commit a02042d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions day04.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@ def points(self):
card_points = card_points * 2
return card_points

def wins(self):
# variation on part1 but with counts
wins = 0
for win in self.winning_numbers:
if win in self.played_number:
wins += 1
return wins


def part01(input_lines):
# working!
Expand All @@ -28,11 +36,28 @@ def part01(input_lines):
winning_list = [wn for wn in winning_nums.strip().split(" ") if wn.isnumeric()]
played_list = [pn for pn in played_nums.strip().split(" ") if pn.isnumeric()]
new_game_card = LottoCard(card_number, winning_list, played_list)
print(new_game_card.points())
# print(new_game_card.points())
total_points += new_game_card.points()
cards.append(new_game_card)
print(total_points)
# print(total_points)
return cards


def add_winning_cards(cards, index, wins):
new_cards = []
for card_idx in range(index, index+wins):
if (wins:=cards[card_idx].wins()) > 0:
new_cards.append(add_winning_cards(cards, card_idx, wins))
return new_cards


def part02(input_lines):
pass
# not working yet
cards = part01(input_lines)
new_card_list = []
total_wins = 0
for (index, card) in enumerate(cards):
if (wins := card.wins()) > 0:
total_wins += wins

print(total_wins)

0 comments on commit a02042d

Please sign in to comment.