diff --git a/README.md b/README.md index e4a2dca..e229b67 100644 --- a/README.md +++ b/README.md @@ -36,4 +36,4 @@ Feel free to explore, learn, and share your own approaches. - [x] **3/28:** 28 Days Later 🧟 - [x] **3/29:** Leaderboard Stats 📊 - [x] **3/30:** Ye Old Emoticons 📰 -- [ ] **3/31:** My Best Streak 🔥 +- [x] **3/31:** [My Best Streak](https://github.com/codedex-io/daily-challenges/tree/main/march-2026/3-31-my-best-streak) 🔥 diff --git a/march-2026/3-31-my-best-streak/my-best-streak.py b/march-2026/3-31-my-best-streak/my-best-streak.py new file mode 100644 index 0000000..58cdc9d --- /dev/null +++ b/march-2026/3-31-my-best-streak/my-best-streak.py @@ -0,0 +1,19 @@ +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 \ No newline at end of file