Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • \$\begingroup\$ Notes: 1) the entry gives (usually) different results every time it's run in a new interpreter but may give the same result if run within the same python session. 2) I assume that terminating through an error without explicitly checking for k=0 is acceptable. \$\endgroup\$ Commented Jul 10, 2018 at 0:42
  • \$\begingroup\$ Sorry, but functions must be reusable arbitrarily often in the same environment. Terminating in an error is acceptable though \$\endgroup\$ Commented Jul 10, 2018 at 6:36
  • \$\begingroup\$ The task requires a uniform random number from the given range. hash() tries to maintain but doesn't guarantee this property. For that task you should use the random module. \$\endgroup\$ Commented Jul 10, 2018 at 12:41
  • \$\begingroup\$ With only 57 bytes you can amend your solution to use uniformly random numbers from random.randrange(): from random import*;f=lambda k:print(k)or f(randrange(k)) \$\endgroup\$ Commented Jul 10, 2018 at 13:29