YAPC::EU 2018 Glasgow Update!

This commit is contained in:
Ingy döt Net 2018-08-17 15:15:24 +01:00
parent 22f33d4004
commit 4e2d22a71d
1170 changed files with 15042 additions and 3047 deletions

View file

@ -1,10 +1,13 @@
print '# Number reversal game'
var data, trials = list('123456789'), 0
while data == sorted(data):
var data, trials = list(1..9), 0
while data == sort data:
random.shuffle data
while data != sorted(data):
while data != sort data:
trials += 1
flip = int input '#$trials: LIST: $(join data) Flip how many?: '
data[:flip] = data[!flip:]
flip = int input '#$trials: LIST: ${join data} Flip how many?: '
data[:flip] = data[end:-1:flip]
print '\nYou took $trials attempts to put digits in order!'

View file

@ -0,0 +1,21 @@
SIZE = 9
ordered = (1..SIZE).to_a
shuffled = (1..SIZE).to_a
while shuffled == ordered
shuffled.shuffle!
end
score = 0
until shuffled == ordered
print "#{shuffled} Enter items to reverse: "
next unless guess = gets
next unless num = guess.to_i?
next if num < 2 || num > SIZE
shuffled[0, num] = shuffled[0, num].reverse
score += 1
end
puts "#{shuffled} Your score: #{score}"

View file

@ -1,7 +1,4 @@
# Project : Number reversal game
# Date : 2017/12/02
# Author : Gal Zsolt (~ CalmoSoft ~)
# Email : <calmosoft@gmail.com>
rever = 1:9
leftrever = []