6 kyu
Pair items from two lists of different lengths
118 of 128user2553318
Loading description...
Fundamentals
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.
Quite a complex kata, I guess getting the correct pairing combinations is what's challenging about it.
=> That's an issue. And to sustain that, the first sample test using "codewars" should be added to the description.
Thanks for the feedback.
I added the test case 'codewars' to the examples in the description.
that's not enough. You have to specify the problem entirely too. ;) (surely I wasn't clear enough: I meant to update the description and add the example)
Ok, I see. I extended the description with an additional property and two hints.
I think having points 2 and 3 separated (mostly with 3 after 2) is still misleading. Imo, you should merge them:
And I'd even begin the examples with the one that is currently last
Ok, I tried a new wording based on your suggestion and rearranged the examples.
Thanks for the helpful input. I take the liberty of closing the topic. Open a new topic if any further ambiguities are discovered.
:+1:
Python: The second sample test
is rubbish since the order of operation is
(actual == expected1) or expected2
andexpected2
is a non-empty list, so True-ish.True. I have now adjusted the test.
Thanks for the feedback.
It is nowhere stated that each sublist has to contain the maximum amount of tuples possible. From what I read in the description it could also be possible to return sublists with only one pair in the examples.
In the python tests it's really annoying that you simply get an error message "Value is not what was expected" when your test fails instead of the expected and actual results.
Sorry for that. I enhanced tests now with more detailed error messages.
Thanks for the feedback.
Changed python tests to allow any order of inner lists (also see updated description). The Ruby tests may also need to be adjusted.
Ruby sample tests:
expect(pair_items([1], [2, 3])).to eq([[[1, 2], [1, 3]]])
This looks incorrect. Compare to Python:test.assert_equals(pair_items([1], [2, 3]), [[(1, 2)], [(1, 3)]])
Fixed.
Some Python solutions call
len
on the input and they pass all current tests. Either it should be guaranteed that the input iterables have known lengths or tests against this should be added.The Python version never tested anything besides lists and strings, so I think changing "2 iterable objects" to "2 lists" would be better (tests with strings don't add anything to the task, so they could be removed entirely).
agreed, I will convert the string inputs in the python tests into lists
Changed description and tests to list input only.
Ruby has strings in the sample tests. Strings are not iterable in Ruby.
Removed tests with strings.
Ruby translation. Please, review and approve.
The function must return a list of lists.
The order of the inner lists is defined in the task description: "maintaining the order of the items". But the order of the lists in the list is not defined in the task description.
The test fails if the lists are not in the correct order. But the correct order is not specified. Only by trial and error I found a solution.
Sorry for that. I will look into it.
Thanks for the feedback.
This comment has been hidden.
Thank you. I removed the teaser.
I don't understand why I have to return some pairs twice. For example "abc" and "xy": Why aren't the pairs ax, ay, bx, by, cx, cy?
Look at the structure of the return type. It isn't a list of tuples, it is a list of lists of tuples. Each inner list being a set of combinations which can exist together. So the options of "abc" and "xy" are either:
[("a", "x"), ("b", "y")]
OR[("a", "x"), ("c", "y")]
OR[("b", "x"), ("c", "y")]
So our solution needs to return a list of all of these options.
The user can modify the input.
Thanks, fixed it.