7 kyu

Fizz Buzz

2,171 of 26,360stephenyu
Description
Loading description...
Algorithms
Fundamentals
Arrays
  • Please sign in or sign up to leave a comment.
  • hobovsky Avatar

    This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/226.
    Please join the discussion to help us identify duplicate kata and retire them.

  • ejini战神 Avatar

    Description should be language-agnostic

  • big_M Avatar

    i fizz buzz maked 🌨 ❄❄❄ ☃ Translation Dart ░░░░░░░░░░░░░░▄▄░░░██░░░▄▄░░░░░░░░░░░░░░ ░░░░░░░░░░▄▄░░███▄░██░▄███░░▄▄░░░░░░░░░░ ░░░░░▄░░░░██░░░▀████████▀░░███░░░▄░░░░░░ ░░░░░▀██▄░██░░░░░▀████▀░░░░███▄███░░░░░░ ░░░░░░▀█████░░░░░░░██░░░░░░█████▀░░░░░░░ ░░░█████████▄░░░░░░██░░░░░░██████████░░░ ░░░░▀▀▀▀▀▀▀▀██▄░░░░██░░░░▄██▀░░░░░░░░░░░ ░███▄░░░░░░░░▀██▄░░██░░▄██▀░░░░░░░░▄██▀░ ░░▀███▄░░░░░░░░▀████████▀░░░░░░░░▄███▀░░ ▄▄▄▄████▄▄▄▄▄▄▄▄████████▄▄▄▄▄▄▄▄████▄▄▄▄ ▀▀▀▀████▀▀▀▀▀▀▀▀████████▀▀▀▀▀▀▀▀████▀▀▀▀ ░░▄███▀░░░░░░░░▄████████▄░░░░░░░░▀███▄░░ ░▄██▀░░░░░░░░▄██▀░░██░░▀██▄░░░░░░░░▀███░ ░░░░░░░░░░░▄██▀░░░░██░░░░▀██▄▄▄▄▄▄▄▄░░░░ ░░░██████████░░░░░░██░░░░░░▀█████████░░░ ░░░░░░░▄█████░░░░░░██░░░░░░░█████▄░░░░░░ ░░░░░░███▀███░░░░▄████▄░░░░░██░▀██▄░░░░░ ░░░░░░▀░░░███░░▄████████▄░░░██░░░░▀░░░░░ ░░░░░░░░░░▀▀░░███▀░██░▀███░░▀▀░░░░░░░░░░ ░░░░░░░░░░░░░░▀▀░░░██░░░▀▀░░░░░░░░░░░░░░

  • ejini战神 Avatar

    No random tests in Haskell

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • christosf360 Avatar

    This comment has been hidden.

  • christosf360 Avatar

    Hello everyone,

    New to CodeWars and relatively new to (python) programming. I think the site has huge potential to help people like me with their programming skills, however, I seem to have stumbled at the first hurdle. I tried to use a very simple "input()" command and when I press the test button to test I get an end of line error. When I run the same code in another python editor, external to CodeWars, the command works and no error is produced. Any advice please? It feels that this may be something fundamentaly wrong with the way I am using the site and its resources. The code I tried to run was: number = input('Enter your number:'), many thanks!

  • 4500zenja1 Avatar

    Scala translation with upgrade to 3.0

  • vglampard Avatar

    My JS solution is passing the preliminary tests for 10 numbers, one number, and one random 1-100 integer, but for the 30 and 100 numbers tests that run when I try to attempt the kata it's returning a fail. Here's the error code for 30, and it's the same with 100 - i.e., it looks like the expected and actual results are identical! Am I missing something simple here?

    Thanks in advance! (edited to try and get the actual and expected arrays to align so they can be more easily compared...)

    Fails with 30 numbers!: expected

    '[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"Fizzbuzz",16,17,"Fizz",19,"Buzz","Fizz",22,23,"Fizz","Buzz",26,"Fizz",28,29,"Fizzbuzz"]' to equal '[1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz",11,"Fizz",13,14,"FizzBuzz",16,17,"Fizz",19,"Buzz","Fizz",22,23,"Fizz","Buzz",26,"Fizz",28,29,"FizzBuzz"]'

  • kyinness Avatar

    This comment has been hidden.

  • mattglwilliams Avatar

    This comment has been hidden.

  • lax0248917 Avatar

    Test throws a systems error with test.js when using javascript to solve kata. /home/codewarrior/node/test.js:49 }); ^

    SyntaxError: Unexpected token ) at new Script (vm.js:80:7) at createScript (vm.js:274:10) at Object.runInThisContext (vm.js:326:10) at Module._compile (internal/modules/cjs/loader.js:664:28) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at /home/codewarrior/node/node_modules/.registry.npmjs.org/mocha/5.2.0/node_modules/mocha/lib/mocha.js:250:27 at Array.forEach () at Mocha.loadFiles (/home/codewarrior/node/node_modules/.registry.npmjs.org/mocha/5.2.0/node_modules/mocha/lib/mocha.js:247:14) at Mocha.run (/home/codewarrior/node/node_modules/.registry.npmjs.org/mocha/5.2.0/node_modules/mocha/lib/mocha.js:576:10) at Object. (/home/codewarrior/node/node_modules/.registry.npmjs.org/mocha/5.2.0/node_modules/mocha/bin/_mocha:637:18) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3) at Function.Module.runMain (internal/modules/cjs/loader.js:754:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

  • yeliabhcaz6 Avatar

    This comment has been hidden.

  • Shikiiii Avatar

    This comment has been hidden.

  • dummyaccount Avatar

    This comment has been hidden.

  • LegendaryFartMaster Avatar

    Scala Translation submitted. Please share your thoughts!

  • kdoxsey1 Avatar

    This comment has been hidden.

  • rowcased Avatar

    This kata has varying output types (as well as function names) between the translations, and as such, currently the dynamic language descriptions are lacking, unclear, or misleading.

  • Dominic-Taylor-Dev Avatar

    This comment has been hidden.

  • rowcased Avatar

    This kata has 9 language translations, yet only two dynamic language examples in the description. Therefor, being that the csharp example is before the prolog example, AFAIK all languages other than prolog default to the C# example. Yet, that language expects a different type of output, namely an array of strictly strings, than (most?) other languages, which expect a mixed-type array as a return value.

  • GeorgCantor Avatar

    not fu*king clear!!!

  • DavidFromNorth Avatar

    Well, I think I'm ready for the interview now 🧠

  • Damascan-Alex Avatar

    When use map method the test shows this error: n.map is not a function

  • AntonLiutvinas Avatar

    This comment has been hidden.

  • vieraboschkova Avatar

    silly stuff- check all the words "then" in the description of the exercise, it should probably be "than"

  • B1ts Avatar

    Prolog translation kumited. (author is inactive)

  • WestwardLand968 Avatar

    In Python there is only one random test. (Although there is one test from 1 - 100)

    Should more be added?

  • Javatlacati Avatar

    Java translation Kumited! please accept :smile:

  • Javatlacati Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    This comment has been hidden.

  • Javatlacati Avatar

    This comment has been hidden.

  • stauntonjr Avatar

    Broken in python. Disappointing.

  • MFazio23 Avatar
  • Chrono79 Avatar

    It could use random tests in all languages.

  • john9631 Avatar

    Saw the complaints that it wasnt working so tried it. The Python version was fine.  Good Kata.

  • Blind4Basics Avatar

    Ruby: test cases use Test.expect instead of Test.assert_equals. Sample tests are up to date, though.

  • emmaalbury Avatar

    Ruby: getting errors when test argument is multiple of 10 (i.e. 30 or 100) or 1, even though output is correct (output is 'buzz' and '1' but error says 'Fails: 10' etc and 'Fails: 1'). Any ideas as to why? Is this just a bug or am I doing something wrong? Any way to fix this to trick the bug?

  • sledge_909 Avatar

    lovely kata! thanks.

  • Voile Avatar

    Ugh, publish timeout.

    Let's try this again.

  • Voile Avatar

    Kata (kinda) fixed since site change made at https://github.com/Codewars/codewars.com/issues/1010

    Since 500 solves has already been made I can't change the test cases. This is the best I can do. :(

    At least it's solvable (normally) now.

  • Illoric Avatar

    I actually haven't had an issue with the ReferenceError. However, I am having an issue passing the 30 numbers test case EVEN THOUGH my output is exactly the same as what is expected by the test case (Python 3.4) which makes no sense to me. Has anyone else run into a similar issue?

  • albmaso Avatar

    TestCases are still broken, ReferenceError: fizzify is not defined message appears

  • izotope115 Avatar

    Still broken. Be sure to put fizzify = fizzbuzz; globally, in your solution.

  • Ravalo Avatar

    Testcase still not fixed ...

  • CollinRea Avatar

    Hey Guys!

    I am getting this:

    Fizzbuzz Should fizzify 10 numbers correctly Fails with 10 numbers! - Expected: [1,2,"Fizz",4,"Buzz","Fizz",7,8,"Fizz","Buzz"], instead got: [1,2,3,4,5,6,7,8,9,10] 0 Passed 1 Failed 0 Errors Process took 202ms to complete

    I got my array setup in the function and the .push under each if statement but It just prints 1-10.

    any help?

  • PaulCalvelage Avatar

    The JavaScript test cases are broken. The line arr.push(fizzify(i)); should be arr.push(fizzbuzz(i));.

    To workaround, put var fizzify = fizzbuzz; in your solution.

  • Steadyx Avatar

    This comment has been hidden.

  • srhbinion Avatar

    I was getting this error:

    Should fizzify a random positive integer (1~100) correctly
    ReferenceError: fizzify is not defined
      at fizzbuzzRandom
      at Test.it
      at Test.describe
      
      at Object.<anonymous>
    

    and I could not fiure out the answer. I even ended up deleteing my visible code test. (oops!) I still did not find a way to reset or bring back the original test code. BUT I did figure out that seeing the test code does not matter to the testing conditions.

    To any coders who are in the same spot. You can still solve this problem: The hint is fizzify is not defined and you can enter this code in the solution window not the test case window.

  • Azuaron Avatar

    This comment has been hidden.

  • Leks12lk Avatar

    While submission decision appears error: ReferenceError: fizzify is not defined at fizzbuzzRandom at Test.it at Test.describe

        at Object.<anonymous> 
    

    Does anyone know what is it?

  • YasminEndusa Avatar

    C# version kumited some more test cases, but no random test case also I added a rule (for now only for C#) for inputs smaller 1

  • mjquito Avatar

    Great kata to practice using the range function!

  • nataliemona Avatar

    This comment has been hidden.

  • Spinaldash Avatar

    Essentially, the last test case is testing a different function than the first 4 test cases.

    I would recommend changing test case 5 to test the same function that test cases 1 - 4 test. (FizzBuzz)

  • stewardtz Avatar

    This comment has been hidden.

  • Pavloski Avatar

    This is my code at the end of my program but it tells me "Unexpected token at 'else{' " and if i remove the semi-colon, it says "Unexpected token '(' at '});{});' "! What is the problem!
    if (stuff){ stuff here; }; else{ stuff here; }; return spoiler;

  • scamsjk Avatar

    This comment has been hidden.

  • kopijunkie Avatar

    Like a few others, I had resorted to a hack to pass the last test thinking it was a bug in the tests.

    But now that I've seen some of the solutions & had a think about it, I realised why that last test is testing for a 'fizzify' function. Good test! But it probably should be made clearer in the Kata's description that a second function with that name should be part of the solution instead of only finding out after the first submission attempt.

  • oldccoder Avatar

    I found the same error in the test cases:

    "Should fizzify a random positive integer (1~100) correctly ReferenceError: fizzify is not defined at fizzbuzzRandom at Test.it at Test.describe

        at Object.<anonymous>"
    
  • donald-s Avatar

    There's an error with the last test case in this Kata. The last test case is looking for a function called "fizzify", but it doesn't exist and the instructions do not say anything about creating another function called fizzify. Here's the error:

    Should fizzify a random positive integer (1~100) correctly ReferenceError: fizzify is not defined at fizzbuzzRandom at Test.it at Test.describe

    at Object.

  • dabcoder Avatar

    This comment has been hidden.

  • GiacomoSorbi Avatar

    The last test passes to me if I put:

    var fizzify=fizzbuzz;

    Yet still annoying and I hope it is fixed soon.

  • CruzanCaramele Avatar

    hi, am kind of new here, am trying to solve this Fizzbuzz in python. I managed to solve it on my computer correclty but on here i get the following error :

    Traceback: in in fizzbuzz TypeError: not all arguments converted during string formatting

    0 Passed 0 Failed 0 Errors

    --> is there a problem or anything i should know or is it just my solution that's incorrect? any help would appreciated

  • qed2000 Avatar

    Try using this test case:

    var num = Math.floor(Math.random() * 101);
    it('Should fizzify ' + num + ' numbers correctly', function() {
      var expected = [1,2,'Fizz',4,'Buzz','Fizz',7,8,'Fizz','Buzz',
                     11,'Fizz',13,14,'FizzBuzz',16,17,'Fizz',19,'Buzz',
                     'Fizz',22,23,'Fizz','Buzz',26,'Fizz',28,29,'FizzBuzz',
                     31,32,'Fizz',34,'Buzz','Fizz',37,38,'Fizz','Buzz',
                     41,'Fizz',43,44,'FizzBuzz',46,47,'Fizz',49,'Buzz',
                     'Fizz',52,53,'Fizz','Buzz',56,'Fizz',58,59,'FizzBuzz',
                     61,62,'Fizz',64,'Buzz','Fizz',67,68,'Fizz','Buzz',
                     71,'Fizz',73,74,'FizzBuzz',76,77,'Fizz',79,'Buzz',
                     'Fizz',82,83,'Fizz','Buzz',86,'Fizz',88,89,'FizzBuzz',
                     91,92,'Fizz',94,'Buzz','Fizz',97,98,'Fizz','Buzz'
                     ];
      Test.assertEquals(JSON.stringify(fizzbuzz(num)), JSON.stringify(expected.slice(0,num)) , 'Fails with ' + num +' numbers!');
    });
    
  • computerguy103 Avatar

    In addition to the fizzify not defined bug, the random number test is broken. It calls fizzbuzzRandom twice and compares the results and of course the results are identical so it'll always succeed (as long as fizzbuzzRandom wouldn't crash). It should call it once and compare that result to the array returned by fizzbuzz.

    As a result, fizzify can be defined to return anything, as long as isn't random and depends purely on the value of its argument. It's actually supposed to return only a single value - "Fizz", "Buzz", "FizzBuzz", or the number it was called with - not an array, so it's not the same as fizzbuzz. I.e.

    fizzify(1) == 1
    fizzify(3) == "Fizz"
    fizzify(5) == "Buzz"
    fizzify(15) == "FizzBuzz"
    

    etc.

  • bhatti1209 Avatar

    The "fizzyif" test cases is very misleading. It should either be removed or description for the same added in the problem statement.

  • El Corto Avatar

    stephenyu, could you please fix this kata for JS. Pavel has already pointed out the bug

  • cauli Avatar

    This comment has been hidden.

  • pavel Avatar

    Gives me this on the last test, when submitting my solution.

    ReferenceError: fizzify is not defined at fizzbuzzRandom at Test.it at Test.describe

        at Object.<anonymous>
    
  • phlacin Avatar

    This comment has been hidden.

  • bennacer860 Avatar

    You should have message to explain the error in your test, i can't understand why my code is failing.

  • user9852779 Avatar

    The description says that N will never be less than 0, but doesn't say how the case n==0 should be handled. If you want fizzbuzz(0) === [], you should make that clear in the description and add a test case for that, otherwise change the description to say N will never be less than 1.