Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,22 @@
'''
number reversal game
Given a jumbled list of the numbers 1 to 9
Show the list.
Ask the player how many digits from the left to reverse.
Reverse those digits then ask again.
until all the digits end up in ascending order.
'''
import random
print(__doc__)
data, trials = list('123456789'), 0
while data == sorted(data):
random.shuffle(data)
while data != sorted(data):
trials += 1
flip = int(input('#%2i: LIST: %r Flip how many?: ' % (trials, ' '.join(data))))
data[:flip] = reversed(data[:flip])
print('\nYou took %2i attempts to put the digits in order!' % trials)