6 kyu
Back and Forth: How Many for Each Side?
69 of 125LanXnHn
Loading description...
Puzzles
Logic
Algorithms
Performance
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
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...
This comment has been hidden.
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.Couldn't understand the description. Although of course it may be due to the fact that I translate by Google.
Basically, you are to find out how many boxes you need to put at
first
andsecond
, so you wil have enough boxes to move.If there is any other question, please let me know.
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.
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.
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.
Ruby Translation
I need help from a Ruby master for this...
Only know Python and some JS...
Suddenly notice someone approved it, thank you for your translation.
JS Translation
This comment has been hidden.
If you don't think the above point is a problem, let me know, I will approve it.
Ah, you want a combination of numbers with repetition? In that case, I need to rework my translation a bit.
It doesn't really make a lot of changes.
Thinking to add another fixed test for
[4, 4, 4, 4, 4]
.Here's a new fork: https://www.codewars.com/kumite/636564b7d411604ed0e6fb46?sel=63662062b1e8e3002342d27d
Looks fine for me.
Thank you for your work!
There are no repetitions of numbers in the random tests in the C++ version as well. Do you want me to change this?
Ah, that's what confused me. I took the C++ translation as reference to make JS :)
Somehow I thought that random.choices in python was without repetitions.
Anyway, here is a fork with updated tests (including the
[4, 4, 4, 4, 4]
test): https://www.codewars.com/kumite/6364ffd71663bc0069bf98b7?sel=636636d1c94f160030e14290Approved and also added that test case in JS.
I know python choices, choice and sample are confusing...
The case not really a big thing.
Maybe not a big thing, but it does make the distribution of numbers a bit differently. Perhaps some solutions could take advantage of that somehow. It's good all translations are aligned now. :)
C++ translation
Thank you for your work.
My knowledge on C++ is none.
I may need to ask on Discord for review.
approved
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:
Thank you for this. Let's see how everyone think about it.
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:
Additional tags:
logic
,algorithms
Tags added.
Interesting kata. I suggest you turn this into a performance kata for extra challenge.
I don't know how to make such a simple one into performance...
I increased the length and numbers up to 100.
This comment has been hidden.
This comment has been hidden.
With your suggestion, I increased the numbers limit up to 200.
Now it will generate big numbers for the approach you brought up.
This comment has been hidden.
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.
Well, never have any translation before, let me add them.
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
I don't know Java, if one day someone makes a translation, you can do this Kata with it.