fork download
  1. import itertools
  2.  
  3. s = [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
  4. 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
  5. 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
  6. 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
  7.  
  8. def variate_from_id(l, id, n=4):
  9. combination = []
  10. id -= 1
  11. size = len(s)
  12. for _ in range(n):
  13. combination.append(l[id % size])
  14. id //= size
  15. return tuple(reversed(combination))
  16.  
  17. def variate4(l):
  18. yield from itertools.product(*([l] * 4))
  19.  
  20. print(variate_from_id(s, 4856))
  21.  
  22. j = 0
  23. for i in variate4(s):
  24. j = j + 1
  25. if j == 4856:
  26. print(''.join(str(i)))
  27. break
Success #stdin #stdout 0.04s 9748KB
stdin
Standard input is empty
stdout
(0, 1, 44, 10)
(0, 1, 44, 10)