World Cup group stage: Difference between revisions

→‎version 2, generated game sets: optimized the nextResult function.
m (→‎version 2, generated game sets: aligned some statements better.)
(→‎version 2, generated game sets: optimized the nextResult function.)
Line 841:
end /*j*/
end /*k*/
z = 1; setLimit= copies(2, sets) /*Z: max length of any number shown. */
say teams ' teams, ' sets " game sets: " gs /*display what's being used for calcs. */
results = copies(0, sets); say /*start with left-most teams all losing*/
Line 853:
end /*j*/
call sort teams
do t=1 for teams; tm= t - 1; _= @.t
points.tm._ = points.tm._ + 1; z= max(z, length(points.tm._) )
end /*t*/
Line 873:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
nextResult: procedure expose results sets; if results==copies(2, sets)setLimit then return 0
res= 0 /* [↓] do arithmetic in base three.*/
do jk=1 for sets; res= res * 3 + substr(results, jk, 1)
end /*j*/
results=; res= res + 1
Line 888:
end /*j*/; return
/*──────────────────────────────────────────────────────────────────────────────────────*/
th: arg th; th=return (th/1;) return th|| word('th st nd rd', 1 +(th//10) *(th//100%10\==1)*(th//10<4))</lang>
{{out|output|text=&nbsp; when using the default input of: &nbsp; &nbsp; <tt> 4 </tt>}}
<pre>