blob: 1ccab066fc42b61b094de1fd128a2530c59ac806 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/* Return the largest element from array `a` of length `l` */
define max(a[], l) {
auto m, i
for (i = 0; i < l; i++) {
if (a[i] > m)
m = a[i]
}
return m
}
/* Return the kilometers traveled by a raindeer that flys with speed `s` km/s
* for `t` seconds before needing to rest for `r` seconds.
*/
define calc(s, t, r) {
auto a, d
while (d + t <= 2503) {
a += s * t
d += t + r
}
if (d < 2503)
a += s * (2503 - d)
return a
}
|