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.
In the solution,
var output []int
would be my pick. We don't need to allocate if there's nothing to do. See https://github.com/golang/go/wiki/CodeReviewComments#declaring-empty-slices.Test 4 should test
len(output) == 0
since either[]int{}
ornil
would fit the criteria (nil
would be more idiomatic). Failing the hidden test case for returningnil
instead of[]int{}
would be very annoying.Go comes with testing built-in, the use of an external testing library seems unnecessary.
reflect.DeepEqual(want, got)
would be enough for Tests 1-3, andlen(got) == 0
for Test 4, or the negation of these to signal test failure.Two alternate ways to write the loop: