you are hardcoding the amount of memory, even though the amount is dynamic and depends on the input. you do not allocate enough memory for large n and write out of bounds, hence the crash
strpos works correctly. You have to ask yourself what strpos will evaluate to when the character in question is a, and what that means in an if condition.
Well, it looks like you never submitted your solution, this kata is not listed in the "kata" tab on your profile. You might want to go into the trainer and hit "attempt" and submit it.
I'd love to have the tasks of the same difficulty on my job.
I like simple explanation what to do but only came up with loop solution.
Haskell translation
Diamonds are forever
you are hardcoding the amount of memory, even though the amount is dynamic and depends on the input. you do not allocate enough memory for large
n
and write out of bounds, hence the crashtoo late now with more than 10 languages and 37,000 completions
added
No random tests in Java
strpos
works correctly. You have to ask yourself whatstrpos
will evaluate to when the character in question isa
, and what that means in anif
condition.This comment is hidden because it contains spoiler information about the solution
thanks!
Well, it looks like you never submitted your solution, this kata is not listed in the "kata" tab on your profile. You might want to go into the trainer and hit "attempt" and submit it.
Oh, I fixed it with my teacher. I forgot to return the variable and instead printed it.
Your code passes the tests for me. Do you get an error or anything?
when I test the code it comes up with the right answers but still marks it incorrect :(
Loading more items...