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.
Very idiomatic... I like it!
The code is short, very slick, but all those strings!
That's very nice... I did the same logic but missed the application of fold, which is elegant.
A very elegant solution if I may say so, distinguishing the square that may arise in processing from a square supplied as initall argument.
In Rust, types str and String are Unicode strings, with varialbe sized chars, so you can't index into them or easily determine their length in chars or graphemes. The len() method is the length in bytes. The only way to reliably process a Unicode string is to iterate from the start. All the solutions to this in Rust which make use of len() are vulnerable to Unicode strings with multibyte chars.
This is just an old answer, so its had a long time to slowly accumulate votes. There's no generic upvote, you either vote for best practice or clever, and this is definitely NOT clever.
It's also rust, which very few people truly understand (certainly including me) so many people don't know what they're looking at.
That being said, I haven't ever used C and C++ only like 15 years ago, so this is more just general procedural language not really C/C++. But yeah, there are definitely more concise ways of doing this in rust, considering it's awesome methods on iterables.
Several upticks for 'Best Practices' which I don't understand. This is exactly a C/C++ solution transscribed into Rust, it works but is not idiomatic Rust. I'd therefore say NOT best practice.