rustlings icon indicating copy to clipboard operation
rustlings copied to clipboard

Canonical Solutions

Open dustinroepsch opened this issue 3 years ago • 6 comments

Hello!

It would be great if after you complete a file, it showed you a "good" solution. Sometimes it's hard to tell if I cheated on accident, or didn't learn the lesson I was supposed to.

The hints feature is great and kinda serves this purpose, but I'd still appreciate solutions to the problems after I do them myself :)

dustinroepsch avatar Aug 11 '21 18:08 dustinroepsch

I'm voting for this! 🌻

It's nice to see different ways to solve a problem, we can even put several solutions for each exercise.

For example - primitive_types3.rs Creating an array with at least 100 elements- a short Google search would yield something like:

let a = [0; 500];

but the hints also say:

Bonus: what are some other things you could have that would return true for a.len() >= 100?

I didn't have any idea.. and it'd be cool to encounter a different approach :)

itayperry avatar Jan 28 '22 17:01 itayperry

@itayperry I guess taking advantage of rust's awesome features like monomorphization, std, core, generics, traits, etc, is the way to go.

kaiuri avatar Jan 29 '22 00:01 kaiuri

@kaiuri I just started learning :) so it would take a while. In short, regarding the issue at hand, I'm absolutely up for adding canonical solutions for all the exercises.

itayperry avatar Jan 30 '22 06:01 itayperry

@kaiuri I just started learning :) so it would take a while. In short, regarding the issue at hand, I'm absolutely up for adding canonical solutions for all the exercises.

Hmmm... I think Rust is too expressive for canonical, maybe the most idiomatic solution would result in something approaching uniqueness.

kaiuri avatar Feb 06 '22 21:02 kaiuri

Possible duplicate of #293

rytheo avatar Feb 07 '22 04:02 rytheo

That would be such a great feature! Rustlings is a awesome for learning the language but it would be great to compare ones own solution with an idiomatic "optimal" solution

pbaettig avatar Mar 28 '22 20:03 pbaettig