Compare Triplets Hackerrank Solution Python