$ ./guess_the_languageProblem Solving — fix the bug
Problem Solving — fix the bug · hard · #173

Which fix removes the bug?

class Cache:
    store = {}
    def put(self, k, v):
        self.store[k] = v
  1. Create store in __init__
  2. Copy store on each put
  3. Mark store as private
  4. Use a classmethod here
A class attribute is shared by every instance, so all caches see each other's entries.
Play Problem Solving ▸