Mar-03-2020, 06:15 PM
In your code, line 101, pairs has 7 elements. You divide the count of elements by 2 to get the number of pairs (dropping remainder). You cannot pair everything up using that.
I get that a good looking list has pairs such that each element in the pair is one from the other, can be either order.
A for loop that has a step of 2 will let you assess pairs. A good looking pair will have an even number n and odd number n+1. If the pair is ugly then make a swap.
I get that a good looking list has pairs such that each element in the pair is one from the other, can be either order.
A for loop that has a step of 2 will let you assess pairs. A good looking pair will have an even number n and odd number n+1. If the pair is ugly then make a swap.