World Cup group stage: Difference between revisions

m
Line 216:
{{trans|Java}}
ELENA 3.4 :
<lang elena>import system'routines.;
import extensions.;
public programsingleton =program
{
static games := (new string[]{"12", "13", "14", "23", "24", "34").};
static results := "000000".;
nextResult()
[{
if (results=="222222") [{ ^ false ].};
results := (results .toInt(3) + 1) toLiteral.toString(3); .padLeft($48, 6).;
^ true
]}
closure()
[{
var points := IntMatrix new IntMatrix(4, 10).;
 
doUntil(program.nextResult().Inverted)
[{
var records := new int[](4);
for(int i := 0, i < 6, i "1"+= [1)
[
var records := IntArray new(4).{
(var r := results[i]) =>;
[ r =>
"2" [{ records[games[i][0] .toInt() - 49] += 3 ];}
]. "1" {
records[games[i][0] .toInt() - 49] += 1.;
records[games[i][1] .toInt() - 49] += 1
}
"0" [{ records[games[i][1] .toInt() - 49] += 3 ].};
[ };
0records till:6= dorecords.ascendant(:i);
[
(results[i]) =>
"2" [ records[games[i][0] toInt - 49] += 3 ];
"1" [
records[games[i][0] toInt - 49] += 1.
records[games[i][1] toInt - 49] += 1
];
"0" [ records[games[i][1] toInt - 49] += 3 ].
].
recordsfor(int i := 0, i <= 3, i += 1) { points[i][records[i]] += 1 ascendant.}
].};
new Range(0, repeatTill:4; zip:).zipForEach(new string[]{"1st", "2nd", "3rd", "4th")}, forEach(:i:,l)
0 to:3 do(:i)[ (points[i][records[i]]) += 1 ].
] {
console .printLine(l,": ", points[3 - i] .toArray())
] repeatWhile:$(self nextResult).
});
}
0 repeatTill:4; zip:("1st", "2nd", "3rd", "4th") forEach(:i:l)
}.</lang>
[
arrayConvertorEx convert(points[3 - i]).
console printLine(l,": ", points[3 - i] toArray)
].
]
}.</lang>
{{out}}
<pre>
Anonymous user