Ad
  • Custom User Avatar

    Solution set up should not contain any import.

    Also, I think it's better to add a line of code so the default set up code doesn't throw a compile error (for example return "" or return silly).

  • Custom User Avatar

    Thanks for the reply. Then I'm on the completly wrong track…

  • Custom User Avatar

    Time: 1682ms

    Golang version seems to be fine for me. You are not supposed to calculate the actual value of the factorial. Inputs go up to n=1000000000, and even with bigint, calculating it will take forever.

    I am going to close this as not a kata issue, because my Golang solution which uses exactly the same approach I used in other languages passed.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Also,

    strings.Split(s, " ") is equvalent to string.Fields(s)

  • Custom User Avatar

    I'd say the proper way is:

    import "unicode/utf8"
    
    utf8.RuneCountInString()
    

    Seen this on Go blog.
    Cheers :)

  • Custom User Avatar

    Please add another test case with unicode characters:
    {"lets add one unicode character → makes this more interesting", 1},
    {"lets add two unicode characters →→ makes this more interesting", 2},

    All the current test cases only cover the number of bytes of the shortest word!

  • Custom User Avatar

    This solutions doesn't account for unicode characters!
    E.g. len("→") => 2
    Use len([]rune("→") => 1

  • Custom User Avatar

    Yeah I am use to using buffer for strings coming from Java so searched docs for it from the get go, and after seeing the solutions look at the cheap oneliner in code to see what it was doing if anything and nope, just uses the string builder instead of bytes but affectivly the same iterative loop on a count. The only heads up thing was that it preemptively grew the size ahead of time so that if you were looping a large number of times it would not have to resize. https://github.com/golang/go/blob/master/src/strings/strings.go#L533-L536