Implementation of the TornNumber problem