World Cup group stage: Difference between revisions

m
→‎version 2, generated game sets: added capability to simulate Cricket World Cup, added title and indexing to show what is being displayed, boxed and added a grid for the wide displays of points.
m (→‎version 2, generated game sets: removed a comment from the REXX section header.)
m (→‎version 2, generated game sets: added capability to simulate Cricket World Cup, added title and indexing to show what is being displayed, boxed and added a grid for the wide displays of points.)
Line 827:
............................................................................................................. !-->
<lang rexx>/*REXX pgm calculates world cup standings based on the number of games won by the teams.*/
parse arg teams win . /*obtain optional argument from the CL.*/
if teams=='' | teams=="," then teams= 4 /*Not specified? Then use the default.*/
setsif win==0;'' | win=="," then win= 3; /* " gs= " /*the" number of" sets (so" far). " */
sets=0; gs= /*the number of sets (so far). /* [↓] tidy up trailing commas, add []*/
do j=1 for teams
do k=j+1 to teams; sets= sets+1 /*bump the number of game sets. */
Line 846 ⟶ 847:
if r==2 then @.A= @.A + win /*win for left─most team. */
end /*j*/
call sort 4teams
do t=1 for 4teams; tm= t - 1; _= @.t
points.tm._ = points.tm._ + 1; z= max(z, length(points.tm._) )
end /*t*/
end /*until*/
$.=
do j=0 for teams+6
do j=0 for 10; do k=0 for 4; $.k= $.k || right(points.k.j, z)', '; end /*k*/
end /*j*/ do k=0 for teams; $.k= $.k || right(points.k.j, z)'│ '; end /* [↑] last value will have extra ", "k*/
end /*j*/
/* [↓] tidy up trailing commas, add []*/
say; do m=3 by -1 for 4; say ' ['strip( strip($.m, "T"), , ',')"]"; end /*m [↓] build grid line for the box*/
L=length($.1) -2; $$= translate( translate( left($.1, L), , 0123456789), '─', " ")
say left('', 15) center('points', L) /*display the boxed title. */
say left('', 15) "╔"translate($$, '═╤', "─│")'╗' /*display the bottom sep for title.*/
p=0
do m=teams-1 by -1 for teams; p = p+1
say right('('th(p) "place)", 14) " ║"left($.m, L)'║'
if m>0 then say right(' ', 14) " ╟"translate($$, '┼', "│")'╢'
end /*m*/
say left('', 15) "╚"translate($$, '═╧', "─│")'╝' /*display the bottom sep for title.*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
Line 871 ⟶ 881:
if @.k<@.j then parse value @.j @.k with @.k @.j
end /*k*/
end /*j*/; return</lang>
/*──────────────────────────────────────────────────────────────────────────────────────*/
th: arg th; th=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>
4 teams, 6 game sets: 12 13 14 23 24 34
 
 
[ 0, 0, 0, 1, 14, 148, 152, 306, 0, 108]
[ 0, 0, 4, 33, 338, 172, 164, 18, 0, 0] points
╔═══╤════╤════╤════╤════╤════╤════╤════╤════╤════╗
[ 0, 18, 136, 273, 290, 4, 8, 0, 0, 0]
(1st [108,place) 306, 184, 125, 0│ 6, 0│ 0, 0│ 0, 1│ 0,14│ 148│ 152│ 0,306│ 0]0│ 108║
╟───┼────┼────┼────┼────┼────┼────┼────┼────┼────╢
(2nd place) ║ 0│ 0│ 4│ 33│ 338│ 172│ 164│ 18│ 0│ 0║
╟───┼────┼────┼────┼────┼────┼────┼────┼────┼────╢
(3rd place) ║ 0│ 18│ 136│ 273│ 290│ 4│ 8│ 0│ 0│ 0║
╟───┼────┼────┼────┼────┼────┼────┼────┼────┼────╢
(4th place) ║108│ 306│ 184│ 125│ 6│ 0│ 0│ 0│ 0│ 0║
╚═══╧════╧════╧════╧════╧════╧════╧════╧════╧════╝
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; &nbsp; <tt> 5 </tt>}}
Line 885 ⟶ 904:
5 teams, 10 game sets: 12 13 14 15 23 24 25 34 35 45
 
 
[ 0, 0, 0, 1, 37, 1522, 5049, 14496, 14106, 9420]
[ 0, 0, 12, 333, 4269, 14706, 15813, 18156, 3378, 2220] points
╔═════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╤══════╗
[ 0, 162, 2406, 8241, 21483, 16566, 7821, 2334, 12, 24]
(1st place) ║ 0│ 0│ 0│ 0│ 1│ 74│ 2409│ 11520│ 16230│ 10860│ 14310║
[ 2916, 11502, 15078, 14753, 12119, 2198, 477, 6, 0, 0]
╟─────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────╢
(2nd place) ║ 0│ 0│ 0│ 5│ 181│ 7314│ 15609│ 26400│ 5610│ 3660│ 270║
╟─────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────╢
(3rd place) ║ 0│ 0│ 30│ 825│ 10401│ 25794│ 16119│ 5790│ 30│ 60│ 0║
╟─────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────╢
(4th place) ║ 0│ 270│ 3990│ 13185│ 28871│ 10414│ 2289│ 30│ 0│ 0│ 0║
╟─────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────╢
(5th place) ║ 3645│ 14310│ 17850│ 15145│ 7931│ 144│ 24│ 0│ 0│ 0│ 0║
╚═════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╧══════╝
</pre>
{{out|output|text=&nbsp; when using the input of: &nbsp; &nbsp; <tt> 6 </tt>}}
Line 894 ⟶ 922:
6 teams, 15 game sets: 12 13 14 15 16 23 24 25 26 34 35 36 45 46 56
 
 
[ 0, 0, 0, 3, 330, 24741, 227610, 942366, 2364504, 2598813]
[ 0, 0, 108, 7011, 126666, 905661, 2219454, 3997638, 3749148, 1891485] points
╔═══════╤════════╤════════╤════════╤════════╤════════╤════════╤════════╤════════╤════════╤════════╤════════╗
[ 0, 4374, 104760, 572085, 2028906, 3848769, 3608766, 2964474, 944640, 230391]
(1st place) ║ 0│ 0│ 0│ 0│ 0│ 1│ 434│ 68910│ 1049904│ 2333079│ 4056210│ 3149820║
[ 236196, 1176606, 2257092, 2963841, 3748998, 2542905, 1030050, 362382, 27588, 3231]
╟───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────╢
(2nd place) ║ 0│ 0│ 0│ 0│ 6│ 1165│ 207308│ 1803570│ 5266944│ 3648879│ 2822850│ 392580║
╟───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────╢
(3rd place) ║ 0│ 0│ 0│ 45│ 4926│ 366445│ 2580578│ 6232110│ 3900744│ 1055889│ 206550│ 540║
╟───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────╢
(4th place) ║ 0│ 0│ 540│ 34965│ 623466│ 3793085│ 5521498│ 3916830│ 410364│ 47889│ 270│ 0║
╟───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────╢
(5th place) ║ 0│ 10935│ 261360│ 1395225│ 4446336│ 5645615│ 2210128│ 378300│ 864│ 144│ 0│ 0║
╟───────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────┼────────╢
(6th place) ║ 354294│ 1760535│ 3281040│ 3884175│ 3782616│ 1176803│ 108874│ 570│ 0│ 0│ 0│ 0║
╚═══════╧════════╧════════╧════════╧════════╧════════╧════════╧════════╧════════╧════════╧════════╧════════╝
</pre>
<!-- 7 teams with 21 game sets is just a bridge too far. !-->