7 kyu

Return substring instance count

2,005 of 8,204jhoffner
Description
Loading description...
Strings
Fundamentals
  • Please sign in or sign up to leave a comment.
  • tobeannouncd Avatar

    Haskell translation

    • Added fixed test to verify that matches do not overlap.
  • clivepato Avatar

    This comment has been hidden.

  • prstk Avatar

    This comment has been hidden.

  • Zofraa Avatar

    This comment has been hidden.

  • skvnikita Avatar

    This comment has been hidden.

  • yLaWy Avatar
  • gabigab117 Avatar

    This comment has been hidden.

  • Colgateinuntap Avatar

    Falsifiable (after 14 tests): "zzaaaza" "aaaz" 2 expected 2 but got 1

    I don't get this kata. How can you find "aaaz" from "zzaaaza" twice?

  • trashy_incel Avatar

    C translation (without overlap or empty substrings)

  • oldcoder Avatar

    this should be level 8 , no need to be 7

  • akar-0 Avatar

    The description doesn't say if we should count overlapping substrings. This should be stated and all versions should be coherent with it; currently there are no overlaps or they should not be counted in Python, but it's the contrary in Haskell and JS.

  • akar-0 Avatar

    In Haskell the substring may be empty, and we are supposed to return the full string length in that case. It doesn't make sense.

  • w-h-a Avatar

    This comment has been hidden.

  • user4896126 Avatar

    BROKEN KATA

  • nsticco Avatar

    Why does an empty string substring match length of the string times? Should this behavior be explicitly called out in the instructions?

  • Voile Avatar

    The tests need a complete rewrite to include random tests.

  • Arthé Avatar

    Issue on C# Can't submit my solution : fixture.cs(23,71): error CS0120: An object reference is required to access non-static member `Kata.SubstringCount(string, string)'

  • DestyNova Avatar

    In the testcases the function is called solution but in the function declaration it's solve.

  • KenKamau Avatar

    Haskell translation

    Please review and approve.

  • lechevalier Avatar

    Old and too simple... Nothing to gain for new Python players... Nothing to gain to translate it in Python except points on the leaderboard...

  • suic Avatar

    This comment has been hidden.

  • myjinxin2015 Avatar

    This should be a very old Kata, with the CW standard to measure it now, it is not qualified.

    It does not have example testcases,and random testcases, and the difficulty is not suitable as a 6kyu.

  • aassea12 Avatar

    Shouldn't there be a test case where some strings are uppercase? The more popular solutions would fail that case, wouldn't they?

  • Tunny Avatar

    I think this is a bit easy for a 6 Kyu.

  • smallbottle Avatar

    This comment has been hidden.

  • moorsiek Avatar

    Wow. The kata is that popular and old, but have some problems.

    #First Tests check too few cases. My solution had serious bug, but have passed the tests, because it's not too unlikely to pass only 4 tests when a solution does almost what it must.


    #Second The description doesn't state, what kind of text a solution must accept as input. Is it alpha-numeric only? Or is it a regular text - "Yo, man", "whatcha gonna do", etc.?

    It looks like most of people who solved the kata have considered code examples in the description as a hint like "no special characters here!". So the best solution is to state "Input string consists of a-z, A-Z, _ and space", for example.

  • Talne Avatar

    This comment has been hidden.

  • abadalyan Avatar

    How about adding empty string to possible searchText values? Test.expect(solution('aaaa','') == 0);

  • jakber Avatar

    Also Test.expect(solution('aaabb', '.') == 0, "solution should not assume search text is safe to use as a regular expression")

  • jhoffner Avatar

    Excellent suggestion. Adding that will break probably every single solution given. I think I might create a new, harder version of this kata that takes the following signature:

    solution(fullText, searchText, allowOverlap)
    

    Unless of course someone else is up for creating the new kata and earning the honor for doing it :)

  • r0ze Avatar

    Test.expect(solution('aaabb', 'aa') == 2, "solution should return correctly count overlapping search results ")