Implement Langford with triplets