Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Scala translation
There should be fixed test cases for multiple plateaus I think
CoffeeScript translation
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Ok bud. Don't delete this kata, but can you add a better description please? Add examples when the data array comes with zeros and negative numbers. It will save time for many people. Thanks
For those wondering what the definition of a peak is in this question (which could be more specifically notes):
The values immediately left and right of the "peak" have to be less than it.
The plateau description is fine.
This comment is hidden because it contains spoiler information about the solution
I did this in Java.
In my opinion, the sample tests for this kata should be rewritten.
Some of the test failure messages are the same even though what is being tested is different, making it difficult to tell which test you have failed. Critically, the tests do not test for arrays where values are repeated but are not plateaus; this isn't mentioned in the description either, so it's not clear that this is a problem until you go to attempt the kata and get failures there. At the very least, the description should be updated to account for this.
I can understand why the tests have been conducted in a single @Test block, but I don't think it results in a well written test. Sure, it makes the code shorter, but shorter isn't always better if the result is confusing to anyone who has to look at the code later. Splitting them into seperate tests means the logs are also split, making debugging problems a whole lot easier, especially with the Codewars UI we are using here.
I have included the tests I wrote below, and you can judge for yourself.
Nice kata. Maybe the description should mention that the returned object needs to have the peaks sorted into the same order in which they occurred in the original array?
COBOL translation (author is inactive).
This comment is hidden because it contains spoiler information about the solution
There might be something wrong with the random tests in php.
I pass all tests except random, where I get a timeout (over 12000 ms), using my code elsewhere (online php sandbox) on a random array with 95 peaks, looped 100 times, results in: "Total execution time in seconds: 0.085011005401611". I have a
for
loop which contains two very shortforeach
loops for the before and after arrays. Both have breaks and the second does not get used if the first fails. There doesn't seem to be anything to optimise out.Logging to STDOUT, it seems that the random test fails at 293 arrays being generated, but without any of them actually passing through the function (I get 293 '1's and no arrays using
fwrite(STDOUT, print_r($arr));
before my timeout, while passed tests give me one '1' per array, then the actual arrays are printed, as expected).I am having a problem with the use of global variables, out the box my code works correctly, but here in the tests, it fails flat out in all the tests. I have tested with different versions of python and in all of them, it works correctly.
[spellmell@nexus codewars]$ python3.8 15_pick_peaks.py
[7, 9, 5, 0, 7, 9, 9, 8, 6]
pos:[1, 5]
peaks:[9, 9]
python 3.8.12 (default, Aug 30 2021, 00:00:00)
[GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
[spellmell@nexus codewars]$ python3.9 15_pick_peaks.py
[7, 8, 9, 5, 4, 0, 4, 2, 3]
pos:[2, 6]
peaks:[9, 4]
python 3.9.9 (main, Nov 19 2021, 00:00:00)
[GCC 11.2.1 20210728 (Red Hat 11.2.1-1)]
[spellmell@nexus codewars]$ python3.10 15_pick_peaks.py
[6, 1, 0, 3, 4, 8, 7, 2, 8]
pos:[5]
peaks:[8]
python 3.10.1 (main, Dec 7 2021, 00:00:00) [GCC 11.2.1 20211203 (Red Hat 11.2.1-7)]
Here: Time: 500ms Passed: 0 Failed: 10 Exit Code: 1
It is confirmed that the problem is the global variables, when removing them the code works.
I was reading the "troubleshooting" page, and I see that there is some reference to the problem, but
I can't understand. Any suggestions on how I can solve it?
Please, NASM Translation
Loading more items...