Round-robin tournament schedule: Difference between revisions
Content added Content deleted
(Added Easylang) |
imported>Thebeez |
||
Line 1,285: | Line 1,285: | ||
</pre> |
</pre> |
||
=={{header|uBasic/4tH}}== |
|||
{{trans|FreeBASIC}} |
|||
<syntaxhighlight lang="ubasic-4th"> |
|||
Print "Twelve teams" |
|||
Proc _Roundrob(12) |
|||
Print |
|||
Print "Nine teams with byes" |
|||
Proc _Roundrob(9) |
|||
End |
|||
' helper function to allow byes to be printed intelligently |
|||
_Nob |
|||
Param (3) |
|||
Local (1) |
|||
d@ = Iif (a@ > 9, " ", "") |
|||
If a@ = b@ * c@ Then Return (Join (d@, "B")) |
|||
Return (Iif (b@ < 10, Join(d@, Str(b@)), Str(b@))) |
|||
_Roundrob |
|||
Param (1) |
|||
Local (5) |
|||
b@ = 0 |
|||
' if there is an odd number of competitors |
|||
If a@ % 2 = 1 Then b@ = 1 : a@ = a@ + 1 |
|||
' make note of this fact and treat the tournament |
|||
For d@ = 1 To a@ ' as having one more competitor |
|||
@(d@) = d@ ' initial population of the array with numbers 1-n |
|||
Next |
|||
For c@ = 1 To a@-1 |
|||
Print Using "Round __: ";c@; |
|||
For d@ = 1 To a@/2 ' print the pairings according to the scheme |
|||
' 1 2 3 4 |
|||
' 5 6 7 8 |
|||
Print "("; Show(FUNC(_Nob (a@, @(d@), b@)));" - "; |
|||
Print Show(FUNC(_Nob (a@, @(d@+a@/2), b@)));") "; |
|||
Next |
|||
Print |
|||
' now move positions 2-n around clockwise |
|||
e@ = @(a@/2) ' need to track two temporary variables |
|||
f@ = @(a@/2+1) |
|||
' top row |
|||
For d@ = a@/2 To 3 Step -1 |
|||
@(d@) = @(d@-1) |
|||
Next |
|||
' bottom row |
|||
For d@ = a@/2+1 To a@-1 |
|||
@(d@) = @(d@+1) |
|||
Next |
|||
@(a@) = e@ ' fill in the ones that "jumped" between rows |
|||
@(2) = f@ |
|||
Next |
|||
Return |
|||
</syntaxhighlight> |
|||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |