2 "Morra" Binary

# 2 "Morra" Binary

• Thursday, January 22, 2009 1:58 PM

Is this code the best ?

'Programma MORRA 2
'Inizializza l'array  (V) a 0

N
=16
For i=1 to N

Array
.SetValue("V",i,0)
EndFor

TextWindow
.Write("Gioca 0.., Q per finire:")
G=TextWindow
i
=1
While G
<>"Q"

x
=0

if (Array.GetValue("V",i)<=Array.GetValue("V",i+1)) then
x=-1

EndIf
y=Math
.Remainder(G,2)

TextWindow.Write(-x+","+y
+" HA VINTO ")

T
=0

IF x=-y
Then
T
=-1

EndIf

TextWindow.Write(text.GetSubText("UC",-t
,1))

tc=tc-
t
tu=tu+t
+1

i=i+
y
TextWindow.Write(" !  Vittorie: "+tc+">C  "+tu
+">U .. RiGioca :")

Array.SetValue("V",i,Array.GetValue("V",i
)+1)

i=2*Math.Remainder(i
,8)

G=TextWindow
EndWhile

### All Replies

• Tuesday, October 30, 2012 8:07 AM
Owner

Did you ever publish this?

Thanks!

Ed Price (a.k.a User Ed), SQL Server Customer Program Manager (Blog, Twitter, Wiki)

• Tuesday, October 30, 2012 1:55 PM

```'Program MORRA 2

TextWindow.Write("Play 0..5, Q to finish:")
tc = 0
tu = 0
While (nu <> "Q") And (nu <> "q")
nc = Math.GetRandomNumber(6) - 1
oc = Math.Remainder(nc, 2)
ou = Math.Remainder(nu, 2)
TextWindow.Write(nc + "(" + oc + ")," + nu + "(" + ou + ") ")
If oc = ou Then
TextWindow.Write("C")
tc = tc + 1
Else
TextWindow.Write("U")
tu = tu + 1
EndIf
TextWindow.Write(" WON!  Wins: " + tc + "=C  " + tu + "=U .. Replay:")