Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. # Written by *** and Eric Martin for COMP9021
  2.  
  3.  
  4. from random import seed, shuffle
  5. import sys
  6.  
  7.  
  8. # for_seed is meant to be an integer, length a strictly positive integer.
  9. # length will not be large for most tests, but can be as large as 10_000_000.
  10. def generate_permutation(for_seed, length):
  11. seed(for_seed)
  12. values = list(range(1, length + 1))
  13. shuffle(values)
  14. return values
  15.  
  16. def maps_to(values, x):
  17. new_values = list(range(1, x + 1))
  18. new_values = sorted(values)
  19. print(new_map_values)
  20. return new_values
  21. # REPLACE PASS ABOVE WITH YOUR CODE
  22.  
  23. def length_of_cycle_containing(values, x):
  24. pass
  25. # REPLACE PASS ABOVE WITH YOUR CODE
  26.  
  27. # Returns a list of length len(values) + 1, with 0 at index 0
  28. # and for all x in {1, ..., len(values)}, the length of the cycle
  29. # containing x at index x.
  30. def analyse(values):
  31. pass
  32. # REPLACE PASS ABOVE WITH YOUR CODE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement