6 kyu

Back and Forth: How Many for Each Side?

69 of 125LanXnHn
Description
Loading description...
Puzzles
Logic
Algorithms
Performance
View
AllIssuesQuestions1Suggestions7Show Resolved
  • Please sign in or sign up to leave a comment.
  • eurydice5717 Avatar

    Nice Kata, but.... in the description the line "If you have less than 2 boxes at any side, you will run out of boxes while carrying." is confusing, as it relates to the EXAMPLE and not to the general problem.

    Very confusing, especially because the line is highlighted bold.

    Took me som time to figure that out...

  • mzajaczkowsky Avatar

    This comment has been hidden.

    • LanXnHn Avatar

      Sorry for delay on answering.

      You can think about that if you need to move 1 box to the second, then move 100 to first ([1, 100]). See what your code return, compare with the correct answer counting by yourself.

  • Krillan Avatar

    Couldn't understand the description. Although of course it may be due to the fact that I translate by Google.

    • LanXnHn Avatar

      Basically, you are to find out how many boxes you need to put at first and second, so you wil have enough boxes to move.

      If there is any other question, please let me know.

    • Krillan Avatar

      In general, everything that needs to be done is not clear, I just realized that there are 2 locations and you need to transfer boxes to them, but how does this interact with the input array of numbers, where do these 2 numbers in brackets come from in the example, etc. You need some kind of visual explanation or instruction, for example, a detailed one, what exactly is happening with the input array step by step and what does it have to do with 2 locations.

  • Krispy_Butter Avatar

    Not a bad one. I think the example walkthrough can be way more clear. Like even after solving it, I'm still not sure how starting with the solution (2,2) aids in understanding. I had to just go through the other examples and write it out to figure out my solution. Maybe something like: So for example, lets say you have lst = [1,2,3,4]. Think of the first 2 indices as the start of the left and right side. So starting from left to right, we have 1 box (lst[0]) on the left going to the right (lst[1]). So now we have (0, 3) where 0 is the left and 3 is the right. Now it's time to go from right to left. The next amount of boxes to move comes from index lst[1] since we are now going through each move operation in lst. So now we are moving 2 (lst[1]) from the right side, 3, to the left side, 0. So we get (2, 1). Find the amount of additional boxes needed if the current amount of required boxes lst[i] operation (left or right movement) is short for the current side.

    • LanXnHn Avatar

      Thank you for your reply.

      To work out the amount of boxes needed is the puzzle for this kata.

      If I give the whole procedure of how to get the needed amount, it lost the point.

      The example is just intended to show the procedure of how boxes moving work, then from there one can work on the amount for it.

  • dfhwze Avatar
  • dfhwze Avatar
  • ilash Avatar
  • benjaminzwhite Avatar

    Really elegant puzzle and cool kata @LanXnHn , thanks!

    I'll bookmark it and am happy to approve it for you later, if/when it is well voted :+1:

    • LanXnHn Avatar

      Thank you for this. Let's see how everyone think about it.

    • benjaminzwhite Avatar

      I just came back to my bookmarks, and saw @dfhwze has already approved - he was faster than me it seems, that's what it must take to become 2 dan... Oh well, I'll get the next one ;)

      Thanks again for the nice kata @LanXnHn :+1:

  • dfhwze Avatar

    Additional tags: logic, algorithms

  • dfhwze Avatar

    Interesting kata. I suggest you turn this into a performance kata for extra challenge.

    • LanXnHn Avatar

      I don't know how to make such a simple one into performance...

      I increased the length and numbers up to 100.

    • benjaminzwhite Avatar

      This comment has been hidden.

    • benjaminzwhite Avatar

      This comment has been hidden.

    • LanXnHn Avatar

      With your suggestion, I increased the numbers limit up to 200.

      Now it will generate big numbers for the approach you brought up.

    • benjaminzwhite Avatar

      This comment has been hidden.

    • dfhwze Avatar

      You could leave a hint to future translators and to all users that want to solve your kata by adding a "performance constraints" section in the description.

      • Add your N = 200 there, but also leave a note that this number may vary by language.
      • Also make sure to write that brute force solutions shall not pass.
      • Add the "performance" tag to the kata.
    • LanXnHn Avatar

      Well, never have any translation before, let me add them.

    • McMurphyCod Avatar

      i've made the solution on Java, it passes all your's and my own tests (including {} and {0} lists) maybe somedays there will be a Java kata for this example and i'll post my solution

    • LanXnHn Avatar

      I don't know Java, if one day someone makes a translation, you can do this Kata with it.