"""
Exercise 2: build independent counters with closures

Implement make_counter(start=0) that returns TWO functions packaged as
a tuple (increment, get_value):

  increment(step=1) -> adds step to the counter, returns new value
  get_value()        -> returns the current value WITHOUT changing it

Requirements:
  - Each call to make_counter() must produce an INDEPENDENT counter —
    calling increment() on one counter must never affect another.
  - Use `nonlocal`, not a mutable default argument or a global.
  - The counter's current value must not be readable except through
    get_value() (i.e. no attribute exposing it directly).
"""

def make_counter(start=0):
    # TODO: implement using a closure + nonlocal
    pass


# --- self-check: do not modify below this line ---
inc_a, get_a = make_counter()
inc_b, get_b = make_counter(100)

inc_a()
inc_a()
inc_a(step=5)
inc_b(step=-10)

checks = [
    (get_a(), 7),     # 0 + 1 + 1 + 5
    (get_b(), 90),    # 100 - 10
]

all_passed = all(actual == expected for actual, expected in checks)
for actual, expected in checks:
    print(f"got {actual!r}, expected {expected!r} -> {'PASS' if actual == expected else 'FAIL'}")

print("ALL PASS" if all_passed else "SOME FAILED")
