codes for algorithm puzzles