6 kyu
Needles in a haystack
388 of 390NiklasE
Loading description...
Algorithms
Fundamentals
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.
Global
obj
object is created which can be overwritten by accident.I had to sort my results, but it wasn't specified in the description.
Return value should be a sorted array.
- it says that in the description.True, sorry :)
No random tests.
Mine passes the last 3 tests but not the main first one. If I change the return array so that it fits the format of the first test case, it does not work for the last 2. It just doesnt make sense to me how the order of the first test, is the exact opposite of what the other tests require. Hope you have a tip for how to solve this.
Returned array should be sorted alphabetically. Usually sorted (string) arrays refer to alphabetically ordered arrays if there is no mention of how it should be sorted. Leave me a reply if this does not help you forward.
This comment has been hidden.
Well, yeah, you are right. Great to hear that you solved it. I'll mark this issue as resolved.
'Did you check for invalid values?'. What does this mean? What invalid values?
You probably have invalid values in your return value? You can also use logging in all of the katas... Hope this helps you forward.
You are storing the results in global scope, so any preceding function calls will cause the previously unnecessary values to accumulate.
I have my code giving the correct answer on repl.it, but this kana is giving me "Unknown Error." Unless I'm just noticing that auto indent doesn't work and that you can't paste code, the site's gotten a bit buggy. the only code I've tried to paste is where I left off with this challenge last night. What should I do next? Post my code here for help?
Hi, I'm not quite sure if this is an issue with this specific kata or the site. Did you try to modify and resubmit your code after you pasted it? Are you sure there's no errors in your code? You can always use logging in all of the katas, so maybe it could help you forward.
Logging? Is there a way to see the console on this site that I have't found yet? I'm pretty sure this is an issue with the kata. It says unknown error if I just return an empty array.
This comment has been hidden.
Oh! I see where the console logging is now. Thanks for that!
No problem! Just remember to remove those logging rows when you are submitting the final solution :) Did you get a grasp of what might be causing the error?
Console.log helped, but the issue I'm lost on is that I'm using global variables. The challenge doesn't make it clear how the haystack and needle are coming through. Are the tests running search(object, needle) or am I supposed to run it in my script? I found that console.log(obj) logs an object, but how do I log the needle when I don't have a variable to call it?
This comment has been hidden.
Ok, I think I get it now. The explanation should probably be more clear, particularly just explain how the needle and haystack will be called for someone who's still getting used to this level. I was able to get the errors to go away, but the final solution I give has the array in the wrong order. The instructions didn't mention order mattering.
Great to hear that you solved it! I think the basics of this site should be explained in the general docs. It's not pretty convenient to have users explaining them over and over when creating katas. You probably would get at least some insight from http://codewars.com/docs
It is actually mentioned in the description that the return value should be a sorted array. Usually sorted (string) arrays refer to arrays sorted by Unicode code points or alphabetically (almost the same thing). In addition there is an example in the description.
I'll mark this issue as resolved for now.
Fair enough. Actually in retrospect, I noticed that I seem to understand the instructions now in the context I understand them now, moreso than when I started. I don't know if there is a term or phrase to describe this, but I might have just gotten caught up in the unfamiliarity of the problem until I solved it. Thanks for heling me out.
Nice and decent Kata. Made me wonder though should the value from function be included or not. Points for the Lovecraftian grammar! ;)
This comment has been hidden.
This comment has been hidden.
Unless the response being a comma separated string is important for some reason, might I suggest the response being an array of the object properties instead?
This would be much more practical in a real-world scenario, and it makes validity checks easier when the desired order of the properties is not specified (as is the case in your description), or cannot easily be ensured.
I changed the solution/description a little bit. Now the return value should be a sorted array.