Created
May 15, 2018 16:20
-
-
Save skade/8049601bc7469f94c5d7d947d5229e55 to your computer and use it in GitHub Desktop.
FastBuzz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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