Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1.  
  2. price = input()
  3.  
  4. price.split(' ')
  5.  
  6. p= list()
  7.  
  8. n = 0
  9.  
  10. while n < len(price) :
  11. if price[n] == ' ' :
  12. n=n+1
  13. continue
  14. p.append(price[n])
  15. n = n+1
  16.  
  17. p.sort()
  18.  
  19. print(p)
  20.  
  21. coins = input()
  22.  
  23. def khoj(list,coin):
  24. first = 0
  25. last = len(list)
  26.  
  27. found = False
  28.  
  29. while found is False:
  30. mid = int((first+last)//2)
  31. if list[mid] == coin:
  32. found = True
  33. print(mid)
  34. elif list[mid+1] > coin > list[mid] :
  35. found = True
  36. print(mid)
  37. else :
  38. if coin > list[mid] :
  39. first = mid
  40. else :
  41. last = mid
  42.  
  43. khoj(price,coins)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement