6 kyu

Count word occurrences

265 of 268Uraza
Description
Loading description...
Strings
Algorithms
View
AllIssues3Questions2Suggestions1Show Resolved
  • Please sign in or sign up to leave a comment.
  • ejini战神 Avatar

    This comment has been hidden.

  • Gorgoroth Avatar

    Passed: 24 Failed: 0 Exit Code: 1 Shows timeout...is there a catch to the Kata that I have missed ?

  • cucubau3000 Avatar

    I pass the test cases. But when I submit I get 'TypeError: Cannot call method 'count' of undefined' and I really don't understand why. Can someone please give me a hint about what I'm doing wrong?

    • Uraza Avatar

      Your solution should be written inside the wordCounter function initially provided by the kata: is that what you did?

      var wordCounter = function(text) {
        // TODO - Add your implementation here
      };
      
      Question marked resolved by Uraza 9 years ago
  • ymaz Avatar

    Hi, nice Kata! But, I have the issue with last test case: "should not count punctuation as words". Could you please specify input text and word? After that i could figure out why my solution not passed. Many thanks!

  • alvaro893 Avatar

    Weird thing. My solution works with every test but it's rejected because it takes more than 6000 ms. That doesn't happen when I try my code in the browser console (it takes less than 1 sec with the long text "I am a bad bad bad algorithm because I do not use a cache...").

  • gperales Avatar

    This comment has been hidden.

  • gperales Avatar

    You are not testing if our implementations are using cache to avoid calculate count for already caculated word counts.

    • Uraza Avatar

      Hi.

      There was a "performance" test but it was apparently not sufficient for your solution to time out.

      I have slightly modified this test case, it should be good now.

      Thanks for pointing that out! :)

      Issue marked resolved by Uraza 9 years ago
    • gperales Avatar

      Yeah, thats solve the issue... but I have a new issue for you. I'm going to post it. We keep talking :)

  • everett980 Avatar

    Question is quite simple, probably level 7, but the means of calling it are over complex. Why not simply have a function with (str1, str2) and check if str1 is inside of str2?

    • Uraza Avatar

      The idea is to have the count performed once when setting up the wordCounter, instead of computing that information each time the count method is called.

      Issue marked resolved by Uraza 9 years ago
  • wthit56 Avatar

    Good job. A couple of minor suggestions:

    • I would add a note about how to handle a word that is just punctuation, however.
    • You could rename WordCounter to wordCounter. A common convention says that when the first letter is capitalised, the function is a constructor, which could cause confusion.
    • Instead of giving them heavy hints as comments and stub objects and so on, I'd just leave it open. I implemented my solution very differently to the way suggested.
    • Uraza Avatar

      Thanks for your valuable feedbacks, the code and description have been updated.

      Suggestion marked resolved by Uraza 10 years ago