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.
My bad, I read
len(group)
instead oflen(set(group))
. Sorry about that. Still that makes it a bit puzzling to read.set(group) == set(range(1, 10))
is shorter, pythonic and more readable (in my humble opinion).They could also pass strings, booleans, bananas and unicorns to that function. In any case, the description says that it is guaranteed that the input is correct and has only valid values.
It will return False. Look closer... It tests the
len(set(group)) == 9
. So,len(set([2,2,3,3,5,6,7,8,9]))
will be 7.So, the method is perfectly safe.
What will valid([2,2,3,3,5,6,7,8,9]) return?
I think this test method is not safe.
But we are not told in the description that such values may be passed, only that 0-9 appear in the solutions to validate.
I think your valid(group) would accept sets with negative numbers/ number outside of range(1,10), such as (0,2,3,4,5,6,7,8, 10) which is definitely not valid