Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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 ""
orreturn silly
).Thanks for the reply. Then I'm on the completly wrong track…
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.
This comment is hidden because it contains spoiler information about the solution
Also,
strings.Split(s, " ") is equvalent to string.Fields(s)
I'd say the proper way is:
Seen this on Go blog.
Cheers :)
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!
This solutions doesn't account for unicode characters!
E.g.
len("→")
=> 2Use
len([]rune("→")
=> 1Yeah 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