DEV Community

Abubakar Sadiq Ismail
Abubakar Sadiq Ismail

Posted on

Day 6 I4G 10DaysOfCodeChallenge

Problem 6: Fizz Buzz Multithreaded.
Category Medium.
Given a class FizzBuzz, with 4 methods fizz (which print fizz),buzz (which print buzz),fizzBuzz (which print fizzBuzz), and printNumber( print a number).
FizzBuzz will be initialized with an integer n.
All four methods will be called from different threads.
the result of running all four threads.
Should be based on i which is 1 to n;

if i % 3 and i % 5 is 0;
return fizzBuzz
if i % 3 is 0;
return fizz
if i % 5 is 0;
return buzz
else if i % 3 and i % 5 is not 0;
return i
.
This problem as well Javascript is not in the programming language because it's single threaded.
Hence I use python to create another threads when all the threads are started.
When the last thread is started.
Iterate through n.
check the condition and call the appropriate thread or printNumber with i

Problem
Solution Implementation

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay