Much sneakier algorithm