Horse racing: Difference between revisions

Content added Content deleted
(Created a new draft task, Horse racing, and added a Wren solution.)
 
m (Minor tweaks.)
Line 55: Line 55:
1. Weights carried are expressed in stones and pounds (traditional in US and UK racing) where 1 stone equals 14 pounds.
1. Weights carried are expressed in stones and pounds (traditional in US and UK racing) where 1 stone equals 14 pounds.


2. The distances are the distances between horses at the finish of the race.
2. The distances are the actual distances between horses at the finish of the race.


3. All races are run at 1 mile in similar going and weather conditions and the time shown is the time taken by the winner to run the race.
3. All races are run at 1 mile in similar going and weather conditions and the time shown is the time taken by the winner to run the race.
Line 134: Line 134:
var dist = 0
var dist = 0
if (p > 1) dist = (l[x-1].value[0] - l[x].value[0]) * 0.5
if (p > 1) dist = (l[x-1].value[0] - l[x].value[0]) * 0.5
var pos = (p == 1 || dist > 0) ? p : p - 1
var pos = (p == 1 || dist > 0) ? p.toString : (p - 1).toString + "="
var sx = l[x].value[1] ? "colt" : "filly"
var sx = l[x].value[1] ? "colt" : "filly"
Fmt.print("$-2d $s $s $3.1f $s", pos, l[x].key, wt, dist, sx)
Fmt.print("$-2s $s $s $3.1f $s", pos, l[x].key, wt, dist, sx)
p = p + 1
p = p + 1
}
}
Line 161: Line 161:
6 E 9.00 0.5 colt
6 E 9.00 0.5 colt
7 B 8.11 1.0 filly
7 B 8.11 1.0 filly
7 D 8.11 0.0 filly
7= D 8.11 0.0 filly
9 C 9.00 1.0 colt
9 C 9.00 1.0 colt
10 G 9.00 0.5 colt
10 G 9.00 0.5 colt