Candy Button
ABC 376Problem 40 of 50
EasyWhat to do
You have a button that gives you a candy when you press it. However, you can only get a candy if a certain amount of time has passed since you last got one. You will press the button multiple times, and you need to count how many candies you receive.
Key Concepts
if-statements
loops
basic math
input/output handling
Examples
Input:
6 5
1 3 7 8 10 12
Output:
3
Input:
3 2
0 2 4
Output:
3
Tips for Beginners
- Focus on understanding the logic, not memorizing syntax
- Use print statements to debug your code
- Don't worry about input parsing - the function handles that for you
- If stuck, try writing out your solution on paper first
Python Editor
Loading Python...