June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -1,18 +1,10 @@
'''
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.
'''.print()
var data = list('123456789')
var trials = 0
while data == sorted(data): random.shuffle data
print '# Number reversal game'
var data, trials = list('123456789'), 0
while data == sorted(data):
random.shuffle data
while data != sorted(data):
trials += 1
flip = int scan '#$trials: LIST: $(join data) Flip how many?: '
data[:flip] = data[!flip:]
trials += 1
flip = int input '#$trials: LIST: $(join data) Flip how many?: '
data[:flip] = data[!flip:]
print '\nYou took $trials attempts to put digits in order!'