Building an Iterator Protocol

Medium Design Patterns & Final Challenges
Solve in Playground →

Problem Statement

Create a `Countdown` class that implements Python’s strict iterator protocol using `__iter__` and `__next__`. It should count down from a `start` value to 0. Read an integer, instantiate the iterator, and loop through it, printing each number separated by spaces.

Input Format

A single integer N.

Output Format

Print space-separated countdown sequence.

Constraints

N >= 0

Sample Input

3

Sample Output

3 2 1 0

Explanation

Custom objects can integrate directly into standard `for` loops by defining iteration protocols and raising `StopIteration`.

Starter Code

class Countdown:
    # Implement __init__, __iter__, and __next__
    pass

if __name__ == '__main__':
    n = int(input().strip())
    # Instantiate and iterate
    pass

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used