Find the difference between the alternate numbers in the set of numbers and find the index position of the smallest number with the largest difference
Problem :
Sheela is crazy on mathematics. Since decided to play a game by using a set of numbers.
The game is to find the difference between the alternate numbers in the set of numbers and find the index position of the smallest number with the largest difference. If more than one pair has the same largest difference consider the first occurrence. If the size of a set is less than 5 and greater than 10, Display "invalid array size".
Solution :
When we execute the above python code, it will prompt the user for an input (given below)
Enter the no of values:
Here i will give the input as 6.
Then it will prompt the user to enter 6 values. So the ouput terminal will look like :
Enter the no of values:6
Enter the Values
Enter the values you want to test it for. (Example given below)
65
45
54
23
25
24
Once we enter all the values, we will get the following output as response and the output terminal will look like:
Enter the no of values:6
Enter the Values
65
45
54
23
25
24
29 Greatest difference
25 is the smallest parent
54 is the greatest parent
Tags : How to find difference between alternate numbers, find difference between alternate numbers .