6 kyu

Recursion: An introduction

Description
Loading description...
Recursion
Fundamentals
Tutorials
  • Please sign in or sign up to leave a comment.
  • S2lyaQ Avatar

    Funny one! :) A little bit trickier than it seems.

  • ejini战神 Avatar
    • A non-recursive solution can still pass the tests like this one

    • In the description, the third call should replace all values of 2 with 3

    • The description needs better formatting as well

  • KatyaBarta Avatar

    Thanks, that was fun recursion practice!

  • glynester Avatar

    Tests do not adequately check for width = 0.

    This is only covered by random tests which means that a solution can randomly pass and fail depending on whether or not it caters for width 0.

    So some of the accepted solutions fail.

  • SomeEngineer42 Avatar

    Was using this kata to introduce someone to recursion and there were some huge problems that came up.

    • The instructions never really talk about returning the method being called recursively. This is pretty integral to how recursion works and what's going on.
    • The example uses an array variable declared outside of the function, but this doesn't actually work for this problem since you call the tests in succession. Should probably discuss declaring your recursive function inside the main method or talk about defaulting a third parameter and then passing it through.
    • Should really not provide a 0 width. It just ends up with a bad experience for the user. Newbies aren't really going to understand what happened when you blow the stack.

    Update; I totally missed that 0 width criteria was mentioned at the bottom. I definitely missed that reading the question the first time.

  • revanslacey Avatar

    Hi there,

    In your explaination the third call still has the value of '2' rather than '3'.

    Cheers,

    R

  • Voile Avatar

    Approved

  • otajor Avatar

    It is not explicitly stated how the function should behave when the width is 0, as can happen in the random tests. Either add clear specs for this case, or make sure that the random tests always have a width > 0.

  • user7973646 Avatar

    This comment has been hidden.

  • jaels Avatar

    Hey, I think your description of the stair situation is very confusing. It looks like 0 is the top stair. so if, for example, you start in the 10th, going down, I thought the numbers will go up. So very confusing up-down top-bottom description. Had to look a few times and use the examples to understand what you want to get. Maybe you meant 100 - 0 top to bottom? you wrote 0 - 100 top to bottom. Might be that the confusion starts there.

  • smashzen Avatar

    This comment has been hidden.

  • zvytas Avatar

    Initial tests need updating.

  • Unnamed Avatar

    stepDown(5,7) [] You can't make a step without falling in to the lava

    Then in this case:

    stepDown(49,10) [9,19,29,39,49]

    how is 9 in the answer? You can only step into lava from there too. Or if you end up in 9 then why isn't it [5] in the first case?

  • donaldsebleung Avatar

    This comment has been hidden.