6 kyu
Prefix Permutation
53 of 117medmelki
Loading description...
Performance
Algorithms
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.
I don't think it should print the result. This should be changed.
The only performance tests are fixed, and they can be easily hardcoded allowing non-optimal solutions to pass.
Added random tests. Guess work solutions killed.
I think must be test case like
[-5,-3,-2,-4,-1] equal 3
Approved
Typo in Java Sample test - wrong number params to prefix
assertEquals(PrefixPermutation.prefix(3, new int[]{2, 1, 3, 5, 4}));
Fixed
Please, add details on the assumptions about the input array such as it containing only positive integers, without repetition, or add some tests.
Also precise input array could be large.
Could do with a
performance
tag.My perfectly servicable solution chokes on
50000
element arrays.Edited!
To me the harder part to understand was how your example worked. May be a more detailled example would help other non-mathy-coders like me :
; ) )
Thank you for the comment. I have considered that.
where is the solution?
Interesting one.
But you have to provide some fixed tests OF REASONABLE SIZE, in which you print the array to the console so that the warrior can debug is code. Currently, you use arrays that are too long to be displayed in the console. Note that you have to do the printing because if the warrior does it in his code, the big tests will be displayed too and that will provoque a failure.
You know, you can always add
if(arr.length < x)
in your printing code ;-)There should be tests with numbers less than 1 and greater than length, like
{-1, 4, 3, -99, 100}
. Some solutions don't work in these cases.I agree, some solutions return
1
for[2, 2, 2]
...Added a few fixed tests that will catch them.
And finally, needs random tests.
Done
Expected and actual arguments in the test function are flipped.
Done
In the sample tests too.
Edited!
Initial code is for placing code templates, not test descriptions.
Done