Sanely optimized fizzbuzz
elronnd at elronnd.net
Sat Oct 30 21:12:07 UTC 2021
On Saturday, 30 October 2021 at 11:35:10 UTC, Brian Callahan
> My machine doesn't have enough memory to do CTFE for values
> larger than 15000. If it did, then I would have done that. The
> rules do not state that you cannot pre-calculate. On my
> machine, the pre-calculating approach gives a significant
> throughput improvement.
1. That doesn't change the fact that the code you posted is
meaningless as a benchmark.
2. If such an approach is valid, then one may use 'cat' as a fast
fizzbuzz implementation. Clearly that is not very interesting or
useful. The question is about _generating_ fizzbuzz, not
reproducing arbitrary text. 'The rules do not state that you
cannot pre-calculate' is equivocation; such an approach is
clearly outside of its spirit.
3. In the limit, the pregeneration approach will be bottlenecked
by disc, which is slow.
4. Pregeneration cannot reach the limit anyway, because disc
space is limited (streams are not).
More information about the Digitalmars-d