Advertisement
Callowlock

310 A1

Oct 6th, 2022 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. def findMinRooms(*lists):
  2. L, i = [], 0
  3. while i <len(lists):
  4. L.append(lists[i])
  5. i+=1
  6. L.sort()
  7. i, count, c2, itr = 1, 1, 0, L[0]
  8. while i < len(L):
  9. if (itr == L[i]):
  10. itr = L[i]
  11. count +=1
  12. elif (itr[1] <= L[i][0]):
  13. itr = L[i]
  14. c2, count = max(c2,count), 1
  15. else:
  16. count+=1
  17. i+=1
  18. return max(c2,count)
  19.  
  20. print("l = actual: 1. from function =", findMinRooms([1,3]))
  21. print("l1 = actual: 3. from function =", findMinRooms([3.1, 8.0], [2.3, 5.0], [1.2, 3.4]))
  22. print("l2 = actual: 2. from function =", findMinRooms([4.1, 8.0], [2.3, 5.0], [1.2, 3.4]))
  23. print("l3 = actual: 4. from function =", findMinRooms([3.1, 8.0], [2.3, 5.0], [1.2, 3.4], [1.0, 10.0]))
  24. print("l4 = actual: 3. from function =", findMinRooms([1.1, 1.5], [5, 6], [4, 7], [1.0, 2.0], [3, 8]))
  25. print("l6 = actual: 4. from function =", findMinRooms([1,2],[1,22],[1.5,6], [6,10],[6,10],[6,10], [12.1,17.8]))
  26. print("l7 = actual: 1. from function =", findMinRooms([1,2],[2,3],[3,4],[15,18]))
  27. print("l8 = actual: 3. from function =", findMinRooms([1,3],[1,3],[1,3]))
  28. print(findMinRooms([1,20],[2,19],[3,15],[16,18],[17,20])) #output should be 4
Tags: python
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement