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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
No reason to panic, submitted inadvertently!
Nice solution, but
n > 0
can be omitted maybe?This comment is hidden because it contains spoiler information about the solution
I agree, sort_by_key is preferable. I honestly don't remember anything about this kata, but probably an unstable sort should also suffice? (Not in my solution obviously, but in the sort_by_key solution)
Because
&name[0..1]
is not a valid string if the first character spans multiple bytes.This comment is hidden because it contains spoiler information about the solution
The kata description is not very clear about the meaning of 'valid strings'.
Therefore, I would take it as 'any' string.
This solutions fails on the empty string as well as non-ASCII names like Иван
This comment is hidden because it contains spoiler information about the solution
m
is the maximum partition size. Sosub(5, 3)
calculates all partitions of 5 with no partition larger than 3.I assume you mean that
i % 2
returns-1
for negative odd numbers whereasi & 1
is positive. But I fail to see where behavior is different for even numbers. See https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1ba4abb31460c86f5c426d188672c5bbI think this solution might work for many problems. Isn't that kind of weird?!
It does a bitwise AND. As all odd numbers will have the final bit set and all even numbers not, this is a good test.
This is definitely an issue. As a workaround you can use the following template:
Loading more items...