6 kyu

Custom FizzBuzz Array

699 of 3,664ogryzek
Description
Loading description...
Arrays
Logic
Fundamentals
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar

    Missing fixed and random tests such as num_1 = 6 && num_2 = 10 in

  • user1430804 Avatar

    thanks for this.. i still dont know why my solution is correct.. just followed your instructions.. :)

  • SunMaster Avatar

    I'm doing the rust version and I really don't understand this.

    As I understand it the 4 paramters to the function means the defaults should be overwritten.

    So if the string_one argument is given it should be checked if it's a multiple of num_one (if parameter is given, otherwise 3). The same for string_two.

    What I don't understand is how the argument in brackets is passed on to the function - and how to retrieve it in the function

    fizz_buzz_custom[15]                         # returns 16
    fizz_buzz_custom[44]                         # returns "FizzBuzz" (45 is divisible by 3 and 5)
    fizz_buzz_custom('Hey', 'There')[25]         # returns 26
    fizz_buzz_custom('Hey', 'There')[11]         # returns "Hey" (12 is divisible by 3)
    fizz_buzz_custom("What's ", "up?", 3, 7)[80] # returns "What's " (81 is divisible by 3)
    
  • Stephen Chao Avatar

    I think this kata has a problem. In Javascript, I pass the first two custom tests but the third says Expected: "FizzBuzz", Instead: 15. But according to my code and the output, it gives "FizzBuzz". I think the test is having an issue.

  • skay97 Avatar

    This comment has been hidden.

  • christinamartinez Avatar

    This comment has been hidden.

  • bbirkinbine Avatar

    Python:

    initial test cases work fine but random tests don't work even though the expected and actual output match. I even compared both via the command line diff command and no differences, not sure why test cases are failing.

    moving on as I've wasted a lot of time on this exercise trying to get random tests to work that look to be correct.

  • kalo hing Avatar

    This is terribly confusing. Are we supposed to include cases for any number of inputs? Say the function call was fizz_buzz_custom('Hey', 8). Then is string_two still "buzz" and num_two still 5?

  • anter69 Avatar

    Add edge case e.g. n1 = 3, n2 = 6

  • B1ts Avatar

    No sample tests in JS.

  • Blind4Basics Avatar

    Python:

    since the random test process (eg. testing the whole returned result) isn't the same than the one for the fixed tests (eg testing one item from the result), a discrepency from the description arises:

    return a sequence of numbers

    so, I went on, returning a tuple, but it ofc fails the random tests while it's perfectly valid according to the description.

    => either add a note somewhere, or change the way the random tests are testing the results, or at the very least, add some fixed tests (both in the test suite and the sample tests) testing an actual list, to show that it's not "just" a sequence that is expected.

  • cliffstamp Avatar

    Ruby does not have random tests.

  • Unihedron Avatar

    Missing sample tests

  • sledge_909 Avatar

    description >= confusing ? return 'pass'

  • jar9tf Avatar

    How do we solve this problem, if we don't know how that array index is being passed into the function? It's not an argument. I guess I'm a little confused.

  • missyj2016 Avatar

    I've come up with instructions on this Kata that I feel are more clear.

    Create a method that returns an array of 100 items.

    The method can accept up to 4 arguments. The first two are strings and the last two are integers. The defaults are as follows (e.g. use these if values are not passed for an argument):

    • stringOne = "Fizz"
    • stringTwo = "Buzz"
    • numOne = 3
    • numTwo = 5

    If the array index is divisible by the first integer argument (NumOne), push the first string (StringOne) to the array.

    If the array index is divisible by the second integer argument (NumTwo), push the second string (StringTwo) to the array.

    If the array index is divisible by both the first and second integer arguments, push the concatanated strings to the array.

    If the array index is not divisible by either of the first and second integer arguments, push the index number to the array.

  • DarylMcCullough Avatar

    This kata is misleading in yet another way. The way that I usually approach these is to run the examples, and if the examples pass, then I submit an "attempt". But in this case, "Run examples" apparently always says that your code fails. This is my output:

    Time: 417ms Passed: 0 Failed: 1

    Since I couldn't figure out what was wrong with my code, I submitted anyway, and it passed.

  • DarylMcCullough Avatar

    I found the instructions for this challenge to be completely confusing. It wasn't at all clear what was being asked for. For example:

    "Create a method/function that returns an array of numbers from 1 to 100."

    Does that mean an array of length 100? Or does it mean an array whose elements are numbers from 1 to 100?

    For another example, the instructions say: "If no arguments are passed, the value at the index of the array for the number should be 'Fizz' if it is divisible by 3, 'Buzz' if divisible by 5, 'FizzBuzz' if it divisible by both 3 and 5, or the number if it is not divisible by 3 or 5."

    What does "the index of the array for the number" mean? I assume it just means that if x is the array, then x[i] should be equal to 'Fizz' if i is divisible by 3, etc. But the examples don't show that. It seems to show that if i+1 is divisible by 3, ...

    For another example, the instructions don't actually say what is supposed to be done with the arguments. The instructions say: "If no arguments are passed, ...", but it doesn't say what to do with the arguments if they are passed. The instructions say "The first and second arguments are strings, which should be 'Fizz' and 'Buzz' by default. The third and fourth arguments are integers and and should be 3 and 5 by default." But there is no indication of how to use the arguments, so I'm not sure what it means to use defaults for the values.

    Finally, the test that is performed when you click "Run Examples" doesn't actually do anything. So are we supposed to write our own test? I have no idea what the program is supposed to do, so how could I possibly write a test to see if it does it correctly?

    Is this challenge supposed to be preparation for a job as a programmer, when you often have no idea what the customer actually wants?

  • mjohnson2016 Avatar

    I'm seeking clarification on the Instructions. • Should the array alement always be a number if the index is not divisible by 3 or 5? • When should only one string be included when two are passed as function arguments?

  • mjohnson2016 Avatar

    Should update test description, "should return 'Fizz' at the index of a number divisible by 3 and 5". It should read, "should return 'FizzBuzz' at the index of a number divisible by 3 and 5".

  • jkoller90 Avatar

    Super confused about what the two number parameters are supposed to do exactly. Can somebody please clarify what we're supposed to do with them? Thanks!

  • user5036852 Avatar

    Nice kata!

  • kparekh01 Avatar

    def fizz_buzz_custom(string_1 = "Fizz", string_2 = "Buzz", num_1 = 3, num_2 = 5) p number end

    fizz_buzz_custom[28]

    I'm having some trouble understanding this kata, how does one pass an argument outside of the method parentheses # fizz_buzz_custom[number from 1..100]?

  • patrick_7891 Avatar

    Spent 10 minutes trying to just understand the insructions. Not going to waste anymore time on this after seeing that everybody else is having the same problem.

  • ikreazy Avatar

    Create a method/function that returns an array of numbers from 1 to 100.

    It is possible to solve this without using neither Array nor even Hash. If it REALLY have to return an array there should be a test for it!

  • g964 Avatar

    What a mess in the description!

  • carlqt Avatar

    Pretty confusing description. It took me longer to understand the question than to solve it. I'll re-edit this post, and try to rephrase the description. This puzzle is fun but if we can't understand the instructions, it really ruins the fun.

  • Onikoroshi Avatar

    I'm getting a "Test Didn't Pass: Unknown Error" whenever I try to run my tests. Even with blank tests, and not altering the starting code at all. Doesn't seem like that should happen. :/

  • user578387 Avatar

    Great kata idea, nice job!

  • happinesssam Avatar

    Terrible instructions, I'm not sure what is required.

  • rongworks Avatar

    same for me "Unknown error", Tests pass

  • nicoglot Avatar

    This comment has been hidden.

  • Craft Avatar

    It may be that I am really new to this, but I have NO idea what I am being asked to do. The grammar/punctuation makes it kind of incomprehensible. Can we get this re-worded? After attempting it one time and failing I read the failure errors to be able to deduce what is actually being asked.

  • alkimo Avatar

    I don't even know what this kata is asking me to do, Jesus! Can't you fix the instructions?

  • janejanejane Avatar

    This comment has been hidden.

  • pedrofialho Avatar

    LOL only now I realized this kata was much easier than I thought. I read the description so fast that I didn't notice the size constraint and ended up creating a "infinite array" solution.

    Anybody did that too?

  • yaphi1 Avatar

    This kata seems clear and the test cases are well-described. Nice work!

  • hencethus Avatar

    This comment has been hidden.

  • wthit56 Avatar

    The description is pretty confusingly written here. There are no "replace"s necessary, and you only explain what you're actually meant to be doing right at the end. It would be easier to understand if you wrote everything in order, making everything as clear as possible and hilighting with back-ticks to show the names of arguments and such. This will really help the readability of this kata.

    A fun exercise, though, once you get your head around it.

  • OverZealous Avatar

    This comment has been hidden.

  • mlabrum Avatar

    Tests are passed now. I think the only thing left is to clean up the example given in the kata description:

    fizz_buzz_custom[44]                         # returns "FizzBuzz"
    fizz_buzz_custom[15]                         # returns 16
    fizz_buzz_custom('Hey', 'There')[25]         # returns 26
    fizz_buzz_custom('Hey', 'There')[14]         # returns "HeyThere"
    fizz_buzz_custom("What's ", "up?", 3, 7)[80] # returns "What's "
    
  • mlabrum Avatar

    The last of the two-parameter tests needs a small tweak. As is, Test Failed: expected: fizz_buzz_custom('lol', 'dude')[92] to return 'dude', instead got: lol; 93 is only divisible by three, so the expected output should be 'lol'.

  • vferries Avatar

    Tests are just wrong...

    I have exactly the same output as zishe.

  • zishe Avatar
    FizzBuzz Array! (Custom):
    should return FizzBuzz defaults when no params are passed:
    Test Passed
    Test Failed: expected: fizz_buzz_custom[89] to return 'Buzz', instead got: FizzBuzz
    Test Passed
    should return Custom Words in place of FizzBuzz for first two params:
    Test Passed
    Test Passed
    Test Failed: expected: fizz_buzz_custom('lol', 'dude')[87] to return 'loldude', instead got: 88
    Test Failed: expected: fizz_buzz_custom('lol', 'dude')[92] to return 'dude', instead got: lol
    should return custom words in place of FizzBuzz, for custom numbers if 4 params are passed:
    Test Failed: expected: fizz_buzz_custom('Happy', 'Pony', 1, 8)[87] to return 'Pony', instead got: HappyPony
    Test Passed
    Test Passed
    Test Passed
    

    Tests are horrible.

    fizz_buzz_custom[89] to return 'Buzz' - if it's 90 of course it multiples 15, and 89 not multiplies both 3 or 5.

    fizz_buzz_custom('lol', 'dude')[87] to return 'loldude' - srsly?

  • mlabrum Avatar

    Are the indices in the example correct? If FizzBuzz, by default, is an array counting from 1 to 100, it should be fizz_buzz_custom[14] instead of fizz_buzz_custom[15] that returns "Buzz", correct?

    Could the expected values be added to the failure messages? I'm getting about 2/3 of the test cases to pass, and since the output is the same for each of them, I'm not sure what's going wrong.