Skip to content

Instantly share code, notes, and snippets.

@skade skade/fast_buzz.rs
Created May 15, 2018

Embed
What would you like to do?
FastBuzz
extern crate itoa;
use std::io::Write;
use std::io::BufWriter;
pub fn main() {
let stdout = std::io::stdout();
let mut stdout = BufWriter::new(stdout);
let mut acc = 810092048;
for i in 1..100_000_000_u32 {
let c = acc & 3;
match c {
0 => {
itoa::write(&mut stdout, i).unwrap();
stdout.write(b"\n").unwrap();
},
1 => {
stdout.write(b"Fizz\n").unwrap();
},
2 => {
stdout.write(b"Buzz\n").unwrap();
},
3 => {
stdout.write(b"FizzBuzz\n").unwrap();
},
_ => { unimplemented!() }
}
acc = acc >> 2 | c << 28
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.