puzzle code from paper