dougbaker45

Random Count Up

Jun 15th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.08 KB | None | 0 0
  1. import random
  2. from timeit import default_timer as timer
  3. start = timer()
  4. y = [0]
  5. x = 1
  6. f = 1000000
  7. g = 500
  8. z = y[:-1]
  9. d = {}
  10. tot = 0
  11. rolls = 0
  12. rollsmax = 0
  13. rollsmin = 0
  14. highroll = 0
  15. lowroll = None
  16. highkey = 0
  17. lowkey = 0
  18. hightime = 0
  19. lowtime = None
  20. hightimekey = 0
  21. lowtimekey = 0
  22. trange = 0
  23. while y[-1] < g:
  24.     x = random.randint(1, f)
  25.     a = len(str(x))
  26.     b = 4 - a
  27.     z = y[-1]
  28.     rolls += 1
  29.     if x in d:
  30.         d[x] += 1
  31.     else:
  32.         d[x] = 1
  33.     if x == z + 1:
  34.         y.append(x)
  35.         end = timer()
  36.         print(x, ':', rolls)
  37.         if rolls > highroll:
  38.             highroll = rolls
  39.             highkey = y[-1]
  40.             print('The Highest Current Roll was: ', highroll,', for key number: ', highkey)
  41.         if lowroll is None:
  42.             lowroll = rolls
  43.             lowkey = y[-1]
  44.             print('The Lowest Current Roll was: ', lowroll,', for key number: ', lowkey)
  45.         if rolls < lowroll:
  46.             lowroll = rolls
  47.             lowkey = y[-1]
  48.             print('The Lowest Current Roll was: ', lowroll,', for key number: ', lowkey)
  49.         kend = end - start
  50.         if kend > hightime:
  51.             hightime = kend
  52.             hightimekey = y[-1]
  53.         if lowtime is None:
  54.             lowtime = kend
  55.             lowtimekey = y[-1]
  56.         if kend < lowtime:
  57.             lowtime = kend
  58.             lowtimekey = y[-1]
  59.         rolls = 0
  60.     tot += 1
  61. averagerolls = tot / g
  62. ending = timer()
  63. averagetime = (ending - start) / g
  64. rrange = highroll - lowroll
  65. trange = hightime - lowtime
  66. print('Total Rolls is:', tot, ', Total Time is', (ending - start))
  67. print('The Average number of rolls was:', averagerolls)
  68. print('The average time was', (averagetime))
  69. print('The Highest Roll was: ', highroll,', for key number: ', highkey)
  70. print('The Lowest Roll was: ', lowroll,', for key number: ', lowkey)
  71. print('Roll Range was', rrange)
  72. print('The Longest Roll Time was: ', hightime,', for key number: ', hightimekey)
  73. print('The Shortest Roll Time was: ', lowtime,', for key number: ', lowtimekey)
  74. print('The Time Range was:', trange)
Add Comment
Please, Sign In to add comment