Skip to content
Wish Lists Cart
0 items

Fizz Buzz Game

06 Nov 2023
Fizz Buzz Game

What is FizzBuzz?

Fizzbuzz is a widely known programming problem that serves as both a learning tool and a coding challenge. It’s a simple exercise where the task is to count from 1 to a specified number, replacing multiples of 3 with “Fizz,” multiples of 5 with “Buzz,” and numbers divisible by both 3 and 5 with “FizzBuzz.” The primary goal of this exercise is to reinforce essential programming concepts like loops, conditional statements, and algorithmic thinking. It is often used as a basic assessment in coding interviews to gauge a candidate’s coding skills, problem-solving abilities, and familiarity with fundamental programming constructs.

FizzBuzz Game

The Fizz Buzz game is a playful and interactive way to teach divisibility rules, commonly used in educational settings. It is often employed as a teaching tool for children or beginners to help them grasp the concepts of multiplication and remain engaged in the learning process. The game involves participants sitting in a circle, taking turns counting numbers starting from 1. When a player encounters a number divisible by 3, they say “Fizz,” for numbers divisible by 5, they say “Buzz,” and for numbers divisible by both 3 and 5, they say “FizzBuzz.” This game fosters an understanding of basic arithmetic principles while making learning math enjoyable and participatory.

What Is Fizzbuzz Used For?

Fizzbuzz is primarily used as a teaching and assessment tool in computer science education and programming interviews. It serves as a simple yet effective way to evaluate a programmer’s ability to think logically, apply conditional logic, and create code that follows a set of rules. In educational settings, Fizzbuzz helps students grasp fundamental programming concepts and enhances their problem-solving skills. In coding interviews, it acts as a quick test of a candidate’s coding proficiency and algorithmic thinking. Beyond education and assessment, Fizzbuzz doesn’t have substantial real-world applications but remains a valuable exercise for honing coding skills.

Details and Algorithm

  1. Players start counting from 1.
  2. If the number is divisible by 3, they say “Fizz” instead.
  3. If the number is divisible by 5, they say “Buzz” instead.
  4. If the number is divisible by both 3 and 5, they say “Fizz Buzz.”
  5. If none of these conditions apply, they say the number itself.

The game continues, and players take turns following these rules. It’s often used to teach programming concepts and assess coding skills in interviews. Here you see the algorithm of this game.

Components

1xPicoBricks

Wiring Diagram

MicroBlocks Codes of Fizz Buzz

MicroPython Codes of Fizz Buzz


from time import sleep
from machine import Pin
from machine import I2C
from picobricks import SSD1306_I2C
from picobricks import WS2812
import time

i2c = I2C(0, scl=Pin(5), sda=Pin(4), freq=200000)
oled = SSD1306_I2C(128, 64, i2c, addr=0x3c)
ws2812 = WS2812(6, brightness = 1)

def write_fizzbuzz():
    global i
    oled.fill(0)
    oled.text("{}".format("FizzBuzz"), 0, 25)
    oled.show()
    ws2812.pixels_fill((255, 0, 0))
    ws2812.pixels_show()
    time.sleep((0.75))

def write_fizz():
    global i
    oled.fill(0)
    oled.text("{}".format("Fizz"), 0, 25)
    oled.show()
    ws2812.pixels_fill((51, 255, 51))
    ws2812.pixels_show()
    time.sleep((0.75))

def write_i():
    global i
    oled.fill(0)
    oled.text("{}".format(i), 0, 25)
    oled.show()
    ws2812.pixels_fill((0 ,0 ,0 ))
    ws2812.pixels_show()
    time.sleep((0.75))

def write_buzz():
    global i
    oled.fill(0)
    oled.text("{}".format("Buzz"), 0, 25)
    oled.show()
    ws2812.pixels_fill((51, 51, 255))
    ws2812.pixels_show()
    time.sleep((0.75))

oled.fill(0)
while True:
    for i in range((101)):
        if (i % 15) == (0):
            write_fizzbuzz()
        elif (i % 3) == (0):
            write_fizz()
        elif (i % 5) == (0):
            write_buzz()
        else:
            write_i()
    oled.fill(0)
    oled.text("{}".format("END"), 0, 25)
    oled.show()
    time.sleep((3))

PicoBlockly Codes of PicoBricks

You can explore other fun projects you can create with PicoBricks by clicking here!

Arduino C Codes for PicoBricks


#include <Adafruit_NeoPixel.h>
#define PIN 6 
#define NUMPIXELS 1
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
#include <Wire.h>
#include "ACROBOTIC_SSD1306.h"

void write_fizzbuzz() {
  oled.clearDisplay();
  oled.setTextXY(3, 1);
  oled.putString("FizzBuzz");
  pixels.setPixelColor(0,pixels.Color(255,0,0));
  pixels.show(); 
  delay(750);
}

void write_fizz() {
  oled.clearDisplay();
  oled.setTextXY(3, 1);
  oled.putString("Fizz");
  pixels.setPixelColor(0,pixels.Color(51,255,255));
  pixels.show(); 
  delay(750);
}

void write_buzz() {
  oled.clearDisplay();
  oled.setTextXY(3, 1);
  oled.putString("Buzz");
  pixels.setPixelColor(0,pixels.Color(51,51,255));
  pixels.show(); 
  delay(750);
}

void write_i(int i) {
  oled.clearDisplay();
  oled.setTextXY(3, 1);
  oled.putString(String(i));
  pixels.setPixelColor(0,pixels.Color(0,0,0));
  pixels.show(); 
  delay(750);
}

void setup() {
  //define dht sensor and Oled screen
  Serial.begin(115200);
  Wire.begin();  
  oled.init();                      
  oled.clearDisplay();
  pixels.begin();
  pixels.clear(); 
}

void loop() {
  oled.clearDisplay();

  for (int i = 1; i <= 100; i++) {
    if (i % 15 == 0) {
      write_fizzbuzz();
    } else if (i % 3 == 0) {
      write_fizz();
    } else if (i % 5 == 0) {
      write_buzz();
    } else {
      write_i(i);
    }
  }
  oled.clearDisplay();
  oled.setTextXY(3,1);
  oled.putString("THE END");
  delay(3000);
}
fizzbuz game on rasperry
ALT TAG
Prev Post
Next Post

Thanks for subscribing!

This email has been registered!

Shop the look
Choose Options

Edit Option

Have Questions?

Back In Stock Notification

Compare

Product SKURatingDescription Collection Availability Product Type Other Details
this is just a warning
Login
Shopping Cart
0 items
Same Day Shipping No Extra Costs
Easy Returns Guarantee Return with Ease
Secure Checkout Secure Payment