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.
Scrutinized Tests
Reworded assertion messages
Removed reference solution's function
I just realized this
I like it !
Such an awesome solution! Well done!
I have no clue of what your code does, lol!
Yes. If the logical statement is never met then it would be an infinite loop. But in my case n would always equal to 0 at one point, so it terminates and return.
Will it return ret inside the loop given there is no return value outside of it?
Replace
seen := make(map[string]int, len(gloves))
toseen := make(map[string]int)
in my solution, and you will get identical benchmark.If you think what I have done is considered "clever" I have bad news for you..
These solutions that try and be clever and test for % 2 inside the loop are doing way too many tests. Here's the results:
BenchmarkKata2 is for this code. BenchmarkKata1 is for code that does not check inside the for loop, and has a separate for loop over the map to add "seen" / 2 to the total number of pairs.
"Clever" in codewars seems to be a positive mark. In reality, you don't want to be clever in your code. Especially with Go, one of the key values of the language is that it is straight-forward and simple. In this case, clever is not even faster, it is almost 50% slower.
Checkout my solution XD (critics are welcome)
from description: "Note: Don't worry, all inputs will be strings, and every string is a perfectly valid representation of an integral number." -> so I wouldn't worry about it, just as author wants us to :)
It is best practice to not ignore the error return value. See other solutions for some ways to respond to an error.
If
num
== 0 random test expect get 1 copy of word, as ifnum
was 1. Kate description say nothing about itapproved
Approved by someone
Loading more items...