Get the latest tech news
Optimizing FizzBuzz in Rust
Optimizing FizzBuzz in Rust for fun and profit. Contribute to nrposner/fizzcrate development by creating an account on GitHub.
He expanded the if-else chain: I asked him to find a way to do it without explosively increasing the number of necessary checks with each new term added. The simple act of removing newlines, printing the entire buffer as one continuous, illegible block instead of allocating a new line to each number reduces our runtime by roughly 80%. Note that the single-threaded version on 100 is slower than the 900ns we time earlier: mainly because this one is actually saving the contents of each loop and collecting them into a vector.
Or read this on Hacker News