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.
Hey thanks for translating this, I had fun solving it!
My only suggestion is that the function signature look more like this:
Here's my reasoning:
bool
rather thanu8
because any value except 0 or 1 are invalid for this problem.n
would be ever so slightly nicer to work with if it were ausize
. This allows the implementor to compute max allocation sizes without having to cast tousize
themself.Vec
is necessarily the best datastructure to return. For instance, I foundVecDeque
s easier to use since the world could be extended efficiently. It would also allow the use ofBTreeMap<usize, bool>
s (or some other ordered map) to be used, which some might find more ergonomic.list
) is provided as a slice because that places the responsibility of allocating the input on the caller, not the implementor, but prevents mutation (like if aVec
were provided instead).I've reviewed your solution and tests, and I've written a working Haskell solution, does that count?
Looks good to me. I hope this gets approved!
Have you heard of that cool thing where an
Iterator<Item = Option/Result<T>>
can becollect
ed into aOption/Result<Vec<T>>
? I think it would let you say.collect().unwrap()
instead of.map(Option::unwrap).collect()
.Nice! I wish
slice::array_windows
was stable, that would let you do something like:Nice!