Questions tagged [fizzbuzz]

a game, algorithm and a common programming task of replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz"

Fizzbuzz is a game used to teach children division. Implementing an algorithm for that game is sometimes used as an interview task.

https://en.wikipedia.org/wiki/Fizz_buzz

290 questions
-1
votes
4 answers

can anyone solve this by using list comprehension method like fizzBuzz problem

l=["Sai", "prasad", 1234,12.34, [1,2,3,4]] def filter_int(l): l1=[] for i in l: if type(i)==int or type(i)==float: l1.append(i) elif type(i)==list: for j in i: l1.append(j) return…
-1
votes
3 answers

I am getting an error in taking remainder of range ?why is this happening

n = int(input()) for x in (range(1,n))%2!=0: if x % 3 == 0 and x % 5 == 0: print("SoloLearn") elif x % 3 == 0: print("Solo") elif x % 5 == 0: print("Learn") It gives this error---TypeError: unsupported operand…
Musa Khan
  • 1
  • 2
-1
votes
2 answers

Why does my Fizzbuzz is not outputting correctly?

I'm creating a Fizzbuzz code but there is a problem with the code where the result is like this: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 Here is my code: word = [3,5] ans = ["Fizz","Buzz"] i = 1 j = 0 result = "" while i <= 20: while j <=…
Franc
  • 31
  • 4
-1
votes
5 answers

FizzBuzz using limited number of conditions and StringBuilder

All of you know the trivial fizzbuzz question during the first junior interviews. In my case, it was more than write a solution. There were more requirements: Only two if\else statements. StringBuilder required. No Map, Collection. No ternary…
-1
votes
1 answer

FizzBuzz Function not getting past not a number logic

I put together a fizzbuzz algorithm and for some odd reason the part of the function that should return "not a number" when the value assigned to the input seems to take every input and return "not a number" If I keep the if statement with the NaN…
-1
votes
5 answers

Print a string in console.log instead of a number

I want to print the strings: "Fizz", "Buzz" and "FizzBuzz" in console.log instead of the number they refer to. The point is that until now I can get both number and string, but I don't know how to overcome the number value with the string. For…
Alebacce
  • 63
  • 12
-1
votes
1 answer

FizzBuzz Optimisation | Modulus vs Decrement Operator Performance

This is not the typical debate in FizzBuzz code about how to handle repeated if statement. I believe that it is a matter of personal preference. I am here to ask about the choice of repeated mathematical operation. Usually the solution to a FizzBuzz…
-1
votes
4 answers

Using IntStream to iterate and call a method

How can I call a function to print a value while iterating over a range using an IntStream? public static void fizzBuzz(int n) { // The below does not work as it expects a return value. // Is there a different method that I could use to…
Punter Vicky
  • 15,954
  • 56
  • 188
  • 315
-1
votes
3 answers

Java Solving FizzBuzz problem through converting an ArrayList to an array issue

So I am trying to solve the FizzBuzz problem in Java by altering a String ArrayList and then returning a string array after converting the aforementioned ArrayList to a String array Here's what I have so far: import java.util.ArrayList; public class…
-1
votes
2 answers

Calling solution class in main

I'm trying to mimic a solution to the FizzBuzz problem in Eclipse. The solution class has been given, but I'm not entirely sure on how to run it in main to print the result. In the solution, the list goes up to 15 and prints out the results. If I…
jimmyg8085
  • 13
  • 2
-1
votes
4 answers

What is the difference between return and console.log()

I get different outputs when I use console.log() in my function vs when I use the return statement. When I run the function with the return statement I get a one word output which is one of the following: 'fizz' 'buzz' or 'fizzbuzz', but when I run…
jq712
  • 5
  • 6
-1
votes
4 answers

Difficulty with Fizz Buzz

I'm a high highschool student taking an online course for python, and one of the assignments is to create a function similar to fizz buzz, except instead of "fizz" and "buzz", they simply use "three" and "five". I wrote a function but unfortunately…
-1
votes
4 answers

foo bar not printing the correct output

Currently my code will display 1 through 100 but will not actually print out the case statements when it is divisible by 3 or 5 or both ....What am I doing wrong here? def display(item_count) n = 1 while n <= item_count case n when n %…
Nabeel A.Rahman
  • 181
  • 3
  • 14
-1
votes
1 answer

Beginner creating fizzbuzz function

This code is supposed to output fizz if number is divisible by 3, buzz if divisible by 5 and fizzbuzz if divisible by 3 and 5. Although I'm a bit unfamiliar with defining my own function and using the return appropriately. How do I remove the last…
Alex Vincent
  • 97
  • 1
  • 3
  • 10
-1
votes
2 answers

Can FizzBuzz be done using arithmetic only?

I'm trying to find a way to do the FizzBuzz problem (print all numbers between 1 and 100, print Fizz if it's a multiple of 3, print Buzz if it's a multiple of 5 and FizzBuzz if it's both) using arithmetic only. It's fairly easy if you do it using…
Auh
  • 145
  • 11