6 kyu

Needles in a haystack

388 of 390NiklasE
Description
Loading description...
Algorithms
Fundamentals
View
AllIssues5Questions1SuggestionsShow Resolved
  • Please sign in or sign up to leave a comment.
  • KonradLinkowski Avatar

    Global obj object is created which can be overwritten by accident.

  • KonradLinkowski Avatar

    I had to sort my results, but it wasn't specified in the description.

  • FArekkusu Avatar

    No random tests.

  • juliankolbe Avatar

    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.

    • NiklasE Avatar

      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.

    • juliankolbe Avatar

      This comment has been hidden.

    • NiklasE Avatar

      Well, yeah, you are right. Great to hear that you solved it. I'll mark this issue as resolved.

      Issue marked resolved by NiklasE 9 years ago
  • cucubau3000 Avatar

    'Did you check for invalid values?'. What does this mean? What invalid values?

    • NiklasE Avatar

      You probably have invalid values in your return value? You can also use logging in all of the katas... Hope this helps you forward.

    • ejini战神 Avatar

      You are storing the results in global scope, so any preceding function calls will cause the previously unnecessary values to accumulate.

      Question marked resolved by ejini战神 12 months ago
  • Philosophist Avatar

    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?

    • NiklasE Avatar

      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.

    • Philosophist Avatar

      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.

    • NiklasE Avatar

      This comment has been hidden.

    • Philosophist Avatar

      Oh! I see where the console logging is now. Thanks for that!

    • NiklasE Avatar

      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?

    • Philosophist Avatar

      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?

    • NiklasE Avatar

      This comment has been hidden.

    • Philosophist Avatar

      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.

    • NiklasE Avatar

      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.

      Issue marked resolved by NiklasE 9 years ago
    • Philosophist Avatar

      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.

  • Alex- Avatar

    Nice and decent Kata. Made me wonder though should the value from function be included or not. Points for the Lovecraftian grammar! ;)

  • OverZealous Avatar

    This comment has been hidden.

  • colbydauph Avatar

    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.