Pyramids Frequency
These are N pyramids in a line.You are given their heights as space-separated integers.Write a program to print the heights of the pyramids in increasing order along with their frequency.
Input
The first line of input contains space-separated integers.
Output
Each line of output should contain the height of the pyramid and its frequency in the ascending order of the pyramid's height.
Explanation
In the example, The given pyramid heights are 1,5,1,2,5,6.
The frequency of each unique pyramid height is
1 2
2 1
5 2
6 1
Sample Input1
1 5 1 2 5 6
Sample Output1
1 2
2 1
5 2
6 1
nums = [int(num) for num in input().split()]
for num in set(nums):
print(num, nums.count(num))
Comments
Leave a comment