diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:02:39 +0200 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-10-29 23:02:39 +0200 |
commit | e7c9108b95e39d7ea5a29ae06d619c4727f11027 (patch) | |
tree | 237261eef3afd0720be77dbcbb9599fa66a24b67 /2015/14/puzzle-1.bc |
Initial commit
Diffstat (limited to '2015/14/puzzle-1.bc')
-rw-r--r-- | 2015/14/puzzle-1.bc | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/2015/14/puzzle-1.bc b/2015/14/puzzle-1.bc new file mode 100644 index 0000000..d36cafd --- /dev/null +++ b/2015/14/puzzle-1.bc @@ -0,0 +1,25 @@ +/* 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 +} |