Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. inputArray = [ 2, 3, 5, 2, 3, 1, 5, 2, 3, 2]
  2. outputArray = [[1, 0], [2, 0], [3, 0], [4, 0], [5, 0], [6, 0]]
  3.  
  4. for i in inputArray:
  5.   outputArray[i-1][1] += 1
  6.  
  7. n = 0
  8. for i in outputArray:
  9.   if i[1] == 0: del outputArray[n]
  10.   n += 1
  11.  
  12. for i in range(len(outputArray) - 1):
  13.   for j in range(len(outputArray) - 1):
  14.     if outputArray[j][1] > outputArray[j+1][1]:
  15.       t = outputArray[j]
  16.       outputArray[j] = outputArray[j+1]
  17.       outputArray[j+1] = t
  18.  
  19.  
  20.  
  21. print(outputArray[0][0], outputArray[1][0], outputArray[2][0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement