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.
the paramter
reels
should beconst char *const[]
in C, as the user is not supposed to mutate itI implemented this method in the editor, then copied it here.
JavaScript:
that's because there are no sample tests in JavaScript, re-raising
on the first iteration of your
while
loop you callstrlen()
on uninitialized memory returned bymalloc()
(it is not guaranteed to be zeroed)the code you posted crashes on an empty list, as it dereferences
NULL
your new code passes the tests most of the time, though it allocates a static amount of memory that is not always enough for the return string
;-)
dc
at this point of your program ?realloc()
does not expand a buffer. it allocates what you requested, no more, no less. if the new size is less than the old one, the buffer will shrink.okay, it seems that the translator fixed the original translation, but this has no effect on the kata. i guess this is the reason for the useless double use of
Math.abs()
I cannot approve yet, the author is active :(
gotta wait 7 days...
It seems that you edited this fork post-approval to fix the issues i raised. I'm letting you know that this has no effect on the kata; post-approval you need to either use the
edit
button on the kata, not the translation to enter the kata editor, make your changes and re-publish the kata; OR make a new fork (preferably using the kata'sfork
button since it pulls the up-to-date version, instead of forking the translation that may be obsolete) and submit it for review/approval.I know it's confusing, and it's an oversight that Codewars allows us to edit a fork post-approval since it's useless and confusing, but that's the way it is.
ideally there should be some explanation in the initial code, yes. you can open a suggestion to request that.
i'd rather shuffle
hat_options
and then iterate on it than randomly select an element for it; this way all combinations are tested while still making hardcoding more tedious than writing a legitimate solutionbecause it's better to use enumerated types in languages that support them. the reasons
enum
s are rarely used on Codewars are 1) some translators are not aware of what is most idiomatic in their language of choice and 2) the first languages available on Codewars (JavaScript, Python, Ruby) do not have language support forenum
s¹, so they used string constants instead, and translators to other langauges replicated this interface most of the time.¹: Python now has an
enum
module, but it's a library and not a language constructokay I forked the kata and I think I fixed it but idk how to get the fix published
Yes, this! Especially the second one. I spent hours attempting this kata before realizing the reference implementation is the one that is wrong, not my code.
As long as the test remains broken the way they currently are, the quickfix for passing the broken tests would be to throw out all negative numbers that are also odd.
I'm guessing the mistake made was thinking that
i % 2 == 1
holds for all odd numbers; actually: a negative odd number% 2
== -1Loading more items...