World Cup group stage: Difference between revisions

m
(Added Perl example)
Line 215:
=={{header|Elena}}==
{{trans|Java}}
ELENA 3.2.14 :
<lang elena>import system'routines.
import extensions.
 
public program =
{
static games := ("12", "13", "14", "23", "24", "34").
static results := "000000".
nextResult
[
if (results=="222222") [ ^ false ].
results := (results toInt(3) + 1) toLiteral(3); padLeft($48, 6).
^ true
]
closure
// program entry point
eval
[
var points := IntMatrix new(4, 10).
[
var r := results.
var records := IntArray new(4).
0 till:6 do(:i)
[
Line 253 ⟶ 251:
"0" [ records[games[i][1] toInt - 49] += 3 ].
].
records := records ascendant.
0 to:3 do(:i)[ (points[i][records[i]]) += 1 ].
] repeatUntilrepeatWhile:$($self nextResult).
0 repeatTill:4; zip:("1st", "2nd", "3rd", "4th") forEach(:i:l)
[
consolearrayConvertorEx printLineconvert(l,": ", points[3 - i]).
console printLine(l,": ", points[3 - i] toArray)
].
]
Anonymous user