Skip to content

Feat/my best streak python solution -> main#27

Open
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/my-best-streak-python-solution
Open

Feat/my best streak python solution -> main#27
alangnt wants to merge 2 commits intocodedex-io:mainfrom
alangnt:feat/my-best-streak-python-solution

Conversation

@alangnt
Copy link
Copy Markdown
Contributor

@alangnt alangnt commented Mar 31, 2026

Hi Codédex team,

This PR creates a folder for today's My Best Streak 🔥 challenge, adds a working Python solution, and updates the README.md file to add today's GitHub link.

Here's the code :

def longest_streak(progress):
  # define best and current streaks
  best_streak = 0
  current_streak = 0

  # for each day
  for day in progress:
    # if completed, add 1 to current
    if day == "✅":
      current_streak += 1
      # if current higher than best
      # replace best by current
      if current_streak > best_streak:
        best_streak = current_streak
    # else reset current
    else:
      current_streak = 0

  return best_streak

Here's how it works :

  • we go through the list day by day
  • if it's a ✅ we increment the current streak counter, and update the best if it's now higher
  • if it's a ❌ we just reset the current counter to 0
  • at the end we return the best streak we found

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