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.
The
collect
step is unnecessary—you can chain iterator transformation operations such asmap()
, i.e. you can domap(...).sum()
.This solution assumes
s
is entirely in ASCII, but Rust strings are UTF-8. For instance,find_short("ø")
will return 2, because ø uses two bytes in UTF-8, but its length is only 1.It will panic. However, the kata says
String will never be empty
, so it's a safe optimization.If you're starting with an empty String, you might as well do
String::new()
instead ofString::from("")
.This comment is hidden because it contains spoiler information about the solution