implemented algorithm and (theoretically, though not realistically) working code