Skip to content
TheChatArchiveThe Chat Archive
o4-mini-2025-04-16· OpenAIHugging Face LMArena Human Preference 140K

wrtie fizz buzz in rust

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Coherecommand-a-03-2025’s answer.
  1. User

    wrtie fizz buzz in rust

  2. Assistant

    Here’s a simple FizzBuzz implementation in Rust (printing 1 through 100). Copy this into a main.rs and run with cargo run or rustc main.rs && ./main.

    fn main() {
        for n in 1..=100 {
            match (n % 3, n % 5) {
                (0, 0) => println!("FizzBuzz"),   // divisible by both 3 and 5
                (0, _) => println!("Fizz"),       // divisible by 3
                (_, 0) => println!("Buzz"),       // divisible by 5
                _      => println!("{}", n),      // neither: print the number
            }
        }
    }
    

    Explanation:

    • 1..=100 is an inclusive range from 1 to 100.
    • The match checks the remainders of dividing by 3 and 5:
      • (0, 0) means divisible by both → prints “FizzBuzz”
      • (0, _) means divisible by 3 only → prints “Fizz”
      • (_, 0) means divisible by 5 only → prints “Buzz”
      • _ catches all other cases → prints the number itself.

    If you’d like to customize the range or output style (e.g. return a Vec<String> instead of printing), just let me know! 🎉

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.