Skip to content

Feat/opening day python solution -> main#21

Open
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/opening-day-python-solution
Open

Feat/opening day python solution -> main#21
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/opening-day-python-solution

Conversation

@alangnt
Copy link
Copy Markdown
Contributor

@alangnt alangnt commented Mar 25, 2026

Hi Codédex team,

This PR adds a working Python solution for today's Opening Day ⚾ challenge, and updates the README.md file to add today's GitHub link.

Here's the code :

def streak_counter(games):
  best_streak = 0
  current_streak = 0

  # for each game
  for game in games:
    # if it's a win
    if game == "W":
      # add 1 to current streak and return highest value
      # between best and current
      current_streak += 1
      best_streak = max(best_streak, current_streak)
    elif game == "L":
      # else if lose current streak goes to 0
      current_streak = 0

  return best_streak

Here's how it works :

  • init two variables best_streak and current_streak at 0
  • for each game if win we add 1 to the current streak and return the highest value between best and current into best_streak to only keep the best streak of all time
  • if lose, we reset the current streak to 0
  • if rainout we don't do anything because it does not modify the streak
  • finally we return the best streak

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant