6 kyu
search in multidimensional array
985 of 1,438bakula
Loading description...
Arrays
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.
This comment has been hidden.
seq = [['"&';""&';"', ']']] value = ']'
True should equal False
I don't understand. The sequence contains the ']' character, and I'm correctly identifying it. Why does the test case say this should be false?
I am not sure what the problem exactly wants. This is what I console.log() -ed arr => two,six,five,seven,three,nine ..//.. value => three and it returned [Should not find 'three']
There was also [not find element on 1st level] which I do not get at all. Does this mean I should not be looking for the value on the 1st level?
Thanks!
29 tests are passing only 1 test is failing. but this seems to return true. Is this the issue in kata itself? The below test is failing. I am wondering why. As my logic is returing true for the same. locate([[[[0],[[1],[[2],[[3],[[4],[[5],[[6],[[7],[[8],[[9],[[10],[[11],[[12],[[13],[[14],0.5577540242354748]]]]]]]]]]]]]]]]],0.5577540242354748)
Click here to get free honour points.
I have tested the same logic in dev tools console and it is working correctly.
specify language; i guess it;s js, isn't it?
yes in JS
This comment has been hidden.
Print the input values, see why.
got it ... THANKS!
I'm struggling a little bit to find a solution that works. I'm using re.findall but I'm always failing some of the random cases because I'm only looking for single quotation marks and ignoring the double marks.
Is this the right approach or should I look at a different way to flatten the list?
Thanks and great kata!
No, this is not the right way to flatten a list. Try to do it by recursion.
Thanks! I did it
I've run the same solution a couple times and have gotten different results in terms of how many of the test cases I get right
It is probably because some of the test cases are automatically generated
It worked for me by testing lists and tuples ; am I wrong ?
I assume the JavaScript array method 'flat' has been disabled? It doesn't seem to be working for me... I guess that makes sense, otherwise it would be a 'white' problem. But, even so, it would nice to be told so explicitly :)
No, it was not disabled. It's not available in Node 10.
"Not find element on 'x' level". What kind of useless test output messages are these? I can't see the input nor the output for some tests so I have NO idea how to debug. I'm finding so many crappy katas for JavaScript.
Can't you print the input with
console.log
?Ahh I see! I thought return would do it, as in other cases it did. Thanks.
Random tests can be improved by increasing the character set that it draws from; it should also include numbers and punctuation marks.
done
Python translation is inconsistent with the original JS kata, allowing solutions that wouldn't pass JS tests. Why remove edge case tests that were present in the original?
updated whole random suit
added back in missing fixed tests
Node 10.x should be enabled.
Some tests are still using expect. (JS)
Python translation
check :)
See above :)
This comment has been hidden.
I am getting 17 passed and one failed.
"find element not existing in array:,0.6680575974751264"
I have no idea how to fix this .
I am also getting the same message.
Needs tests with comma inside the strings:
Added.
I am getting 16 passed and one failed.
"not find element on ~15th level"
Any ideas on what this means?
Test that: locate(['a', ['b'], 'c'], 'c')
This comment has been hidden.
The first 'return' is wrong. Only if the recursive call returns true can you safely return at that point.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
I think Your function must be more precise... ",0.29164992761798203" !== "0.29164992761798203"
In fact :P Code works now.
Any hint about what I am doing wrong when I succesfully test this:
(I fail the last test)
Without your code it's rather hard to guess what is going on. Submit your code as a comment and mark it as "spoiler content".
This comment has been hidden.
Hi LuigiBakker. I'll try to explain what could be the problem(s) in your code without revealing too much to other warriers :)
First of all, notice the description talk about "value" not "string".
Second, once a value is found to exist somewhere in the input, there is no need to look further - simply return true.
While the desciption does not say you should not, the first operation inside your while loop, changes the array - changes the input, which can be a problem depending on how the test cases are built.
Hope this can lead you a little closer to solving this kata :)
Thank you
About your second point I believe I'm stopping my research when I find what I search.
Yes, you do but you can do it more direct: instead of 'res = xyz' and later 'return res' - you can write 'return xyz'. But that is really just a matter of consiseness and does not effect the overall solution.
I learned alot in this Kata
This comment has been hidden.
Description says 'Write a function named "find" that...' when I think it should say 'Write a function named "locate" that...' based on the examples and tests.
Also, under tags there's a typo: 'serach' should be 'search'.
Enjoyed it! Thanks for making.
correct, thanks
This comment has been hidden.
error descriptions updated, thank You.
This comment has been hidden.
good catch, we've got it.
Sorry man, I appreciate your correction but I must report that neither my new solution should pass, it would accept also a partial string match in a value, and would also return true against a comma (,) match. Please, believe me, I'm not that bad guy ;-). (Wow, I'll maybe hold the record of two rejected solutions in a single kata!!!)
nice, I've updated tests... now, this solution is not valid... can't wait for another hack ;)
For a 7th kyu kata, I believe this hack is a bit overdone, IMHO your test fixture can be considered valid. But just for fun, let me invite you to invalidate my solution, not in the simple way, that is, statically changing the order of the tests, but instead randomizing it (or, a bit harder, randomizing the input parameters and, accordingly, the expected return values). Don't worry, I think nearly half of the text fixtures (some of mine either) suffer the same limitation. Thanks for taking it sportively! ;-)
Nice, simple kata.
Minor change suggestion: correct the "Examle" typo in the description, and maybe add comment delimiters before the expected return statements in the examples. For example:
done, thanks!