Prototype: implement touch_order(keys, key). Assume keys contains distinct nonempty strings and key is a nonempty string. Return a fresh list in oldest-to-newest order, moving an existing key to the end or appending a missing key. Do not mutate keys. There is no capacity limit at this stage.
Final: implement LRUCache(capacity). Capacity must be a nonnegative integer, excluding booleans; invalid capacity raises ValueError. Keys must be nonempty strings. Stored values must be integers, excluding booleans; negative values are valid. Invalid keys or stored values raise ValueError before any state or order change.
put(key, value) returns None, inserts or updates the value, and makes the key most recent. Evict the least recent key only if needed. At zero capacity, valid puts are no-ops. get(key, default=None) returns the value and refreshes recency on a hit; a miss returns the supplied default without changing state. Defaults may be any object. delete(key) returns True if removed and False if absent; it does not refresh other keys. items() returns a fresh list of (key, value) tuples ordered least recent first. Instances own independent state. Repeated updates occupy one entry.
Complete the starter code, then run the checks.
Results and errors will appear here.