6 kyu
Diagonal Strings
82 of 254frkn2076
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.
Why not take just a little more time and clear up such a messy description.
What a mess. Let me know if I got this right:
We're supposed to sort the array alphabetically. Then take the diagonal string. Put the first string to the back of the array. Repeat until all strings have been in the front. Sort the new diagonal array to the same configuration as the original array. Return diagonal array.
If this is the case, What determines the original configuration? Whichever word we took the 1st letter from? Say input is: { "def", "abc", "ghi" }, then after sorting it would be { "abc", "def", "ghi" }. Then the diagonal array should be { "aei", "dhc", "gbf" } before setting it to the original configuration. So the output should be { "dhc", "aei", "gbf" }?
Edit: Got it :)
In languages (like Go) with UTF-8 strings (variable number of byte per character):
Add a test case with a 2 byte character (like ± or 🌹) in the string. Solutions with byte access despite the structure of UTF-8 strings will fail the test.
the description is just... horrible :s
You must first sort the array alphabetically. And output consists of letters obtained diagonally (from upper left to lower right).
while it's not that at all......maybe 4kyu.
Not 4kyu at all, the description is just awful...
Test 6 C#. array.len = 5. word.len = 5.
Expected and actual are both <System.String[5]> Values differ at index [0] Expected: null But was: "jPADP"
??
Everything looks fine. Your response array length is 5 and first element of your response is null but it should be "jPADP".
Sorry. my bad) everything worked out.
Np bro
Hello, I've a problem, I pass all tests except test 6. The error message is expected "[ Array(5) ] to deeply equal [ Array(5) ]", I want to be able to see the expected value, so I can be able to my the code.
javascript
Fixed
Hello there! I pass all tests except one random test (RandomTest3). But I am extremely confused by his answer:
Expected: [null, null, null, null, null] Actual: ['zIXkS', 'zIXkS', 'zIXkS', 'zIXkS', 'zIXkS'] Which: was 'zIXkS' instead of at location [0]
How can there be such an answer as indicated in this test?
Language Dart
I've checked test cases, runned every case again and everything looks fine. Can you try again?
No, random test (RandomTest3) still returns an error on my solution.
But it's not even about my decision. And in the expected test response:
Expected: [null, null, null, null, null] Actual: ['BRR9P', 'BRR9P', 'BRR9P', 'BRR9P', 'BRR9P'] Which: was 'BRR9P' instead of at location [0]
How is this possible? In principle, there should not be such an answer under the conditions of the problem. It can be just null, but not an array consisting of null. Isn't that right?
I have an assumption that the test solves the problem, after my solution. And it takes the same data. My solution changes the original array, leaving null in it instead of the input values. In this case, if the test takes a modified array, this explains the incorrect test response.
Yes. My guess was correct. This is a problem in the test. It takes the data after the user's solution works with this data. Because of this, if the user's solution changes the initial data, the test will return an incorrect response. Need to fix it.
I made a workaround in my solution so that the initial data remained unchanged, and the test began to complete correctly.
I am grateful of your awareness. As you noticed, the problem occurs from reference types. Now i've fixed. Can you try again with your previous code?
Everything is fine now. The solution that changed the original array now also completes successfully.
Need a test like
['xyz', 'abc', 'xyz']
My solution passed all the current tests, but it wouldn't have passed this one.Thank you for your kindly attention, i've fixed the case. Added the test case for sample and hidden ones.
I think the description should to say "if array.Length == 0 return null" as from some point of view it can be
treated
as a square...which size is 0 ;pThnak you, i've changed the description, better late then never :)
This kata is harder than a 6 because of the requirement that we must sort the input alphabetically and then sort back into the default order, while the original can have duplicates. This Kata doesnt have much of an explanation, and is mostly an excercise in figuring out what we are supposed to do based on the examples.
It would be a much better kata if there was some sort of real life analogy or situation. I cannot think of any way that would make sense with the duplicates and re-sorting.
The description should probably state this additional information: Sort the strings in alphabetical order. Rotate through each of the strings being the first, while keeping the strings in the sorted order. Find the diagonal from upper left to lower right. We need to find the diagonal rotating through each of the strings being the first string.
For the first test, the very first array diagnol expected back in your answer array is: abcd
kata
qwer
1234 -> abcd => "aae4"
That order looks quite arbitrary to me without explanation of the rotation.
Thank you for your interest :) I think everything is clear except diagonal way. I made a change about it.
I still don't think the instructions are clear (as of May 2020). dlcoe's explanation of the sorting/rotating through each string being first in the order makes more sense, but is not included in the main Kata description. Also, the method of sorting the result array is not clear - I had to re-read the problem about 10 times before I understood that the result array is arranged simply based on the original, unsorted input array, which is counter-intuitive given how many times you are asked to sort the input array within the main body of the problem. Finally, in the example you show "1234" as being at the top of the first list (top left), which, if the sorting/rotating through each string being first described by dlcoe is correct, then 1234 should be the at the top of the last list (bottom right).
I know your comment is old, but thank you for explaining this. I'm coming across several of these Kata where the hardest part is understanding the instructions.
Then why did 90 people still took the time to solve this Kata? Solving a Kata with such a bad description just enables future Kata's with low quality like this.
Tests with non-unique strings needed.
Added
With some of them but not all non-unqie too; some solutions will fail in that case.
Fixed
It doesn't look like this. Was it republished successfully?
I've done. Can you check again?
I don't see any such tests. Something like
string[] test = new string[] { "abcd", "kata", "abcd", "qwer" };
. What should be returned in this case? It's not really specified, but if it's a valid case, then I suppose the sort should be stable so that the first"abcd"
comes first in the result, sostring[] expected = new string[] { "abtr", "kwcd", "aaed", "qbca" };
.I got it now. Yeah, you are right, string[] test = new string[] { "abcd", "kata", "abcd", "qwer" }; input should return string[] expected = new string[] { "abtr", "kwcd", "aaed", "qbca" }; output. Thank you for your interest... I've reorganized my code and tests. Can you check again.
Looks good.
Although some people just hardcode the answer when they can't get it to work only in 1 case, so random tests with duplicated would be nice too.
This comment has been hidden.
Added :)
Needs random tests.
Added
Need sample tests.
To kata author: You need to keep the tests in example tests in actual tests too, because they're separate code and are run in two different places!
Added