Number reversal game: Difference between revisions

Number reversal game in Yabasic
(Added Quackery.)
(Number reversal game in Yabasic)
Line 4,876:
5 8 3 1 4 9 7 2 6
</pre>
 
=={{header|Yabasic}}==
<lang yabasic>// Rosetta Code problem: https://www.rosettacode.org/wiki/Number_reversal_game
// by Jjuanhdez, 06/2022
 
print "Given a jumbled list of the numbers 1 to 9, "
print "you must select how many digits from the left "
print "to reverse. Your goal is to get the digits in "
print "order with 1 on the left and 9 on the right.\n"
 
dim nums(10)
dim a(10)
intentos = 0: denuevo = true: colum = 6
 
//valores iniciales
for i = 1 to 9
nums(i) = i
next i
 
for i = 9 to 2 step -1
n = int(ran(i)) + 1
if n <> i then
a(i) = nums(i)
nums(i) = nums(n)
nums(n) = a(i)
fi
next i
 
repeat
if intentos < 10 print " ";
print intentos, ": ";
for i = 1 to 9
print nums(i), " ";
next i
 
if not denuevo break
 
input " -- How many do we flip " volteo
if volteo < 0 or volteo > 9 volteo = 0
 
for i = 1 to int(volteo / 2)
a(i) = nums(volteo - i + 1)
nums(volteo - i + 1) = nums(i)
nums(i) = a(i)
next i
 
denuevo = false
//comprobamos el orden
for i = 1 to 8
if nums(i) > nums(i + 1) then
denuevo = true
break
fi
next i
 
if volteo > 0 intentos = intentos + 1
until false
print "\n\n You needed ", intentos, " attempts."
end</lang>
 
 
=={{header|zkl}}==
2,130

edits