A Countdown-style Numbers Game in Python
This post is largely because repl.it have an embeddable Python environment and I want to try it out.
And here (hopefully) is an embedded version:
It works! Not every time, and not flawlessly (for example waiting for user input just causes my browser to hang) but it’s still useful.
There is also an iframe version that’s far more powerful in that not only does user input work, but the script is entirely editable:
Same code but hosted locally rather than embedded from a third party:
import random big = [100,75,50,25] small = list(range(1,11))*2 nummax = 6 numbig = int(input('big?')) selected = random.sample(big, numbig) + random.sample(small, nummax - numbig) target = random.randint(100,999) print('{:>14d}{:>30s}'.format(target, ', '.join(str(x) for x in selected)))