Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. def cover_the_gap_students(shed, n, group):
  2. pr = [-1] * 6
  3. for lesson in range(7):
  4. for day in range(6):
  5. if shed[group][lesson][day] != 0:
  6. pr[day] = lesson
  7. cur = []
  8. for i in range(len(pr)):
  9. if pr != -1:
  10. cur.append(i)
  11. rand = choice(len(cur))
  12. rs = cur[rand]
  13. first = -1
  14. # here we are a little bit greedy
  15. for lesson in range(7):
  16. if shed[group][lesson][rand] != 0 and first == -1:
  17. first = lesson
  18. if shed[group][lesson][rand] != 0 and first != -1 and lesson < rs:
  19. pos.append(lesson)
  20. # if possible returns shed, else returns -1
  21. for i in range(len(pos)):
  22. shed[group][rs][rand], shed[group][pos[i]][rand] = shed[group][pos[i]][rand],shed[group][rs][rand]
  23. if checkcorrectness(shed,n,a):
  24. return shed
  25. shed[group][rs][rand], shed[group][pos[i]][rand] = shed[group][pos[i]][rand],shed[group][rs][rand]
  26. return -1
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34. def cover_the_gap_teachers():
  35. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement