-
-
Notifications
You must be signed in to change notification settings - Fork 550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add commonised JSON to scrabble score problem #161
Conversation
"msg": "No, 'a' scores 1 point" | ||
}, | ||
{ | ||
"description": "Uppercase Short input", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Short/short
I think.
I have a few small comments, but nothing major. Thanks! |
@SwamWithTurtles Any chance you'll have time to make the changes on this one? I'd love to merge it. |
Implements the Scrabble Score exercise. As of right now there is no official test suite for Scrabble Score. There is a PR (exercism/problem-specifications#161), but it is not yet merged. I've put this exercise between the Nucleotides and Roman Numerals, figuring that it did similar character iteration and value mapping. I am following the test suite in that PR, with one exception. I thought it was likely that a common naive implementation would be to map through the chars, find the score and then simply unwrap the value. Like this ``` word.chars().map(|c| values.get(&c).fold(0, |sum, v| sum + v.unwrap()) ``` So I have added a test that uses a non-English character that will cause this implementation to panic. My example implementation probably leaves a lot to be desired. I wanted to make the values hash a static, but you can't do that with a hash. ([Lazy Static](http://rust-lang-nursery.github.io/lazy-static.rs/lazy_static/index.html) does let you do this, but I'm not going to require a crate in my example).
I'm working on implementing this in Rust, and I've followed this proposed PR. But I added one test for the edge case of Non-English characters: https://github.com/exercism/xrust/pull/125/files#diff-26a63b91a0b305a1fd995e76a5ef5ad2R54 Though this is particularly useful in Rust (or other languages with Optional types), I can it being a useful test in other languages as well. |
Superseded by #255 - thanks for your work on this one @SwamWithTurtles! |
Implements the Scrabble Score exercise. As of right now there is no official test suite for Scrabble Score. There is a PR (exercism/problem-specifications#161), but it is not yet merged. I've put this exercise between the Nucleotides and Roman Numerals, figuring that it did similar character iteration and value mapping. I am following the test suite in that PR, with one exception. I thought it was likely that a common naive implementation would be to map through the chars, find the score and then simply unwrap the value. Like this ``` word.chars().map(|c| values.get(&c).fold(0, |sum, v| sum + v.unwrap()) ``` So I have added a test that uses a non-English character that will cause this implementation to panic. My example implementation probably leaves a lot to be desired. I wanted to make the values hash a static, but you can't do that with a hash. ([Lazy Static](http://rust-lang-nursery.github.io/lazy-static.rs/lazy_static/index.html) does let you do this, but I'm not going to require a crate in my example).
Pre-Push and local check setup.
No description provided.