ContentsFoundations to FrontierBezhig

graduate_code/starters/contracts.py

All lab code. Download this file.

# Exercise scaffold. Reference implementation is in a separate directory.
"""G01: a finite state model. This is sequential, not a thread model."""
from collections import deque
from dataclasses import dataclass

@dataclass(frozen=True)
class Stock:
    available: int
    sold: int = 0

def reserve(state: Stock, amount: int) -> Stock:
    raise NotImplementedError('Implement this contract from the book.')

def explore(initial: int, max_amount: int=4) -> set[Stock]:
    raise NotImplementedError('Implement this contract from the book.')