commit ff1c36fc249b9ce49b9d2c2ae21e57114281938e Author: Arthur DANJOU Date: Thu Aug 4 23:58:25 2022 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a996b18 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Project exclude paths +/low-power-embedded-game/target/ +/magazine-cutout/target/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..8e518a5 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/rust.iml b/.idea/rust.iml new file mode 100644 index 0000000..e48cfe5 --- /dev/null +++ b/.idea/rust.iml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/all-your-base/.exercism/config.json b/all-your-base/.exercism/config.json new file mode 100644 index 0000000..e1efc23 --- /dev/null +++ b/all-your-base/.exercism/config.json @@ -0,0 +1,36 @@ +{ + "blurb": "Convert a number, represented as a sequence of digits in one base, to any other base.", + "authors": [ + "jonasbb" + ], + "contributors": [ + "CGMossa", + "coriolinus", + "cwhakes", + "efx", + "ErikSchierboom", + "IanWhitney", + "lutostag", + "mkantor", + "navossoc", + "nfiles", + "pedantic79", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/all-your-base.rs" + ], + "example": [ + ".meta/example.rs" + ] + } +} diff --git a/all-your-base/.exercism/metadata.json b/all-your-base/.exercism/metadata.json new file mode 100644 index 0000000..be13f51 --- /dev/null +++ b/all-your-base/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"all-your-base","id":"22568dbd27034998a766c1e5833e585d","url":"https://exercism.org/tracks/rust/exercises/all-your-base","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/all-your-base/.gitignore b/all-your-base/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/all-your-base/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/all-your-base/Cargo.toml b/all-your-base/Cargo.toml new file mode 100644 index 0000000..8ecd110 --- /dev/null +++ b/all-your-base/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "allyourbase" +version = "1.0.0" diff --git a/all-your-base/HELP.md b/all-your-base/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/all-your-base/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/all-your-base/README.md b/all-your-base/README.md new file mode 100644 index 0000000..02a5675 --- /dev/null +++ b/all-your-base/README.md @@ -0,0 +1,62 @@ +# All Your Base + +Welcome to All Your Base on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Convert a number, represented as a sequence of digits in one base, to any other base. + +Implement general base conversion. Given a number in base **a**, +represented as a sequence of digits, convert it to base **b**. + +## Note + +- Try to implement the conversion yourself. + Do not use something else to perform the conversion for you. + +## About [Positional Notation](https://en.wikipedia.org/wiki/Positional_notation) + +In positional notation, a number in base **b** can be understood as a linear +combination of powers of **b**. + +The number 42, *in base 10*, means: + +(4 * 10^1) + (2 * 10^0) + +The number 101010, *in base 2*, means: + +(1 * 2^5) + (0 * 2^4) + (1 * 2^3) + (0 * 2^2) + (1 * 2^1) + (0 * 2^0) + +The number 1120, *in base 3*, means: + +(1 * 3^3) + (1 * 3^2) + (2 * 3^1) + (0 * 3^0) + +I think you got the idea! + +*Yes. Those three numbers above are exactly the same. Congratulations!* + +## Source + +### Created by + +- @jonasbb + +### Contributed to by + +- @CGMossa +- @coriolinus +- @cwhakes +- @efx +- @ErikSchierboom +- @IanWhitney +- @lutostag +- @mkantor +- @navossoc +- @nfiles +- @pedantic79 +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton \ No newline at end of file diff --git a/all-your-base/src/lib.rs b/all-your-base/src/lib.rs new file mode 100644 index 0000000..3f30163 --- /dev/null +++ b/all-your-base/src/lib.rs @@ -0,0 +1,68 @@ +#[derive(Debug, PartialEq, Eq)] +pub enum Error { + InvalidInputBase, + InvalidOutputBase, + InvalidDigit(u32), +} + +/// +/// Convert a number between two bases. +/// +/// A number is any slice of digits. +/// A digit is any unsigned integer (e.g. u8, u16, u32, u64, or usize). +/// Bases are specified as unsigned integers. +/// +/// Return an `Err(.)` if the conversion is impossible. +/// The tests do not test for specific values inside the `Err(.)`. +/// +/// +/// You are allowed to change the function signature as long as all test still pass. +/// +/// +/// Example: +/// Input +/// number: &[4, 2] +/// from_base: 10 +/// to_base: 2 +/// Result +/// Ok(vec![1, 0, 1, 0, 1, 0]) +/// +/// The example corresponds to converting the number 42 from decimal +/// which is equivalent to 101010 in binary. +/// +/// +/// Notes: +/// * The empty slice ( "[]" ) is equal to the number 0. +/// * Never output leading 0 digits, unless the input number is 0, in which the output must be `[0]`. +/// However, your function must be able to process input with leading 0 digits. +/// +pub fn convert(number: &[u32], from_base: u32, to_base: u32) -> Result, Error> { + if from_base < 2 { + return Err(Error::InvalidInputBase); + } + if to_base < 2 { + return Err(Error::InvalidOutputBase); + } + + let mut value: u32 = 0; + for &n in number.iter() { + if n >= from_base { + return Err(Error::InvalidDigit(n)) + } else { + value = value * from_base + n; + } + } + + let mut result = Vec::new(); + while value != 0 { + result.push(value % to_base); + value /= to_base; + } + + if result.is_empty() { + result.push(0); + } + + result.reverse(); + Ok(result) +} diff --git a/all-your-base/tests/all-your-base.rs b/all-your-base/tests/all-your-base.rs new file mode 100644 index 0000000..9012a40 --- /dev/null +++ b/all-your-base/tests/all-your-base.rs @@ -0,0 +1,216 @@ +use allyourbase as ayb; + +#[test] +fn single_bit_one_to_decimal() { + let input_base = 2; + let input_digits = &[1]; + let output_base = 10; + let output_digits = vec![1]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn binary_to_single_decimal() { + let input_base = 2; + let input_digits = &[1, 0, 1]; + let output_base = 10; + let output_digits = vec![5]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn single_decimal_to_binary() { + let input_base = 10; + let input_digits = &[5]; + let output_base = 2; + let output_digits = vec![1, 0, 1]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn binary_to_multiple_decimal() { + let input_base = 2; + let input_digits = &[1, 0, 1, 0, 1, 0]; + let output_base = 10; + let output_digits = vec![4, 2]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn decimal_to_binary() { + let input_base = 10; + let input_digits = &[4, 2]; + let output_base = 2; + let output_digits = vec![1, 0, 1, 0, 1, 0]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn trinary_to_hexadecimal() { + let input_base = 3; + let input_digits = &[1, 1, 2, 0]; + let output_base = 16; + let output_digits = vec![2, 10]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn hexadecimal_to_trinary() { + let input_base = 16; + let input_digits = &[2, 10]; + let output_base = 3; + let output_digits = vec![1, 1, 2, 0]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn fifteen_bit_integer() { + let input_base = 97; + let input_digits = &[3, 46, 60]; + let output_base = 73; + let output_digits = vec![6, 10, 45]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn empty_list() { + let input_base = 2; + let input_digits = &[]; + let output_base = 10; + let output_digits = vec![0]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn single_zero() { + let input_base = 10; + let input_digits = &[0]; + let output_base = 2; + let output_digits = vec![0]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn multiple_zeros() { + let input_base = 10; + let input_digits = &[0, 0, 0]; + let output_base = 2; + let output_digits = vec![0]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn leading_zeros() { + let input_base = 7; + let input_digits = &[0, 6, 0]; + let output_base = 10; + let output_digits = vec![4, 2]; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Ok(output_digits) + ); +} + +#[test] +#[ignore] +fn invalid_positive_digit() { + let input_base = 2; + let input_digits = &[1, 2, 1, 0, 1, 0]; + let output_base = 10; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Err(ayb::Error::InvalidDigit(2)) + ); +} + +#[test] +#[ignore] +fn input_base_is_one() { + let input_base = 1; + let input_digits = &[]; + let output_base = 10; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Err(ayb::Error::InvalidInputBase) + ); +} + +#[test] +#[ignore] +fn output_base_is_one() { + let input_base = 2; + let input_digits = &[1, 0, 1, 0, 1, 0]; + let output_base = 1; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Err(ayb::Error::InvalidOutputBase) + ); +} + +#[test] +#[ignore] +fn input_base_is_zero() { + let input_base = 0; + let input_digits = &[]; + let output_base = 10; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Err(ayb::Error::InvalidInputBase) + ); +} + +#[test] +#[ignore] +fn output_base_is_zero() { + let input_base = 10; + let input_digits = &[7]; + let output_base = 0; + assert_eq!( + ayb::convert(input_digits, input_base, output_base), + Err(ayb::Error::InvalidOutputBase) + ); +} diff --git a/anagram/.exercism/config.json b/anagram/.exercism/config.json new file mode 100644 index 0000000..779665b --- /dev/null +++ b/anagram/.exercism/config.json @@ -0,0 +1,47 @@ +{ + "blurb": "Given a word and a list of possible anagrams, select the correct sublist.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "bobahop", + "chancancode", + "ClashTheBunny", + "coriolinus", + "cwhakes", + "Dimkar3000", + "EduardoBautista", + "efx", + "ErikSchierboom", + "gris", + "IanWhitney", + "kytrinyx", + "lutostag", + "mkantor", + "nfiles", + "petertseng", + "pminten", + "quartsize", + "rofrol", + "stevejb71", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/anagram.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/anagram/.exercism/metadata.json b/anagram/.exercism/metadata.json new file mode 100644 index 0000000..a884ed2 --- /dev/null +++ b/anagram/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"anagram","id":"5abb5b06fa2749eb88cee51e987ac255","url":"https://exercism.org/tracks/rust/exercises/anagram","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/anagram/.gitignore b/anagram/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/anagram/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/anagram/Cargo.toml b/anagram/Cargo.toml new file mode 100644 index 0000000..5e06e4e --- /dev/null +++ b/anagram/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "anagram" +version = "0.0.0" diff --git a/anagram/HELP.md b/anagram/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/anagram/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/anagram/README.md b/anagram/README.md new file mode 100644 index 0000000..e6be820 --- /dev/null +++ b/anagram/README.md @@ -0,0 +1,61 @@ +# Anagram + +Welcome to Anagram on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +An anagram is a rearrangement of letters to form a new word. +Given a word and a list of candidates, select the sublist of anagrams of the given word. + +Given `"listen"` and a list of candidates like `"enlists" "google" +"inlets" "banana"` the program should return a list containing +`"inlets"`. + +The solution is case insensitive, which means `"WOrd"` is the same as `"word"` or `"woRd"`. It may help to take a peek at the [std library](https://doc.rust-lang.org/std/primitive.char.html) for functions that can convert between them. + +The solution cannot contain the input word. A word is always an anagram of itself, which means it is not an interesting result. Given `"hello"` and the list `["hello", "olleh"]` the answer is `["olleh"]`. + +You are going to have to adjust the function signature provided in the stub in order for the lifetimes to work out properly. This is intentional: what's there demonstrates the basics of lifetime syntax, and what's missing teaches how to interpret lifetime-related compiler errors. + +Try to limit case changes. Case changes are expensive in terms of time, so it's faster to minimize them. + +If sorting, consider [sort_unstable](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable) which is typically faster than stable sorting. When applicable, unstable sorting is preferred because it is generally faster than stable sorting and it doesn't allocate auxiliary memory. + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @bobahop +- @chancancode +- @ClashTheBunny +- @coriolinus +- @cwhakes +- @Dimkar3000 +- @EduardoBautista +- @efx +- @ErikSchierboom +- @gris +- @IanWhitney +- @kytrinyx +- @lutostag +- @mkantor +- @nfiles +- @petertseng +- @pminten +- @quartsize +- @rofrol +- @stevejb71 +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup \ No newline at end of file diff --git a/anagram/src/lib.rs b/anagram/src/lib.rs new file mode 100644 index 0000000..017ac1c --- /dev/null +++ b/anagram/src/lib.rs @@ -0,0 +1,25 @@ +use std::collections::HashSet; + +pub fn anagrams_for<'a>(word: &str, possible_anagrams: &[&'a str]) -> HashSet<&'a str> { + let to_lowercase_s = |c: char| { + if !c.is_lowercase() { + c.to_lowercase().to_string() + } else { + c.to_string() + } + }; + + let lw: Vec<_> = word.chars().map(to_lowercase_s).collect(); + let mut sc: Vec<_> = word.chars().map(to_lowercase_s).collect(); + sc.sort_unstable(); + + let result = possible_anagrams.iter() + .filter(|w| { + let mut sci: Vec<_> = w.chars().map(to_lowercase_s).collect(); + let same_word = lw == sci; + sci.sort_unstable(); + sci == sc && !same_word + }).map(|&w| w); + + HashSet::from_iter(result) +} diff --git a/anagram/tests/anagram.rs b/anagram/tests/anagram.rs new file mode 100644 index 0000000..6fbb009 --- /dev/null +++ b/anagram/tests/anagram.rs @@ -0,0 +1,186 @@ +use std::collections::HashSet; + +fn process_anagram_case(word: &str, inputs: &[&str], expected: &[&str]) { + let result = anagram::anagrams_for(word, inputs); + + let expected: HashSet<&str> = expected.iter().cloned().collect(); + + assert_eq!(result, expected); +} + +#[test] +fn test_no_matches() { + let word = "diaper"; + + let inputs = ["hello", "world", "zombies", "pants"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_detect_simple_anagram() { + let word = "ant"; + + let inputs = ["tan", "stand", "at"]; + + let outputs = vec!["tan"]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_does_not_confuse_different_duplicates() { + let word = "galea"; + + let inputs = ["eagle"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_eliminate_anagram_subsets() { + let word = "good"; + + let inputs = ["dog", "goody"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_detect_anagram() { + let word = "listen"; + + let inputs = ["enlists", "google", "inlets", "banana"]; + + let outputs = vec!["inlets"]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_multiple_anagrams() { + let word = "allergy"; + + let inputs = [ + "gallery", + "ballerina", + "regally", + "clergy", + "largely", + "leading", + ]; + + let outputs = vec!["gallery", "regally", "largely"]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_case_insensitive_anagrams() { + let word = "Orchestra"; + + let inputs = ["cashregister", "Carthorse", "radishes"]; + + let outputs = vec!["Carthorse"]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_unicode_anagrams() { + let word = "ΑΒΓ"; + + // These words don't make sense, they're just greek letters cobbled together. + let inputs = ["ΒΓΑ", "ΒΓΔ", "γβα"]; + + let outputs = vec!["ΒΓΑ", "γβα"]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_misleading_unicode_anagrams() { + // Despite what a human might think these words contain different letters, the input uses Greek + // A and B while the list of potential anagrams uses Latin A and B. + let word = "ΑΒΓ"; + + let inputs = ["ABΓ"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_does_not_detect_a_word_as_its_own_anagram() { + let word = "banana"; + + let inputs = ["banana"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_does_not_detect_a_differently_cased_word_as_its_own_anagram() { + let word = "banana"; + + let inputs = ["bAnana"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_does_not_detect_a_differently_cased_unicode_word_as_its_own_anagram() { + let word = "ΑΒΓ"; + + let inputs = ["ΑΒγ"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_same_bytes_different_chars() { + let word = "a⬂"; // 61 E2 AC 82 + + let inputs = ["€a"]; // E2 82 AC 61 + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} + +#[test] +#[ignore] +fn test_different_words_but_same_ascii_sum() { + let word = "bc"; + + let inputs = ["ad"]; + + let outputs = vec![]; + + process_anagram_case(word, &inputs, &outputs); +} diff --git a/armstrong-numbers/.exercism/config.json b/armstrong-numbers/.exercism/config.json new file mode 100644 index 0000000..4083331 --- /dev/null +++ b/armstrong-numbers/.exercism/config.json @@ -0,0 +1,36 @@ +{ + "blurb": "Determine if a number is an Armstrong number", + "authors": [ + "shingtaklam1324" + ], + "contributors": [ + "AndrewKvalheim", + "coriolinus", + "cwhakes", + "eddyp", + "efx", + "ErikSchierboom", + "lutostag", + "ocstl", + "petertseng", + "rofrol", + "sputnick1124", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/armstrong-numbers.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Wikipedia", + "source_url": "https://en.wikipedia.org/wiki/Narcissistic_number" +} diff --git a/armstrong-numbers/.exercism/metadata.json b/armstrong-numbers/.exercism/metadata.json new file mode 100644 index 0000000..ca1579c --- /dev/null +++ b/armstrong-numbers/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"armstrong-numbers","id":"a40568d0bf3448af81f78f78a233cb45","url":"https://exercism.org/tracks/rust/exercises/armstrong-numbers","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/armstrong-numbers/.gitignore b/armstrong-numbers/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/armstrong-numbers/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/armstrong-numbers/Cargo.toml b/armstrong-numbers/Cargo.toml new file mode 100644 index 0000000..4949ea7 --- /dev/null +++ b/armstrong-numbers/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "armstrong_numbers" +version = "1.1.0" diff --git a/armstrong-numbers/HELP.md b/armstrong-numbers/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/armstrong-numbers/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/armstrong-numbers/README.md b/armstrong-numbers/README.md new file mode 100644 index 0000000..bbeea2b --- /dev/null +++ b/armstrong-numbers/README.md @@ -0,0 +1,44 @@ +# Armstrong Numbers + +Welcome to Armstrong Numbers on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +An [Armstrong number](https://en.wikipedia.org/wiki/Narcissistic_number) is a number that is the sum of its own digits each raised to the power of the number of digits. + +For example: + +- 9 is an Armstrong number, because `9 = 9^1 = 9` +- 10 is *not* an Armstrong number, because `10 != 1^2 + 0^2 = 1` +- 153 is an Armstrong number, because: `153 = 1^3 + 5^3 + 3^3 = 1 + 125 + 27 = 153` +- 154 is *not* an Armstrong number, because: `154 != 1^3 + 5^3 + 4^3 = 1 + 125 + 64 = 190` + +Write some code to determine whether a number is an Armstrong number. + +## Source + +### Created by + +- @shingtaklam1324 + +### Contributed to by + +- @AndrewKvalheim +- @coriolinus +- @cwhakes +- @eddyp +- @efx +- @ErikSchierboom +- @lutostag +- @ocstl +- @petertseng +- @rofrol +- @sputnick1124 +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Wikipedia - https://en.wikipedia.org/wiki/Narcissistic_number \ No newline at end of file diff --git a/armstrong-numbers/src/lib.rs b/armstrong-numbers/src/lib.rs new file mode 100644 index 0000000..8b85fbd --- /dev/null +++ b/armstrong-numbers/src/lib.rs @@ -0,0 +1,8 @@ +pub fn is_armstrong_number(num: u32) -> bool { + num == num + .to_string() + .chars() + .map(|c| c.to_digit(10).unwrap()) + .map(|d| d.pow(num.to_string().len() as u32)) + .sum() +} diff --git a/armstrong-numbers/tests/armstrong-numbers.rs b/armstrong-numbers/tests/armstrong-numbers.rs new file mode 100644 index 0000000..2163451 --- /dev/null +++ b/armstrong-numbers/tests/armstrong-numbers.rs @@ -0,0 +1,54 @@ +use armstrong_numbers::*; + +#[test] +fn test_zero_is_an_armstrong_number() { + assert!(is_armstrong_number(0)) +} + +#[test] +#[ignore] +fn test_single_digit_numbers_are_armstrong_numbers() { + assert!(is_armstrong_number(5)) +} + +#[test] +#[ignore] +fn test_there_are_no_2_digit_armstrong_numbers() { + assert!(!is_armstrong_number(10)) +} + +#[test] +#[ignore] +fn test_three_digit_armstrong_number() { + assert!(is_armstrong_number(153)) +} + +#[test] +#[ignore] +fn test_three_digit_non_armstrong_number() { + assert!(!is_armstrong_number(100)) +} + +#[test] +#[ignore] +fn test_four_digit_armstrong_number() { + assert!(is_armstrong_number(9474)) +} + +#[test] +#[ignore] +fn test_four_digit_non_armstrong_number() { + assert!(!is_armstrong_number(9475)) +} + +#[test] +#[ignore] +fn test_seven_digit_armstrong_number() { + assert!(is_armstrong_number(9_926_315)) +} + +#[test] +#[ignore] +fn test_seven_digit_non_armstrong_number() { + assert!(!is_armstrong_number(9_926_316)) +} diff --git a/beer-song/.exercism/config.json b/beer-song/.exercism/config.json new file mode 100644 index 0000000..d1604d4 --- /dev/null +++ b/beer-song/.exercism/config.json @@ -0,0 +1,44 @@ +{ + "blurb": "Produce the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "IanWhitney", + "kytrinyx", + "leoyvens", + "lutostag", + "mkantor", + "murlakatamenka", + "navossoc", + "nfiles", + "petertseng", + "pminten", + "razielgn", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/beer-song.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Learn to Program by Chris Pine", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=06" +} diff --git a/beer-song/.exercism/metadata.json b/beer-song/.exercism/metadata.json new file mode 100644 index 0000000..d608fd1 --- /dev/null +++ b/beer-song/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"beer-song","id":"73cb4eea0081401d9672503aa42beb65","url":"https://exercism.org/tracks/rust/exercises/beer-song","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/beer-song/.gitignore b/beer-song/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/beer-song/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/beer-song/Cargo.toml b/beer-song/Cargo.toml new file mode 100644 index 0000000..11c518b --- /dev/null +++ b/beer-song/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "beer-song" +version = "0.0.0" diff --git a/beer-song/HELP.md b/beer-song/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/beer-song/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/beer-song/README.md b/beer-song/README.md new file mode 100644 index 0000000..736ea89 --- /dev/null +++ b/beer-song/README.md @@ -0,0 +1,361 @@ +# Beer Song + +Welcome to Beer Song on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Recite the lyrics to that beloved classic, that field-trip favorite: 99 Bottles of Beer on the Wall. + +Note that not all verses are identical. + +```text +99 bottles of beer on the wall, 99 bottles of beer. +Take one down and pass it around, 98 bottles of beer on the wall. + +98 bottles of beer on the wall, 98 bottles of beer. +Take one down and pass it around, 97 bottles of beer on the wall. + +97 bottles of beer on the wall, 97 bottles of beer. +Take one down and pass it around, 96 bottles of beer on the wall. + +96 bottles of beer on the wall, 96 bottles of beer. +Take one down and pass it around, 95 bottles of beer on the wall. + +95 bottles of beer on the wall, 95 bottles of beer. +Take one down and pass it around, 94 bottles of beer on the wall. + +94 bottles of beer on the wall, 94 bottles of beer. +Take one down and pass it around, 93 bottles of beer on the wall. + +93 bottles of beer on the wall, 93 bottles of beer. +Take one down and pass it around, 92 bottles of beer on the wall. + +92 bottles of beer on the wall, 92 bottles of beer. +Take one down and pass it around, 91 bottles of beer on the wall. + +91 bottles of beer on the wall, 91 bottles of beer. +Take one down and pass it around, 90 bottles of beer on the wall. + +90 bottles of beer on the wall, 90 bottles of beer. +Take one down and pass it around, 89 bottles of beer on the wall. + +89 bottles of beer on the wall, 89 bottles of beer. +Take one down and pass it around, 88 bottles of beer on the wall. + +88 bottles of beer on the wall, 88 bottles of beer. +Take one down and pass it around, 87 bottles of beer on the wall. + +87 bottles of beer on the wall, 87 bottles of beer. +Take one down and pass it around, 86 bottles of beer on the wall. + +86 bottles of beer on the wall, 86 bottles of beer. +Take one down and pass it around, 85 bottles of beer on the wall. + +85 bottles of beer on the wall, 85 bottles of beer. +Take one down and pass it around, 84 bottles of beer on the wall. + +84 bottles of beer on the wall, 84 bottles of beer. +Take one down and pass it around, 83 bottles of beer on the wall. + +83 bottles of beer on the wall, 83 bottles of beer. +Take one down and pass it around, 82 bottles of beer on the wall. + +82 bottles of beer on the wall, 82 bottles of beer. +Take one down and pass it around, 81 bottles of beer on the wall. + +81 bottles of beer on the wall, 81 bottles of beer. +Take one down and pass it around, 80 bottles of beer on the wall. + +80 bottles of beer on the wall, 80 bottles of beer. +Take one down and pass it around, 79 bottles of beer on the wall. + +79 bottles of beer on the wall, 79 bottles of beer. +Take one down and pass it around, 78 bottles of beer on the wall. + +78 bottles of beer on the wall, 78 bottles of beer. +Take one down and pass it around, 77 bottles of beer on the wall. + +77 bottles of beer on the wall, 77 bottles of beer. +Take one down and pass it around, 76 bottles of beer on the wall. + +76 bottles of beer on the wall, 76 bottles of beer. +Take one down and pass it around, 75 bottles of beer on the wall. + +75 bottles of beer on the wall, 75 bottles of beer. +Take one down and pass it around, 74 bottles of beer on the wall. + +74 bottles of beer on the wall, 74 bottles of beer. +Take one down and pass it around, 73 bottles of beer on the wall. + +73 bottles of beer on the wall, 73 bottles of beer. +Take one down and pass it around, 72 bottles of beer on the wall. + +72 bottles of beer on the wall, 72 bottles of beer. +Take one down and pass it around, 71 bottles of beer on the wall. + +71 bottles of beer on the wall, 71 bottles of beer. +Take one down and pass it around, 70 bottles of beer on the wall. + +70 bottles of beer on the wall, 70 bottles of beer. +Take one down and pass it around, 69 bottles of beer on the wall. + +69 bottles of beer on the wall, 69 bottles of beer. +Take one down and pass it around, 68 bottles of beer on the wall. + +68 bottles of beer on the wall, 68 bottles of beer. +Take one down and pass it around, 67 bottles of beer on the wall. + +67 bottles of beer on the wall, 67 bottles of beer. +Take one down and pass it around, 66 bottles of beer on the wall. + +66 bottles of beer on the wall, 66 bottles of beer. +Take one down and pass it around, 65 bottles of beer on the wall. + +65 bottles of beer on the wall, 65 bottles of beer. +Take one down and pass it around, 64 bottles of beer on the wall. + +64 bottles of beer on the wall, 64 bottles of beer. +Take one down and pass it around, 63 bottles of beer on the wall. + +63 bottles of beer on the wall, 63 bottles of beer. +Take one down and pass it around, 62 bottles of beer on the wall. + +62 bottles of beer on the wall, 62 bottles of beer. +Take one down and pass it around, 61 bottles of beer on the wall. + +61 bottles of beer on the wall, 61 bottles of beer. +Take one down and pass it around, 60 bottles of beer on the wall. + +60 bottles of beer on the wall, 60 bottles of beer. +Take one down and pass it around, 59 bottles of beer on the wall. + +59 bottles of beer on the wall, 59 bottles of beer. +Take one down and pass it around, 58 bottles of beer on the wall. + +58 bottles of beer on the wall, 58 bottles of beer. +Take one down and pass it around, 57 bottles of beer on the wall. + +57 bottles of beer on the wall, 57 bottles of beer. +Take one down and pass it around, 56 bottles of beer on the wall. + +56 bottles of beer on the wall, 56 bottles of beer. +Take one down and pass it around, 55 bottles of beer on the wall. + +55 bottles of beer on the wall, 55 bottles of beer. +Take one down and pass it around, 54 bottles of beer on the wall. + +54 bottles of beer on the wall, 54 bottles of beer. +Take one down and pass it around, 53 bottles of beer on the wall. + +53 bottles of beer on the wall, 53 bottles of beer. +Take one down and pass it around, 52 bottles of beer on the wall. + +52 bottles of beer on the wall, 52 bottles of beer. +Take one down and pass it around, 51 bottles of beer on the wall. + +51 bottles of beer on the wall, 51 bottles of beer. +Take one down and pass it around, 50 bottles of beer on the wall. + +50 bottles of beer on the wall, 50 bottles of beer. +Take one down and pass it around, 49 bottles of beer on the wall. + +49 bottles of beer on the wall, 49 bottles of beer. +Take one down and pass it around, 48 bottles of beer on the wall. + +48 bottles of beer on the wall, 48 bottles of beer. +Take one down and pass it around, 47 bottles of beer on the wall. + +47 bottles of beer on the wall, 47 bottles of beer. +Take one down and pass it around, 46 bottles of beer on the wall. + +46 bottles of beer on the wall, 46 bottles of beer. +Take one down and pass it around, 45 bottles of beer on the wall. + +45 bottles of beer on the wall, 45 bottles of beer. +Take one down and pass it around, 44 bottles of beer on the wall. + +44 bottles of beer on the wall, 44 bottles of beer. +Take one down and pass it around, 43 bottles of beer on the wall. + +43 bottles of beer on the wall, 43 bottles of beer. +Take one down and pass it around, 42 bottles of beer on the wall. + +42 bottles of beer on the wall, 42 bottles of beer. +Take one down and pass it around, 41 bottles of beer on the wall. + +41 bottles of beer on the wall, 41 bottles of beer. +Take one down and pass it around, 40 bottles of beer on the wall. + +40 bottles of beer on the wall, 40 bottles of beer. +Take one down and pass it around, 39 bottles of beer on the wall. + +39 bottles of beer on the wall, 39 bottles of beer. +Take one down and pass it around, 38 bottles of beer on the wall. + +38 bottles of beer on the wall, 38 bottles of beer. +Take one down and pass it around, 37 bottles of beer on the wall. + +37 bottles of beer on the wall, 37 bottles of beer. +Take one down and pass it around, 36 bottles of beer on the wall. + +36 bottles of beer on the wall, 36 bottles of beer. +Take one down and pass it around, 35 bottles of beer on the wall. + +35 bottles of beer on the wall, 35 bottles of beer. +Take one down and pass it around, 34 bottles of beer on the wall. + +34 bottles of beer on the wall, 34 bottles of beer. +Take one down and pass it around, 33 bottles of beer on the wall. + +33 bottles of beer on the wall, 33 bottles of beer. +Take one down and pass it around, 32 bottles of beer on the wall. + +32 bottles of beer on the wall, 32 bottles of beer. +Take one down and pass it around, 31 bottles of beer on the wall. + +31 bottles of beer on the wall, 31 bottles of beer. +Take one down and pass it around, 30 bottles of beer on the wall. + +30 bottles of beer on the wall, 30 bottles of beer. +Take one down and pass it around, 29 bottles of beer on the wall. + +29 bottles of beer on the wall, 29 bottles of beer. +Take one down and pass it around, 28 bottles of beer on the wall. + +28 bottles of beer on the wall, 28 bottles of beer. +Take one down and pass it around, 27 bottles of beer on the wall. + +27 bottles of beer on the wall, 27 bottles of beer. +Take one down and pass it around, 26 bottles of beer on the wall. + +26 bottles of beer on the wall, 26 bottles of beer. +Take one down and pass it around, 25 bottles of beer on the wall. + +25 bottles of beer on the wall, 25 bottles of beer. +Take one down and pass it around, 24 bottles of beer on the wall. + +24 bottles of beer on the wall, 24 bottles of beer. +Take one down and pass it around, 23 bottles of beer on the wall. + +23 bottles of beer on the wall, 23 bottles of beer. +Take one down and pass it around, 22 bottles of beer on the wall. + +22 bottles of beer on the wall, 22 bottles of beer. +Take one down and pass it around, 21 bottles of beer on the wall. + +21 bottles of beer on the wall, 21 bottles of beer. +Take one down and pass it around, 20 bottles of beer on the wall. + +20 bottles of beer on the wall, 20 bottles of beer. +Take one down and pass it around, 19 bottles of beer on the wall. + +19 bottles of beer on the wall, 19 bottles of beer. +Take one down and pass it around, 18 bottles of beer on the wall. + +18 bottles of beer on the wall, 18 bottles of beer. +Take one down and pass it around, 17 bottles of beer on the wall. + +17 bottles of beer on the wall, 17 bottles of beer. +Take one down and pass it around, 16 bottles of beer on the wall. + +16 bottles of beer on the wall, 16 bottles of beer. +Take one down and pass it around, 15 bottles of beer on the wall. + +15 bottles of beer on the wall, 15 bottles of beer. +Take one down and pass it around, 14 bottles of beer on the wall. + +14 bottles of beer on the wall, 14 bottles of beer. +Take one down and pass it around, 13 bottles of beer on the wall. + +13 bottles of beer on the wall, 13 bottles of beer. +Take one down and pass it around, 12 bottles of beer on the wall. + +12 bottles of beer on the wall, 12 bottles of beer. +Take one down and pass it around, 11 bottles of beer on the wall. + +11 bottles of beer on the wall, 11 bottles of beer. +Take one down and pass it around, 10 bottles of beer on the wall. + +10 bottles of beer on the wall, 10 bottles of beer. +Take one down and pass it around, 9 bottles of beer on the wall. + +9 bottles of beer on the wall, 9 bottles of beer. +Take one down and pass it around, 8 bottles of beer on the wall. + +8 bottles of beer on the wall, 8 bottles of beer. +Take one down and pass it around, 7 bottles of beer on the wall. + +7 bottles of beer on the wall, 7 bottles of beer. +Take one down and pass it around, 6 bottles of beer on the wall. + +6 bottles of beer on the wall, 6 bottles of beer. +Take one down and pass it around, 5 bottles of beer on the wall. + +5 bottles of beer on the wall, 5 bottles of beer. +Take one down and pass it around, 4 bottles of beer on the wall. + +4 bottles of beer on the wall, 4 bottles of beer. +Take one down and pass it around, 3 bottles of beer on the wall. + +3 bottles of beer on the wall, 3 bottles of beer. +Take one down and pass it around, 2 bottles of beer on the wall. + +2 bottles of beer on the wall, 2 bottles of beer. +Take one down and pass it around, 1 bottle of beer on the wall. + +1 bottle of beer on the wall, 1 bottle of beer. +Take it down and pass it around, no more bottles of beer on the wall. + +No more bottles of beer on the wall, no more bottles of beer. +Go to the store and buy some more, 99 bottles of beer on the wall. +``` + +## For bonus points + +Did you get the tests passing and the code clean? If you want to, these +are some additional things you could try: + +* Remove as much duplication as you possibly can. +* Optimize for readability, even if it means introducing duplication. +* If you've removed all the duplication, do you have a lot of + conditionals? Try replacing the conditionals with polymorphism, if it + applies in this language. How readable is it? + +Then please share your thoughts in a comment on the submission. Did this +experiment make the code better? Worse? Did you learn anything from it? + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @IanWhitney +- @kytrinyx +- @leoyvens +- @lutostag +- @mkantor +- @murlakatamenka +- @navossoc +- @nfiles +- @petertseng +- @pminten +- @razielgn +- @rofrol +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Learn to Program by Chris Pine - http://pine.fm/LearnToProgram/?Chapter=06 \ No newline at end of file diff --git a/beer-song/src/lib.rs b/beer-song/src/lib.rs new file mode 100644 index 0000000..aab5583 --- /dev/null +++ b/beer-song/src/lib.rs @@ -0,0 +1,23 @@ +const VERSES: [&str; 3] = [ + "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n", + "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n", + "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n" +]; + +pub fn verse(n: u32) -> String { + match n { + 0 => VERSES[0].to_string(), + 1 => VERSES[1].to_string(), + 2 => VERSES[2].to_string(), + _ => format!("{0} bottles of beer on the wall, {0} bottles of beer.\n\ + Take one down and pass it around, {1} bottles of beer on the wall.\n", n, n-1) + } +} + +pub fn sing(start: u32, end: u32) -> String { + (end .. start + 1) + .rev() + .map(|n| verse(n)) + .collect::>() + .join("\n") +} diff --git a/beer-song/tests/beer-song.rs b/beer-song/tests/beer-song.rs new file mode 100644 index 0000000..d5daaf3 --- /dev/null +++ b/beer-song/tests/beer-song.rs @@ -0,0 +1,36 @@ +use beer_song as beer; + +#[test] +fn test_verse_0() { + assert_eq!(beer::verse(0), "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"); +} + +#[test] +#[ignore] +fn test_verse_1() { + assert_eq!(beer::verse(1), "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n"); +} + +#[test] +#[ignore] +fn test_verse_2() { + assert_eq!(beer::verse(2), "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n"); +} + +#[test] +#[ignore] +fn test_verse_8() { + assert_eq!(beer::verse(8), "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n"); +} + +#[test] +#[ignore] +fn test_song_8_6() { + assert_eq!(beer::sing(8, 6), "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n\n7 bottles of beer on the wall, 7 bottles of beer.\nTake one down and pass it around, 6 bottles of beer on the wall.\n\n6 bottles of beer on the wall, 6 bottles of beer.\nTake one down and pass it around, 5 bottles of beer on the wall.\n"); +} + +#[test] +#[ignore] +fn test_song_3_0() { + assert_eq!(beer::sing(3, 0), "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n\n2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\nNo more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n"); +} diff --git a/bob/.exercism/config.json b/bob/.exercism/config.json new file mode 100644 index 0000000..b2e6cd7 --- /dev/null +++ b/bob/.exercism/config.json @@ -0,0 +1,50 @@ +{ + "blurb": "Bob is a lackadaisical teenager. In conversation, his responses are very limited.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "austinlyons", + "cjmochrie", + "cmccandless", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "etrepum", + "f3rn0s", + "IanWhitney", + "kytrinyx", + "leoyvens", + "lewisclement", + "lutostag", + "mkantor", + "nfiles", + "petertseng", + "pminten", + "rofrol", + "rpottsoh", + "stefanv", + "stringparser", + "vvv", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/bob.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial.", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=06" +} diff --git a/bob/.exercism/metadata.json b/bob/.exercism/metadata.json new file mode 100644 index 0000000..3489aa6 --- /dev/null +++ b/bob/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"bob","id":"2ba266860b29447aafa6e7938191d672","url":"https://exercism.org/tracks/rust/exercises/bob","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/bob/.gitignore b/bob/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/bob/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/bob/Cargo.toml b/bob/Cargo.toml new file mode 100644 index 0000000..1ea9172 --- /dev/null +++ b/bob/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "bob" +version = "1.6.0" diff --git a/bob/HELP.md b/bob/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/bob/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/bob/README.md b/bob/README.md new file mode 100644 index 0000000..b3bd607 --- /dev/null +++ b/bob/README.md @@ -0,0 +1,62 @@ +# Bob + +Welcome to Bob on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Bob is a lackadaisical teenager. In conversation, his responses are very limited. + +Bob answers 'Sure.' if you ask him a question, such as "How are you?". + +He answers 'Whoa, chill out!' if you YELL AT HIM (in all capitals). + +He answers 'Calm down, I know what I'm doing!' if you yell a question at him. + +He says 'Fine. Be that way!' if you address him without actually saying +anything. + +He answers 'Whatever.' to anything else. + +Bob's conversational partner is a purist when it comes to written communication and always follows normal rules regarding sentence punctuation in English. + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @austinlyons +- @cjmochrie +- @cmccandless +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @etrepum +- @f3rn0s +- @IanWhitney +- @kytrinyx +- @leoyvens +- @lewisclement +- @lutostag +- @mkantor +- @nfiles +- @petertseng +- @pminten +- @rofrol +- @rpottsoh +- @stefanv +- @stringparser +- @vvv +- @xakon +- @ZapAnton + +### Based on + +Inspired by the 'Deaf Grandma' exercise in Chris Pine's Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=06 \ No newline at end of file diff --git a/bob/src/lib.rs b/bob/src/lib.rs new file mode 100644 index 0000000..66d9640 --- /dev/null +++ b/bob/src/lib.rs @@ -0,0 +1,14 @@ +fn is_yelling(message: &str) -> bool { + let have_letters: bool = message.chars().filter(|c| c.is_alphabetic()).count() > 0; + message.to_uppercase() == message && have_letters +} + +pub fn reply(message: &str) -> &str { + match message.trim() { + m if m.trim().len() == 0 => "Fine. Be that way!", + m if m.ends_with("?") && is_yelling(m) => "Calm down, I know what I'm doing!", + m if m.ends_with("?") => "Sure.", + m if is_yelling(m) => "Whoa, chill out!", + _ => "Whatever." + } +} diff --git a/bob/tests/bob.rs b/bob/tests/bob.rs new file mode 100644 index 0000000..330c7ff --- /dev/null +++ b/bob/tests/bob.rs @@ -0,0 +1,190 @@ +fn process_response_case(phrase: &str, expected_response: &str) { + assert_eq!(bob::reply(phrase), expected_response); +} + +#[test] +/// stating something +fn test_stating_something() { + process_response_case("Tom-ay-to, tom-aaaah-to.", "Whatever."); +} + +#[test] +#[ignore] +/// ending with whitespace +fn test_ending_with_whitespace() { + process_response_case("Okay if like my spacebar quite a bit? ", "Sure."); +} + +#[test] +#[ignore] +/// shouting numbers +fn test_shouting_numbers() { + process_response_case("1, 2, 3 GO!", "Whoa, chill out!"); +} + +#[test] +#[ignore] +/// other whitespace +fn test_other_whitespace() { + process_response_case("\r\r ", "Fine. Be that way!"); +} + +#[test] +#[ignore] +/// shouting with special characters +fn test_shouting_with_special_characters() { + process_response_case( + "ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!", + "Whoa, chill out!", + ); +} + +#[test] +#[ignore] +/// talking forcefully +fn test_talking_forcefully() { + process_response_case("Hi there!", "Whatever."); +} + +#[test] +#[ignore] +/// prattling on +fn test_prattling_on() { + process_response_case("Wait! Hang on. Are you going to be OK?", "Sure."); +} + +#[test] +#[ignore] +/// forceful question +fn test_forceful_question() { + process_response_case("WHAT'S GOING ON?", "Calm down, I know what I'm doing!"); +} + +#[test] +#[ignore] +/// shouting with no exclamation mark +fn test_shouting_with_no_exclamation_mark() { + process_response_case("I HATE THE DENTIST", "Whoa, chill out!"); +} + +#[test] +#[ignore] +/// asking gibberish +fn test_asking_gibberish() { + process_response_case("fffbbcbeab?", "Sure."); +} + +#[test] +#[ignore] +/// question with no letters +fn test_question_with_no_letters() { + process_response_case("4?", "Sure."); +} + +#[test] +#[ignore] +/// no letters +fn test_no_letters() { + process_response_case("1, 2, 3", "Whatever."); +} + +#[test] +#[ignore] +/// statement containing question mark +fn test_statement_containing_question_mark() { + process_response_case("Ending with ? means a question.", "Whatever."); +} + +//NEW +#[test] +#[ignore] +/// multiple line question +fn test_multiple_line_question() { + process_response_case( + "\rDoes this cryogenic chamber make me look fat?\rNo.", + "Whatever.", + ); +} + +#[test] +#[ignore] +/// non-question ending with whitespace +fn test_nonquestion_ending_with_whitespace() { + process_response_case( + "This is a statement ending with whitespace ", + "Whatever.", + ); +} + +#[test] +#[ignore] +/// shouting +fn test_shouting() { + process_response_case("WATCH OUT!", "Whoa, chill out!"); +} + +#[test] +#[ignore] +/// non-letters with question +fn test_nonletters_with_question() { + process_response_case(":) ?", "Sure."); +} + +#[test] +#[ignore] +/// shouting gibberish +fn test_shouting_gibberish() { + process_response_case("FCECDFCAAB", "Whoa, chill out!"); +} + +#[test] +#[ignore] +/// asking a question +fn test_asking_a_question() { + process_response_case("Does this cryogenic chamber make me look fat?", "Sure."); +} + +#[test] +#[ignore] +/// asking a numeric question +fn test_asking_a_numeric_question() { + process_response_case("You are, what, like 15?", "Sure."); +} + +#[test] +#[ignore] +/// silence +fn test_silence() { + process_response_case("", "Fine. Be that way!"); +} + +#[test] +#[ignore] +/// starting with whitespace +fn test_starting_with_whitespace() { + process_response_case(" hmmmmmmm...", "Whatever."); +} + +#[test] +#[ignore] +/// using acronyms in regular speech +fn test_using_acronyms_in_regular_speech() { + process_response_case( + "It's OK if you don't want to go work for NASA.", + "Whatever.", + ); +} + +#[test] +#[ignore] +/// alternate silence +fn test_alternate_silence() { + process_response_case(" ", "Fine. Be that way!"); +} + +#[test] +#[ignore] +/// prolonged silence +fn test_prolonged_silence() { + process_response_case(" ", "Fine. Be that way!"); +} diff --git a/clock/.exercism/config.json b/clock/.exercism/config.json new file mode 100644 index 0000000..f33bc6c --- /dev/null +++ b/clock/.exercism/config.json @@ -0,0 +1,43 @@ +{ + "blurb": "Implement a clock that handles times without dates.", + "authors": [ + "sacherjj" + ], + "contributors": [ + "attilahorvath", + "coriolinus", + "cwhakes", + "danieljl", + "eddyp", + "efx", + "ErikSchierboom", + "felix91gr", + "kunaltyagi", + "lutostag", + "nfiles", + "petertseng", + "rofrol", + "shaaraddalvi", + "stringparser", + "tmccombs", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/clock.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Pairing session with Erin Drummond", + "source_url": "https://twitter.com/ebdrummond", + "custom": { + "allowed-to-not-compile": "Stub doesn't compile because there is no to_string() implementation. This exercise is an introduction to derived and self-implemented traits, therefore adding template for a trait would reduce student learning." + } +} diff --git a/clock/.exercism/metadata.json b/clock/.exercism/metadata.json new file mode 100644 index 0000000..98d3437 --- /dev/null +++ b/clock/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"clock","id":"bcfb7c3bb06e42a0921d4975f51a864f","url":"https://exercism.org/tracks/rust/exercises/clock","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/clock/.gitignore b/clock/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/clock/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/clock/Cargo.toml b/clock/Cargo.toml new file mode 100644 index 0000000..ca943d6 --- /dev/null +++ b/clock/Cargo.toml @@ -0,0 +1,6 @@ +[package] +edition = "2021" +name = "clock" +version = "2.4.0" + +[dependencies] diff --git a/clock/HELP.md b/clock/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/clock/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/clock/README.md b/clock/README.md new file mode 100644 index 0000000..aa08921 --- /dev/null +++ b/clock/README.md @@ -0,0 +1,57 @@ +# Clock + +Welcome to Clock on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Implement a clock that handles times without dates. + +You should be able to add and subtract minutes to it. + +Two clocks that represent the same time should be equal to each other. + +You will also need to implement `.to_string()` for the `Clock` struct. We will be using this to display the Clock's state. You can either do it via implementing it directly or using the [Display trait](https://doc.rust-lang.org/std/fmt/trait.Display.html). + +Did you implement `.to_string()` for the `Clock` struct? + +If so, try implementing the +[Display trait](https://doc.rust-lang.org/std/fmt/trait.Display.html) for `Clock` instead. + +Traits allow for a common way to implement functionality for various types. + +For additional learning, consider how you might implement `String::from` for the `Clock` type. +You don't have to actually implement this—it's redundant with `Display`, which is generally the +better choice when the destination type is `String`—but it's useful to have a few type-conversion +traits in your toolkit. + +## Source + +### Created by + +- @sacherjj + +### Contributed to by + +- @attilahorvath +- @coriolinus +- @cwhakes +- @danieljl +- @eddyp +- @efx +- @ErikSchierboom +- @felix91gr +- @kunaltyagi +- @lutostag +- @nfiles +- @petertseng +- @rofrol +- @shaaraddalvi +- @stringparser +- @tmccombs +- @xakon +- @ZapAnton + +### Based on + +Pairing session with Erin Drummond - https://twitter.com/ebdrummond \ No newline at end of file diff --git a/clock/src/lib.rs b/clock/src/lib.rs new file mode 100644 index 0000000..5bd4344 --- /dev/null +++ b/clock/src/lib.rs @@ -0,0 +1,39 @@ +#[derive(Eq, PartialEq, Debug)] +pub struct Clock { + minutes: i32, +} + +const MINUTES_IN_AN_HOUR: i32 = 60; +const HOURS_IN_A_DAY: i32 = 24; +const MINUTES_IN_A_DAY: i32 = HOURS_IN_A_DAY * MINUTES_IN_AN_HOUR; + +impl ToString for Clock { + fn to_string(&self) -> String { + format!("{:02}:{:02}", self.hours(), self.minutes()) + } +} + +impl Clock { + pub fn new(hours: i32, minutes: i32) -> Self { + Self { + minutes: Self::as_minutes(hours, minutes), + } + } + + pub fn add_minutes(&self, minutes: i32) -> Self { + Self::new(0, self.minutes + minutes) + } + + fn as_minutes(hours: i32, minutes: i32) -> i32 { + ((hours * MINUTES_IN_AN_HOUR + minutes) % MINUTES_IN_A_DAY + MINUTES_IN_A_DAY) + % MINUTES_IN_A_DAY + } + + fn hours(&self) -> i32 { + self.minutes / MINUTES_IN_AN_HOUR + } + + fn minutes(&self) -> i32 { + self.minutes % MINUTES_IN_AN_HOUR + } +} \ No newline at end of file diff --git a/clock/tests/clock.rs b/clock/tests/clock.rs new file mode 100644 index 0000000..6d1ffdf --- /dev/null +++ b/clock/tests/clock.rs @@ -0,0 +1,352 @@ +use clock::Clock; + +// +// Clock Creation +// + +#[test] +fn test_on_the_hour() { + assert_eq!(Clock::new(8, 0).to_string(), "08:00"); +} + +#[test] +#[ignore] +fn test_past_the_hour() { + assert_eq!(Clock::new(11, 9).to_string(), "11:09"); +} + +#[test] +#[ignore] +fn test_midnight_is_zero_hours() { + assert_eq!(Clock::new(24, 0).to_string(), "00:00"); +} + +#[test] +#[ignore] +fn test_hour_rolls_over() { + assert_eq!(Clock::new(25, 0).to_string(), "01:00"); +} + +#[test] +#[ignore] +fn test_hour_rolls_over_continuously() { + assert_eq!(Clock::new(100, 0).to_string(), "04:00"); +} + +#[test] +#[ignore] +fn test_sixty_minutes_is_next_hour() { + assert_eq!(Clock::new(1, 60).to_string(), "02:00"); +} + +#[test] +#[ignore] +fn test_minutes_roll_over() { + assert_eq!(Clock::new(0, 160).to_string(), "02:40"); +} + +#[test] +#[ignore] +fn test_minutes_roll_over_continuously() { + assert_eq!(Clock::new(0, 1723).to_string(), "04:43"); +} + +#[test] +#[ignore] +fn test_hours_and_minutes_roll_over() { + assert_eq!(Clock::new(25, 160).to_string(), "03:40"); +} + +#[test] +#[ignore] +fn test_hours_and_minutes_roll_over_continuously() { + assert_eq!(Clock::new(201, 3001).to_string(), "11:01"); +} + +#[test] +#[ignore] +fn test_hours_and_minutes_roll_over_to_exactly_midnight() { + assert_eq!(Clock::new(72, 8640).to_string(), "00:00"); +} + +#[test] +#[ignore] +fn test_negative_hour() { + assert_eq!(Clock::new(-1, 15).to_string(), "23:15"); +} + +#[test] +#[ignore] +fn test_negative_hour_roll_over() { + assert_eq!(Clock::new(-25, 00).to_string(), "23:00"); +} + +#[test] +#[ignore] +fn test_negative_hour_roll_over_continuously() { + assert_eq!(Clock::new(-91, 00).to_string(), "05:00"); +} + +#[test] +#[ignore] +fn test_negative_minutes() { + assert_eq!(Clock::new(1, -40).to_string(), "00:20"); +} + +#[test] +#[ignore] +fn test_negative_minutes_roll_over() { + assert_eq!(Clock::new(1, -160).to_string(), "22:20"); +} + +#[test] +#[ignore] +fn test_negative_minutes_roll_over_continuously() { + assert_eq!(Clock::new(1, -4820).to_string(), "16:40"); +} + +#[test] +#[ignore] +fn test_negative_sixty_minutes_is_prev_hour() { + assert_eq!(Clock::new(2, -60).to_string(), "01:00"); +} + +#[test] +#[ignore] +fn test_negative_one_twenty_minutes_is_two_prev_hours() { + assert_eq!(Clock::new(1, -120).to_string(), "23:00"); +} + +#[test] +#[ignore] +fn test_negative_hour_and_minutes_both_roll_over() { + assert_eq!(Clock::new(-25, -160).to_string(), "20:20"); +} + +#[test] +#[ignore] +fn test_negative_hour_and_minutes_both_roll_over_continuously() { + assert_eq!(Clock::new(-121, -5810).to_string(), "22:10"); +} + +#[test] +#[ignore] +fn test_zero_hour_and_negative_minutes() { + assert_eq!(Clock::new(0, -22).to_string(), "23:38"); +} + +// +// Clock Math +// + +#[test] +#[ignore] +fn test_add_minutes() { + let clock = Clock::new(10, 0).add_minutes(3); + assert_eq!(clock.to_string(), "10:03"); +} + +#[test] +#[ignore] +fn test_add_no_minutes() { + let clock = Clock::new(6, 41).add_minutes(0); + assert_eq!(clock.to_string(), "06:41"); +} + +#[test] +#[ignore] +fn test_add_to_next_hour() { + let clock = Clock::new(0, 45).add_minutes(40); + assert_eq!(clock.to_string(), "01:25"); +} + +#[test] +#[ignore] +fn test_add_more_than_one_hour() { + let clock = Clock::new(10, 0).add_minutes(61); + assert_eq!(clock.to_string(), "11:01"); +} + +#[test] +#[ignore] +fn test_add_more_than_two_hours_with_carry() { + let clock = Clock::new(0, 45).add_minutes(160); + assert_eq!(clock.to_string(), "03:25"); +} + +#[test] +#[ignore] +fn test_add_across_midnight() { + let clock = Clock::new(23, 59).add_minutes(2); + assert_eq!(clock.to_string(), "00:01"); +} + +#[test] +#[ignore] +fn test_add_more_than_one_day() { + let clock = Clock::new(5, 32).add_minutes(1500); + assert_eq!(clock.to_string(), "06:32"); +} + +#[test] +#[ignore] +fn test_add_more_than_two_days() { + let clock = Clock::new(1, 1).add_minutes(3500); + assert_eq!(clock.to_string(), "11:21"); +} + +#[test] +#[ignore] +fn test_subtract_minutes() { + let clock = Clock::new(10, 3).add_minutes(-3); + assert_eq!(clock.to_string(), "10:00"); +} + +#[test] +#[ignore] +fn test_subtract_to_previous_hour() { + let clock = Clock::new(10, 3).add_minutes(-30); + assert_eq!(clock.to_string(), "09:33"); +} + +#[test] +#[ignore] +fn test_subtract_more_than_an_hour() { + let clock = Clock::new(10, 3).add_minutes(-70); + assert_eq!(clock.to_string(), "08:53"); +} + +#[test] +#[ignore] +fn test_subtract_across_midnight() { + let clock = Clock::new(0, 3).add_minutes(-4); + assert_eq!(clock.to_string(), "23:59"); +} + +#[test] +#[ignore] +fn test_subtract_more_than_two_hours() { + let clock = Clock::new(0, 0).add_minutes(-160); + assert_eq!(clock.to_string(), "21:20"); +} + +#[test] +#[ignore] +fn test_subtract_more_than_two_hours_with_borrow() { + let clock = Clock::new(6, 15).add_minutes(-160); + assert_eq!(clock.to_string(), "03:35"); +} + +#[test] +#[ignore] +fn test_subtract_more_than_one_day() { + let clock = Clock::new(5, 32).add_minutes(-1500); + assert_eq!(clock.to_string(), "04:32"); +} + +#[test] +#[ignore] +fn test_subtract_more_than_two_days() { + let clock = Clock::new(2, 20).add_minutes(-3000); + assert_eq!(clock.to_string(), "00:20"); +} + +// +// Test Equality +// + +#[test] +#[ignore] +fn test_compare_clocks_for_equality() { + assert_eq!(Clock::new(15, 37), Clock::new(15, 37)); +} + +#[test] +#[ignore] +fn test_compare_clocks_a_minute_apart() { + assert_ne!(Clock::new(15, 36), Clock::new(15, 37)); +} + +#[test] +#[ignore] +fn test_compare_clocks_an_hour_apart() { + assert_ne!(Clock::new(14, 37), Clock::new(15, 37)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_hour_overflow() { + assert_eq!(Clock::new(10, 37), Clock::new(34, 37)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_hour_overflow_by_several_days() { + assert_eq!(Clock::new(99, 11), Clock::new(3, 11)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_hour() { + assert_eq!(Clock::new(-2, 40), Clock::new(22, 40)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_hour_that_wraps() { + assert_eq!(Clock::new(-31, 3), Clock::new(17, 3)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_hour_that_wraps_multiple_times() { + assert_eq!(Clock::new(-83, 49), Clock::new(13, 49)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_minutes_overflow() { + assert_eq!(Clock::new(0, 1441), Clock::new(0, 1)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_minutes_overflow_by_several_days() { + assert_eq!(Clock::new(2, 4322), Clock::new(2, 2)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_minute() { + assert_eq!(Clock::new(3, -20), Clock::new(2, 40)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_minute_that_wraps() { + assert_eq!(Clock::new(5, -1490), Clock::new(4, 10)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_minute_that_wraps_multiple() { + assert_eq!(Clock::new(6, -4305), Clock::new(6, 15)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_hours_and_minutes() { + assert_eq!(Clock::new(-12, -268), Clock::new(7, 32)); +} + +#[test] +#[ignore] +fn test_compare_clocks_with_negative_hours_and_minutes_that_wrap() { + assert_eq!(Clock::new(-54, -11_513), Clock::new(18, 7)); +} + +#[test] +#[ignore] +fn test_compare_full_clock_and_zeroed_clock() { + assert_eq!(Clock::new(24, 0), Clock::new(0, 0)); +} diff --git a/gigasecond/.exercism/config.json b/gigasecond/.exercism/config.json new file mode 100644 index 0000000..e31f584 --- /dev/null +++ b/gigasecond/.exercism/config.json @@ -0,0 +1,45 @@ +{ + "blurb": "Given a moment, determine the moment that would be after a gigasecond has passed.", + "authors": [ + "IanWhitney" + ], + "contributors": [ + "andy5995", + "ashleygwilliams", + "cbzehner", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "houhoulis", + "IanWhitney", + "janczer", + "leoyvens", + "lutostag", + "mkantor", + "nfiles", + "NieDzejkob", + "ocstl", + "petertseng", + "rofrol", + "sacherjj", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/gigasecond.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Chapter 9 in Chris Pine's online Learn to Program tutorial.", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=09" +} diff --git a/gigasecond/.exercism/metadata.json b/gigasecond/.exercism/metadata.json new file mode 100644 index 0000000..99b4e9b --- /dev/null +++ b/gigasecond/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"gigasecond","id":"496981dcd7204a27be917dbc863f0a87","url":"https://exercism.org/tracks/rust/exercises/gigasecond","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/gigasecond/.gitignore b/gigasecond/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/gigasecond/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/gigasecond/Cargo.toml b/gigasecond/Cargo.toml new file mode 100644 index 0000000..da110b7 --- /dev/null +++ b/gigasecond/Cargo.toml @@ -0,0 +1,7 @@ +[package] +edition = "2021" +name = "gigasecond" +version = "2.0.0" + +[dependencies] +time = "0.3" diff --git a/gigasecond/HELP.md b/gigasecond/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/gigasecond/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/gigasecond/README.md b/gigasecond/README.md new file mode 100644 index 0000000..dfaa322 --- /dev/null +++ b/gigasecond/README.md @@ -0,0 +1,49 @@ +# Gigasecond + +Welcome to Gigasecond on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a moment, determine the moment that would be after a gigasecond +has passed. + +A gigasecond is 10^9 (1,000,000,000) seconds. + +If you're unsure what operations you can perform on `PrimitiveDateTime` take a look at the [time crate](https://docs.rs/time) which is listed as a dependency in the `Cargo.toml` file for this exercise. + +## Source + +### Created by + +- @IanWhitney + +### Contributed to by + +- @andy5995 +- @ashleygwilliams +- @cbzehner +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @houhoulis +- @IanWhitney +- @janczer +- @leoyvens +- @lutostag +- @mkantor +- @nfiles +- @NieDzejkob +- @ocstl +- @petertseng +- @rofrol +- @sacherjj +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Chapter 9 in Chris Pine's online Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=09 \ No newline at end of file diff --git a/gigasecond/src/lib.rs b/gigasecond/src/lib.rs new file mode 100644 index 0000000..e53a400 --- /dev/null +++ b/gigasecond/src/lib.rs @@ -0,0 +1,7 @@ +use time::{Duration, PrimitiveDateTime as DateTime}; + +// Returns a DateTime one billion seconds after start. +pub fn after(start: DateTime) -> DateTime { + // Add 10 seconds to start + start + Duration::seconds(1_000_000_000) +} diff --git a/gigasecond/tests/gigasecond.rs b/gigasecond/tests/gigasecond.rs new file mode 100644 index 0000000..abd53a8 --- /dev/null +++ b/gigasecond/tests/gigasecond.rs @@ -0,0 +1,52 @@ +use time::PrimitiveDateTime as DateTime; + +/// Create a datetime from the given numeric point in time. +/// +/// Panics if any field is invalid. +fn dt(year: i32, month: u8, day: u8, hour: u8, minute: u8, second: u8) -> DateTime { + use time::{Date, Time}; + + DateTime::new( + Date::from_calendar_date(year, month.try_into().unwrap(), day).unwrap(), + Time::from_hms(hour, minute, second).unwrap(), + ) +} + +#[test] +fn test_date() { + let start_date = dt(2011, 4, 25, 0, 0, 0); + + assert_eq!(gigasecond::after(start_date), dt(2043, 1, 1, 1, 46, 40)); +} + +#[test] +#[ignore] +fn test_another_date() { + let start_date = dt(1977, 6, 13, 0, 0, 0); + + assert_eq!(gigasecond::after(start_date), dt(2009, 2, 19, 1, 46, 40)); +} + +#[test] +#[ignore] +fn test_third_date() { + let start_date = dt(1959, 7, 19, 0, 0, 0); + + assert_eq!(gigasecond::after(start_date), dt(1991, 3, 27, 1, 46, 40)); +} + +#[test] +#[ignore] +fn test_datetime() { + let start_date = dt(2015, 1, 24, 22, 0, 0); + + assert_eq!(gigasecond::after(start_date), dt(2046, 10, 2, 23, 46, 40)); +} + +#[test] +#[ignore] +fn test_another_datetime() { + let start_date = dt(2015, 1, 24, 23, 59, 59); + + assert_eq!(gigasecond::after(start_date), dt(2046, 10, 3, 1, 46, 39)); +} diff --git a/grade-school/.exercism/config.json b/grade-school/.exercism/config.json new file mode 100644 index 0000000..6ad0549 --- /dev/null +++ b/grade-school/.exercism/config.json @@ -0,0 +1,43 @@ +{ + "blurb": "Given students' names along with the grade that they are in, create a roster for the school", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "ffflorian", + "IanWhitney", + "kytrinyx", + "lpil", + "lutostag", + "navossoc", + "nfiles", + "petertseng", + "pminten", + "rofrol", + "stevejb71", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/grade-school.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "A pairing session with Phil Battos at gSchool", + "source_url": "http://gschool.it" +} diff --git a/grade-school/.exercism/metadata.json b/grade-school/.exercism/metadata.json new file mode 100644 index 0000000..c1cfd73 --- /dev/null +++ b/grade-school/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"grade-school","id":"5d0ccb19b5f0468d9f98154f1727365a","url":"https://exercism.org/tracks/rust/exercises/grade-school","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/grade-school/.gitignore b/grade-school/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/grade-school/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/grade-school/Cargo.toml b/grade-school/Cargo.toml new file mode 100644 index 0000000..d885156 --- /dev/null +++ b/grade-school/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "grade-school" +version = "0.0.0" diff --git a/grade-school/HELP.md b/grade-school/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/grade-school/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/grade-school/README.md b/grade-school/README.md new file mode 100644 index 0000000..3ed00a7 --- /dev/null +++ b/grade-school/README.md @@ -0,0 +1,77 @@ +# Grade School + +Welcome to Grade School on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given students' names along with the grade that they are in, create a roster +for the school. + +In the end, you should be able to: + +- Add a student's name to the roster for a grade + - "Add Jim to grade 2." + - "OK." +- Get a list of all students enrolled in a grade + - "Which students are in grade 2?" + - "We've only got Jim just now." +- Get a sorted list of all students in all grades. Grades should sort + as 1, 2, 3, etc., and students within a grade should be sorted + alphabetically by name. + - "Who all is enrolled in school right now?" + - "Let me think. We have + Anna, Barb, and Charlie in grade 1, + Alex, Peter, and Zoe in grade 2 + and Jim in grade 5. + So the answer is: Anna, Barb, Charlie, Alex, Peter, Zoe and Jim" + +Note that all our students only have one name. (It's a small town, what +do you want?) + +## For bonus points + +Did you get the tests passing and the code clean? If you want to, these +are some additional things you could try: + +- If you're working in a language with mutable data structures and your + implementation allows outside code to mutate the school's internal DB + directly, see if you can prevent this. Feel free to introduce additional + tests. + +Then please share your thoughts in a comment on the submission. Did this +experiment make the code better? Worse? Did you learn anything from it? + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @ffflorian +- @IanWhitney +- @kytrinyx +- @lpil +- @lutostag +- @navossoc +- @nfiles +- @petertseng +- @pminten +- @rofrol +- @stevejb71 +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +A pairing session with Phil Battos at gSchool - http://gschool.it \ No newline at end of file diff --git a/grade-school/src/lib.rs b/grade-school/src/lib.rs new file mode 100644 index 0000000..e4ef305 --- /dev/null +++ b/grade-school/src/lib.rs @@ -0,0 +1,46 @@ +use std::collections::HashMap; + +// This annotation prevents Clippy from warning us that `School` has a +// `fn new()` with no arguments, but doesn't implement the `Default` trait. +// +// Normally, it's good practice to just do what Clippy tells you, but in this +// case, we want to keep things relatively simple. The `Default` trait is not the point +// of this exercise. +#[allow(clippy::new_without_default)] +pub struct School { + student_grades: HashMap> +} + +impl School { + pub fn new() -> Self { + Self { + student_grades: HashMap::new() + } + } + + pub fn add(&mut self, grade: u32, student: &str) { + self.student_grades + .entry(grade) + .or_insert(Vec::new()) + .push(student.to_owned()) + } + + pub fn grades(&self) -> Vec { + let mut grades = self.student_grades.keys().cloned().collect::>(); + grades.sort(); + grades + } + + // If `grade` returned a reference, `School` would be forced to keep a `Vec` + // internally to lend out. By returning an owned vector of owned `String`s instead, + // the internal structure can be completely arbitrary. The tradeoff is that some data + // must be copied each time `grade` is called. + pub fn grade(&self, grade: u32) -> Vec { + let mut students_for_grade = match self.student_grades.get(&grade) { + Some(students_grade) => students_grade.to_vec(), + None => vec![] + }; + students_for_grade.sort(); + students_for_grade + } +} diff --git a/grade-school/tests/grade-school.rs b/grade-school/tests/grade-school.rs new file mode 100644 index 0000000..eb41d07 --- /dev/null +++ b/grade-school/tests/grade-school.rs @@ -0,0 +1,83 @@ +use grade_school as school; + +fn to_owned(v: &[&str]) -> Vec { + v.iter().map(|s| s.to_string()).collect() +} + +#[test] +fn test_grades_for_empty_school() { + let s = school::School::new(); + assert_eq!(s.grades(), vec![]); +} + +#[test] +#[ignore] +fn test_grades_for_one_student() { + let mut s = school::School::new(); + s.add(2, "Aimee"); + assert_eq!(s.grades(), vec![2]); +} + +#[test] +#[ignore] +fn test_grades_for_several_students_are_sorted() { + let mut s = school::School::new(); + s.add(2, "Aimee"); + s.add(7, "Logan"); + s.add(4, "Blair"); + assert_eq!(s.grades(), vec![2, 4, 7]); +} + +#[test] +#[ignore] +fn test_grades_when_several_students_have_the_same_grade() { + let mut s = school::School::new(); + s.add(2, "Aimee"); + s.add(2, "Logan"); + s.add(2, "Blair"); + assert_eq!(s.grades(), vec![2]); +} + +#[test] +#[ignore] +fn test_grade_for_empty_school() { + let s = school::School::new(); + assert_eq!(s.grade(1), Vec::::new()); +} + +#[test] +#[ignore] +fn test_grade_when_no_students_have_that_grade() { + let mut s = school::School::new(); + s.add(7, "Logan"); + assert_eq!(s.grade(1), Vec::::new()); +} + +#[test] +#[ignore] +fn test_grade_for_one_student() { + let mut s = school::School::new(); + s.add(2, "Aimee"); + assert_eq!(s.grade(2), to_owned(&["Aimee"])); +} + +#[test] +#[ignore] +fn test_grade_returns_students_sorted_by_name() { + let mut s = school::School::new(); + s.add(2, "James"); + s.add(2, "Blair"); + s.add(2, "Paul"); + assert_eq!(s.grade(2), to_owned(&["Blair", "James", "Paul"])); +} + +#[test] +#[ignore] +fn test_add_students_to_different_grades() { + let mut s = school::School::new(); + s.add(3, "Chelsea"); + s.add(7, "Logan"); + assert_eq!(s.grades(), vec![3, 7]); + assert_eq!(s.grade(3), to_owned(&["Chelsea"])); + assert_eq!(s.grade(7), to_owned(&["Logan"])); +} diff --git a/health-statistics/.exercism/config.json b/health-statistics/.exercism/config.json new file mode 100644 index 0000000..eb248d3 --- /dev/null +++ b/health-statistics/.exercism/config.json @@ -0,0 +1,18 @@ +{ + "blurb": "Learn structs to store statistics for a health-monitoring system.", + "authors": [ + "seanchen1991" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/health-statistics.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + } +} diff --git a/health-statistics/.exercism/metadata.json b/health-statistics/.exercism/metadata.json new file mode 100644 index 0000000..b384d9f --- /dev/null +++ b/health-statistics/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"health-statistics","id":"f7698b2154ad4d28ba7ae9b85f9714c2","url":"https://exercism.org/tracks/rust/exercises/health-statistics","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/health-statistics/Cargo.lock b/health-statistics/Cargo.lock new file mode 100644 index 0000000..0461bf1 --- /dev/null +++ b/health-statistics/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "health_statistics" +version = "0.1.0" diff --git a/health-statistics/Cargo.toml b/health-statistics/Cargo.toml new file mode 100644 index 0000000..66b5fbc --- /dev/null +++ b/health-statistics/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "health_statistics" +version = "0.1.0" +edition = "2021" diff --git a/health-statistics/HELP.md b/health-statistics/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/health-statistics/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/health-statistics/HINTS.md b/health-statistics/HINTS.md new file mode 100644 index 0000000..949a1fa --- /dev/null +++ b/health-statistics/HINTS.md @@ -0,0 +1,31 @@ +# Hints + +## General + +## 1. Implement the `new()` method + +- The `new()` method receives the arguments we want to instantiate a `User` instance with. It should return an instance of `User` with the specified name, age, and weight. + +- See [here](https://doc.rust-lang.org/book/ch05-01-defining-structs.html) for additional examples on defining and instantiating structs. + +## 2. Implement the getter methods + +- The `name()`, `age()`, and `weight()` methods are getters. In other words, they are responsible for returning the corresponding field from a struct instance. + +- Notice that the `name` method returns a `&str` when the `name` field on the `User` struct is a `String`. How can we get `&str` and `String` to play nice with each other? + +- There's no need to use a `return` statement in Rust unless you expressly want a function or method to return early. Otherwise, it's more idiomatic to utilize an _implicit_ return by omitting the semicolon for the result we want a function or method to return. It's not _wrong_ to use an explicit return, but it's cleaner to take advantage of implicit returns where possible. + +```rust +fn foo() -> i32 { + 1 +} +``` + +- See [here](https://doc.rust-lang.org/book/ch05-03-method-syntax.html) for some more examples of defining methods on structs. + +## 3. Implement the setter methods + +- The `set_age()` and `set_weight()` methods are setters, responsible for updating the corresponding field on a struct instance with the input argument. + +- As the signatures of these methods specify, the setter methods shouldn't return anything. \ No newline at end of file diff --git a/health-statistics/README.md b/health-statistics/README.md new file mode 100644 index 0000000..85eafb3 --- /dev/null +++ b/health-statistics/README.md @@ -0,0 +1,91 @@ +# Health Statistics + +Welcome to Health Statistics on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +It is often useful to group a collection of items together, and handle those groups as units. In Rust, we call such a group a struct, and each item one of the struct's fields. A struct defines the general set of fields available, but a particular example of a struct is called an instance. + +Furthermore, structs can have methods defined on them, which have access to the fields. The struct itself in that case is referred to as `self`. When a method uses `&mut self`, the fields can be changed, or mutated. When a method uses `&self`, the fields cannot be changed: they are immutable. Controlling mutability helps the borrow-checker ensure that entire classes of concurrency bug just don't happen in Rust. + +In this exercise, you'll be implementing two kinds of methods on a struct. The first are generally known as getters: they expose the struct's fields to the world, without letting anyone else mutate that value. In Rust, these methods idiomatically share the name of the field they expose, i.e., if we have a getter method that fetches a struct field called `name`, the method would simply be called `name()`. + +You'll also be implementing methods of another type, generally known as setters. These change the value of the field. Setters aren't very common in Rust--if a field can be freely modified, it is more common to just make it public--but they're useful if updating the field should have side effects, or for access control: a setter marked as `pub(crate)` allows other modules within the same crate to update a private field, which can't be affected by the outside world. + +Structs come in three flavors: structs with named fields, tuple structs, and unit structs. For this concept exercise, we'll be exploring the first variant: structs with named fields. + +Structs are defined using the `struct` keyword, followed by the capitalized name of the type the struct is describing: + +```rust +struct Item {} +``` + +Additional types are then brought into the struct body as _fields_ of the struct, each with their own type: + +```rust +struct Item { + name: String, + weight: f32, + worth: u32, +} +``` + +Lastly, methods can be defined on structs inside of an `impl` block: + +```rust +impl Item { + // initializes and returns a new instance of our Item struct + fn new() -> Self { + unimplemented!() + } +} +``` + +With that brief introduction to the syntax of structs out of the way, go ahead and take a look at the [instructions](instructions.md) for this exercise! + +## Instructions + +You're working on implementing a health-monitoring system. As part of that, you need to keep track of users' health statistics. + +You'll start with some stubbed functions in an `impl` block as well as the following struct definition: + +```rust +pub struct User { + name: String, + age: u32, + weight: f32, +} +``` + +Your goal is to implement the stubbed out methods on the `User` `struct` defined in the `impl` block. + +For example, the `new` method should return an instance of the `User` struct with the specified name, age, and weight values. + +```rust +let mut bob = User::new(String::from("Bob"), 32, 155.2); +// Returns: a User with name "Bob", age 32, and weight 155.2 +``` + +The `weight` method should return the weight of the `User`. + +```rust +bob.weight(); +// Returns: 155.2 +``` + +The `set_age` method should set the age of the `User`. + +```rust +bob.set_age(33); +// Updates Bob's age to 33; happy birthday Bob! +``` + +Have fun! + +## Source + +### Created by + +- @seanchen1991 \ No newline at end of file diff --git a/health-statistics/src/lib.rs b/health-statistics/src/lib.rs new file mode 100644 index 0000000..341c76d --- /dev/null +++ b/health-statistics/src/lib.rs @@ -0,0 +1,39 @@ +// This stub file contains items that aren't used yet; feel free to remove this module attribute +// to enable stricter warnings. +#![allow(unused)] + +pub struct User { + name: String, + age: u32, + weight: f32, +} + +impl User { + pub fn new(name: String, age: u32, weight: f32) -> Self { + Self { + name, + age, + weight + } + } + + pub fn name(&self) -> &str { + &self.name + } + + pub fn age(&self) -> u32 { + self.age + } + + pub fn weight(&self) -> f32 { + self.weight + } + + pub fn set_age(&mut self, new_age: u32) { + self.age = new_age + } + + pub fn set_weight(&mut self, new_weight: f32) { + self.weight = new_weight + } +} diff --git a/health-statistics/target/.rustc_info.json b/health-statistics/target/.rustc_info.json new file mode 100644 index 0000000..31dce69 --- /dev/null +++ b/health-statistics/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":547482148007961314,"outputs":{"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/arthurdanjou/.rustup/toolchains/stable-aarch64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.61.0 (fe5b13d68 2022-05-18)\nbinary: rustc\ncommit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e\ncommit-date: 2022-05-18\nhost: aarch64-apple-darwin\nrelease: 1.61.0\nLLVM version: 14.0.0\n","stderr":""},"2797684049618456168":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/health-statistics/target/CACHEDIR.TAG b/health-statistics/target/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/health-statistics/target/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/health-statistics/target/debug/.cargo-lock b/health-statistics/target/debug/.cargo-lock new file mode 100644 index 0000000..e69de29 diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/dep-test-integration-test-health-statistics b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/dep-test-integration-test-health-statistics new file mode 100644 index 0000000..1194ef2 Binary files /dev/null and b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/dep-test-integration-test-health-statistics differ diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/invoked.timestamp b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics new file mode 100644 index 0000000..2605726 --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics @@ -0,0 +1 @@ +49b44726676092fc \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics.json b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics.json new file mode 100644 index 0000000..fb859c4 --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-3855589a8de7cac3/test-integration-test-health-statistics.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":2579682610403781797,"profile":4734105543796642768,"path":2325082057379190229,"deps":[[12509414400136546036,"health_statistics",false,4812219169218510717]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/health_statistics-3855589a8de7cac3/dep-test-integration-test-health-statistics"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/dep-lib-health_statistics b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/dep-lib-health_statistics new file mode 100644 index 0000000..fb1fbec Binary files /dev/null and b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/dep-lib-health_statistics differ diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/invoked.timestamp b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics new file mode 100644 index 0000000..a631d36 --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics @@ -0,0 +1 @@ +7d3f9892d66fc842 \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics.json b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics.json new file mode 100644 index 0000000..13f0ae8 --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-62e3af01ebef91c4/lib-health_statistics.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":5102910661884761124,"profile":11736316127369858332,"path":17523903030608720598,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/health_statistics-62e3af01ebef91c4/dep-lib-health_statistics"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/dep-test-lib-health_statistics b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/dep-test-lib-health_statistics new file mode 100644 index 0000000..fb1fbec Binary files /dev/null and b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/dep-test-lib-health_statistics differ diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/invoked.timestamp b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics new file mode 100644 index 0000000..6bd733a --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics @@ -0,0 +1 @@ +9fbd36fdd78f00fb \ No newline at end of file diff --git a/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics.json b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics.json new file mode 100644 index 0000000..3fb6396 --- /dev/null +++ b/health-statistics/target/debug/.fingerprint/health_statistics-786b473719522259/test-lib-health_statistics.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":5102910661884761124,"profile":4734105543796642768,"path":17523903030608720598,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/health_statistics-786b473719522259/dep-test-lib-health_statistics"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3 b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3 new file mode 100755 index 0000000..85600c2 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3 differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1axv6kvdj40gv5rz.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1axv6kvdj40gv5rz.rcgu.o new file mode 100644 index 0000000..392d5f7 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1axv6kvdj40gv5rz.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1dcei0y1v2t5ia7p.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1dcei0y1v2t5ia7p.rcgu.o new file mode 100644 index 0000000..7da8b87 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1dcei0y1v2t5ia7p.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1e0wxsi01nwvdv5r.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1e0wxsi01nwvdv5r.rcgu.o new file mode 100644 index 0000000..35df59d Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1e0wxsi01nwvdv5r.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1tgv0nxp643orots.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1tgv0nxp643orots.rcgu.o new file mode 100644 index 0000000..3811c85 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1tgv0nxp643orots.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1txsgyvjryajslxj.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1txsgyvjryajslxj.rcgu.o new file mode 100644 index 0000000..b86e99c Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.1txsgyvjryajslxj.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20aefclrez33evz4.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20aefclrez33evz4.rcgu.o new file mode 100644 index 0000000..e1cffef Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20aefclrez33evz4.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20nv2ic31tco7svp.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20nv2ic31tco7svp.rcgu.o new file mode 100644 index 0000000..2ce86c4 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.20nv2ic31tco7svp.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.22c57s2x8hsvtg5y.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.22c57s2x8hsvtg5y.rcgu.o new file mode 100644 index 0000000..a4948f1 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.22c57s2x8hsvtg5y.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.26ynr5ulxkvpjjt5.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.26ynr5ulxkvpjjt5.rcgu.o new file mode 100644 index 0000000..fbeae2b Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.26ynr5ulxkvpjjt5.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.28qk73vyvswrfqu6.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.28qk73vyvswrfqu6.rcgu.o new file mode 100644 index 0000000..370708f Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.28qk73vyvswrfqu6.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2p9u9uo38ur59y7a.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2p9u9uo38ur59y7a.rcgu.o new file mode 100644 index 0000000..f26b103 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2p9u9uo38ur59y7a.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2qusupj40oqbdtza.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2qusupj40oqbdtza.rcgu.o new file mode 100644 index 0000000..0141717 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2qusupj40oqbdtza.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2tt0ll5dsle0mq4w.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2tt0ll5dsle0mq4w.rcgu.o new file mode 100644 index 0000000..6973a97 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2tt0ll5dsle0mq4w.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2uct5nk2v9t87n90.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2uct5nk2v9t87n90.rcgu.o new file mode 100644 index 0000000..89b8c56 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2uct5nk2v9t87n90.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2yso0t4jx2881hcr.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2yso0t4jx2881hcr.rcgu.o new file mode 100644 index 0000000..f1edf4d Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.2yso0t4jx2881hcr.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.31rdjamhuvu5n8vf.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.31rdjamhuvu5n8vf.rcgu.o new file mode 100644 index 0000000..1672bfa Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.31rdjamhuvu5n8vf.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3433yezlxwyuoqed.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3433yezlxwyuoqed.rcgu.o new file mode 100644 index 0000000..dc9c17b Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3433yezlxwyuoqed.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3c9lop65oj2m2gmn.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3c9lop65oj2m2gmn.rcgu.o new file mode 100644 index 0000000..e003fd3 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3c9lop65oj2m2gmn.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3do7zpl74tzbjblt.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3do7zpl74tzbjblt.rcgu.o new file mode 100644 index 0000000..99d8141 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3do7zpl74tzbjblt.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3jwl5rkqkmlhtlmx.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3jwl5rkqkmlhtlmx.rcgu.o new file mode 100644 index 0000000..b39602d Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3jwl5rkqkmlhtlmx.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3kk3pjnas0cuuiy2.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3kk3pjnas0cuuiy2.rcgu.o new file mode 100644 index 0000000..680423e Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3kk3pjnas0cuuiy2.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uk3rd2yfh601hou.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uk3rd2yfh601hou.rcgu.o new file mode 100644 index 0000000..ded6c5c Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uk3rd2yfh601hou.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uz50vqyhyws77ih.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uz50vqyhyws77ih.rcgu.o new file mode 100644 index 0000000..00383a6 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3uz50vqyhyws77ih.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3v0y38uco7a0aphz.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3v0y38uco7a0aphz.rcgu.o new file mode 100644 index 0000000..69ad40f Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3v0y38uco7a0aphz.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3ylkelhwn9lgem5a.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3ylkelhwn9lgem5a.rcgu.o new file mode 100644 index 0000000..ce76303 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3ylkelhwn9lgem5a.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3zkh9tl81jck79t1.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3zkh9tl81jck79t1.rcgu.o new file mode 100644 index 0000000..addc049 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.3zkh9tl81jck79t1.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42fwhacbmejwirge.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42fwhacbmejwirge.rcgu.o new file mode 100644 index 0000000..cd8174f Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42fwhacbmejwirge.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42xtabd83oh5es40.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42xtabd83oh5es40.rcgu.o new file mode 100644 index 0000000..4ec11ad Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.42xtabd83oh5es40.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4a6ucbc2kdl5mpoj.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4a6ucbc2kdl5mpoj.rcgu.o new file mode 100644 index 0000000..e5d0c2b Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4a6ucbc2kdl5mpoj.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4eo9096cg6762yu3.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4eo9096cg6762yu3.rcgu.o new file mode 100644 index 0000000..83e5071 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4eo9096cg6762yu3.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4gj42fp8opqzevxs.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4gj42fp8opqzevxs.rcgu.o new file mode 100644 index 0000000..8184ddc Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4gj42fp8opqzevxs.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4glr0u6oyz66qffq.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4glr0u6oyz66qffq.rcgu.o new file mode 100644 index 0000000..656cf51 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4glr0u6oyz66qffq.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4mc9ml3hwlmfexhf.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4mc9ml3hwlmfexhf.rcgu.o new file mode 100644 index 0000000..417cd86 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4mc9ml3hwlmfexhf.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4z761h1ersufqo5p.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4z761h1ersufqo5p.rcgu.o new file mode 100644 index 0000000..79708ef Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.4z761h1ersufqo5p.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.556kengi742qefva.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.556kengi742qefva.rcgu.o new file mode 100644 index 0000000..0f0007e Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.556kengi742qefva.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.57tl013je3q88i1s.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.57tl013je3q88i1s.rcgu.o new file mode 100644 index 0000000..b5777f1 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.57tl013je3q88i1s.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.7i7aozkhoyubttk.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.7i7aozkhoyubttk.rcgu.o new file mode 100644 index 0000000..50d8d0b Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.7i7aozkhoyubttk.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.d b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.d new file mode 100644 index 0000000..01b7f21 --- /dev/null +++ b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.d @@ -0,0 +1,5 @@ +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3: tests/health-statistics.rs + +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.d: tests/health-statistics.rs + +tests/health-statistics.rs: diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.evx7pf3egc4tlxi.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.evx7pf3egc4tlxi.rcgu.o new file mode 100644 index 0000000..12d0b2f Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.evx7pf3egc4tlxi.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jbrmdfgn6uozu5k.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jbrmdfgn6uozu5k.rcgu.o new file mode 100644 index 0000000..e5b553f Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jbrmdfgn6uozu5k.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jiz326s5m1p6pyh.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jiz326s5m1p6pyh.rcgu.o new file mode 100644 index 0000000..48f29cb Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.jiz326s5m1p6pyh.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.ojovsdgbm7b3282.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.ojovsdgbm7b3282.rcgu.o new file mode 100644 index 0000000..3e0bc26 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.ojovsdgbm7b3282.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.rggag69kdlh3j9x.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.rggag69kdlh3j9x.rcgu.o new file mode 100644 index 0000000..abb6100 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.rggag69kdlh3j9x.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.wuz8oy91vqkk5az.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.wuz8oy91vqkk5az.rcgu.o new file mode 100644 index 0000000..8d0d7e4 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.wuz8oy91vqkk5az.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.y14g302yov14udl.rcgu.o b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.y14g302yov14udl.rcgu.o new file mode 100644 index 0000000..42aea91 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-3855589a8de7cac3.y14g302yov14udl.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-62e3af01ebef91c4.d b/health-statistics/target/debug/deps/health_statistics-62e3af01ebef91c4.d new file mode 100644 index 0000000..83bae24 --- /dev/null +++ b/health-statistics/target/debug/deps/health_statistics-62e3af01ebef91c4.d @@ -0,0 +1,7 @@ +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-62e3af01ebef91c4.rmeta: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rlib: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-62e3af01ebef91c4.d: src/lib.rs + +src/lib.rs: diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259 b/health-statistics/target/debug/deps/health_statistics-786b473719522259 new file mode 100755 index 0000000..60cc135 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259 differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.2oyn1bwaxwir7rh2.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.2oyn1bwaxwir7rh2.rcgu.o new file mode 100644 index 0000000..098fbfc Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.2oyn1bwaxwir7rh2.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.2usrohqur4w4rlqc.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.2usrohqur4w4rlqc.rcgu.o new file mode 100644 index 0000000..8ea6a86 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.2usrohqur4w4rlqc.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.31ppenxrrxzsrvc1.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.31ppenxrrxzsrvc1.rcgu.o new file mode 100644 index 0000000..16d836d Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.31ppenxrrxzsrvc1.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.3k67n6prgcq5htqe.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.3k67n6prgcq5htqe.rcgu.o new file mode 100644 index 0000000..ff07691 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.3k67n6prgcq5htqe.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.3z9objmfwt6qc2pp.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.3z9objmfwt6qc2pp.rcgu.o new file mode 100644 index 0000000..dff32f0 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.3z9objmfwt6qc2pp.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.4mjghmun3qjvgedl.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.4mjghmun3qjvgedl.rcgu.o new file mode 100644 index 0000000..7549b49 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.4mjghmun3qjvgedl.rcgu.o differ diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.d b/health-statistics/target/debug/deps/health_statistics-786b473719522259.d new file mode 100644 index 0000000..d84ddb9 --- /dev/null +++ b/health-statistics/target/debug/deps/health_statistics-786b473719522259.d @@ -0,0 +1,5 @@ +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-786b473719522259: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/health-statistics/target/debug/deps/health_statistics-786b473719522259.d: src/lib.rs + +src/lib.rs: diff --git a/health-statistics/target/debug/deps/health_statistics-786b473719522259.lh8jxnfh6vk6ysl.rcgu.o b/health-statistics/target/debug/deps/health_statistics-786b473719522259.lh8jxnfh6vk6ysl.rcgu.o new file mode 100644 index 0000000..2f97654 Binary files /dev/null and b/health-statistics/target/debug/deps/health_statistics-786b473719522259.lh8jxnfh6vk6ysl.rcgu.o differ diff --git a/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rlib b/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rlib new file mode 100644 index 0000000..fa4b621 Binary files /dev/null and b/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rlib differ diff --git a/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rmeta b/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rmeta new file mode 100644 index 0000000..1db0834 Binary files /dev/null and b/health-statistics/target/debug/deps/libhealth_statistics-62e3af01ebef91c4.rmeta differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/16prd1nrmahviyoj.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/16prd1nrmahviyoj.o new file mode 100644 index 0000000..1251b7b Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/16prd1nrmahviyoj.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1eey4j60ycy45m9b.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1eey4j60ycy45m9b.o new file mode 100644 index 0000000..a14a326 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1eey4j60ycy45m9b.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1y02p1jwjkfs38lw.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1y02p1jwjkfs38lw.o new file mode 100644 index 0000000..1fda799 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/1y02p1jwjkfs38lw.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/29d8v53crfl14yzj.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/29d8v53crfl14yzj.o new file mode 100644 index 0000000..b013915 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/29d8v53crfl14yzj.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2exc4icvt32raobv.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2exc4icvt32raobv.o new file mode 100644 index 0000000..fe3c11f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2exc4icvt32raobv.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2sqv2j4ibkxx2n4r.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2sqv2j4ibkxx2n4r.o new file mode 100644 index 0000000..16f642e Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/2sqv2j4ibkxx2n4r.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31io21mslsywi62o.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31io21mslsywi62o.o new file mode 100644 index 0000000..1985db1 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31io21mslsywi62o.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31j5ou4qyz51zwji.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31j5ou4qyz51zwji.o new file mode 100644 index 0000000..d049210 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/31j5ou4qyz51zwji.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/3o0evmb3ava2deg6.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/3o0evmb3ava2deg6.o new file mode 100644 index 0000000..e178fcc Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/3o0evmb3ava2deg6.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/4f5nzt1abvy187pa.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/4f5nzt1abvy187pa.o new file mode 100644 index 0000000..db7a4e6 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/4f5nzt1abvy187pa.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/5zfurk7h9wnsvaq.o b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/5zfurk7h9wnsvaq.o new file mode 100644 index 0000000..a7d117a Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/5zfurk7h9wnsvaq.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/dep-graph.bin b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/dep-graph.bin new file mode 100644 index 0000000..4f5e04e Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/dep-graph.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/query-cache.bin b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/query-cache.bin new file mode 100644 index 0000000..fcaa474 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/query-cache.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/work-products.bin b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/work-products.bin new file mode 100644 index 0000000..6b3c360 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw-5nsarnsew07m/work-products.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw.lock b/health-statistics/target/debug/incremental/health_statistics-1zvqxpj9wovvg/s-gc680gs8c9-1smdekw.lock new file mode 100755 index 0000000..e69de29 diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2oyn1bwaxwir7rh2.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2oyn1bwaxwir7rh2.o new file mode 100644 index 0000000..098fbfc Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2oyn1bwaxwir7rh2.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2usrohqur4w4rlqc.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2usrohqur4w4rlqc.o new file mode 100644 index 0000000..8ea6a86 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/2usrohqur4w4rlqc.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/31ppenxrrxzsrvc1.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/31ppenxrrxzsrvc1.o new file mode 100644 index 0000000..16d836d Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/31ppenxrrxzsrvc1.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3k67n6prgcq5htqe.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3k67n6prgcq5htqe.o new file mode 100644 index 0000000..ff07691 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3k67n6prgcq5htqe.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3z9objmfwt6qc2pp.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3z9objmfwt6qc2pp.o new file mode 100644 index 0000000..dff32f0 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/3z9objmfwt6qc2pp.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/4mjghmun3qjvgedl.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/4mjghmun3qjvgedl.o new file mode 100644 index 0000000..7549b49 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/4mjghmun3qjvgedl.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/dep-graph.bin b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/dep-graph.bin new file mode 100644 index 0000000..13e00c9 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/dep-graph.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/lh8jxnfh6vk6ysl.o b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/lh8jxnfh6vk6ysl.o new file mode 100644 index 0000000..2f97654 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/lh8jxnfh6vk6ysl.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/query-cache.bin b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/query-cache.bin new file mode 100644 index 0000000..42e169f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/query-cache.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/work-products.bin b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/work-products.bin new file mode 100644 index 0000000..7bdc6a6 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301-161apnxpeqnnz/work-products.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301.lock b/health-statistics/target/debug/incremental/health_statistics-3e5tngork7gw5/s-gc680gs8c9-ssd301.lock new file mode 100755 index 0000000..e69de29 diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1axv6kvdj40gv5rz.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1axv6kvdj40gv5rz.o new file mode 100644 index 0000000..392d5f7 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1axv6kvdj40gv5rz.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1dcei0y1v2t5ia7p.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1dcei0y1v2t5ia7p.o new file mode 100644 index 0000000..7da8b87 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1dcei0y1v2t5ia7p.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1e0wxsi01nwvdv5r.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1e0wxsi01nwvdv5r.o new file mode 100644 index 0000000..35df59d Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1e0wxsi01nwvdv5r.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1tgv0nxp643orots.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1tgv0nxp643orots.o new file mode 100644 index 0000000..3811c85 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1tgv0nxp643orots.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1txsgyvjryajslxj.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1txsgyvjryajslxj.o new file mode 100644 index 0000000..b86e99c Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/1txsgyvjryajslxj.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20aefclrez33evz4.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20aefclrez33evz4.o new file mode 100644 index 0000000..e1cffef Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20aefclrez33evz4.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20nv2ic31tco7svp.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20nv2ic31tco7svp.o new file mode 100644 index 0000000..2ce86c4 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/20nv2ic31tco7svp.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/22c57s2x8hsvtg5y.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/22c57s2x8hsvtg5y.o new file mode 100644 index 0000000..a4948f1 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/22c57s2x8hsvtg5y.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/26ynr5ulxkvpjjt5.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/26ynr5ulxkvpjjt5.o new file mode 100644 index 0000000..fbeae2b Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/26ynr5ulxkvpjjt5.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/28qk73vyvswrfqu6.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/28qk73vyvswrfqu6.o new file mode 100644 index 0000000..370708f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/28qk73vyvswrfqu6.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2p9u9uo38ur59y7a.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2p9u9uo38ur59y7a.o new file mode 100644 index 0000000..f26b103 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2p9u9uo38ur59y7a.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2qusupj40oqbdtza.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2qusupj40oqbdtza.o new file mode 100644 index 0000000..0141717 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2qusupj40oqbdtza.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2tt0ll5dsle0mq4w.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2tt0ll5dsle0mq4w.o new file mode 100644 index 0000000..6973a97 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2tt0ll5dsle0mq4w.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2uct5nk2v9t87n90.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2uct5nk2v9t87n90.o new file mode 100644 index 0000000..89b8c56 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2uct5nk2v9t87n90.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2yso0t4jx2881hcr.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2yso0t4jx2881hcr.o new file mode 100644 index 0000000..f1edf4d Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/2yso0t4jx2881hcr.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/31rdjamhuvu5n8vf.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/31rdjamhuvu5n8vf.o new file mode 100644 index 0000000..1672bfa Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/31rdjamhuvu5n8vf.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3433yezlxwyuoqed.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3433yezlxwyuoqed.o new file mode 100644 index 0000000..dc9c17b Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3433yezlxwyuoqed.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3c9lop65oj2m2gmn.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3c9lop65oj2m2gmn.o new file mode 100644 index 0000000..e003fd3 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3c9lop65oj2m2gmn.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3do7zpl74tzbjblt.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3do7zpl74tzbjblt.o new file mode 100644 index 0000000..99d8141 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3do7zpl74tzbjblt.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3jwl5rkqkmlhtlmx.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3jwl5rkqkmlhtlmx.o new file mode 100644 index 0000000..b39602d Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3jwl5rkqkmlhtlmx.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3kk3pjnas0cuuiy2.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3kk3pjnas0cuuiy2.o new file mode 100644 index 0000000..680423e Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3kk3pjnas0cuuiy2.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uk3rd2yfh601hou.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uk3rd2yfh601hou.o new file mode 100644 index 0000000..ded6c5c Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uk3rd2yfh601hou.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uz50vqyhyws77ih.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uz50vqyhyws77ih.o new file mode 100644 index 0000000..00383a6 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3uz50vqyhyws77ih.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3v0y38uco7a0aphz.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3v0y38uco7a0aphz.o new file mode 100644 index 0000000..69ad40f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3v0y38uco7a0aphz.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3ylkelhwn9lgem5a.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3ylkelhwn9lgem5a.o new file mode 100644 index 0000000..ce76303 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3ylkelhwn9lgem5a.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3zkh9tl81jck79t1.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3zkh9tl81jck79t1.o new file mode 100644 index 0000000..addc049 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/3zkh9tl81jck79t1.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42fwhacbmejwirge.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42fwhacbmejwirge.o new file mode 100644 index 0000000..cd8174f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42fwhacbmejwirge.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42xtabd83oh5es40.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42xtabd83oh5es40.o new file mode 100644 index 0000000..4ec11ad Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/42xtabd83oh5es40.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4a6ucbc2kdl5mpoj.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4a6ucbc2kdl5mpoj.o new file mode 100644 index 0000000..e5d0c2b Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4a6ucbc2kdl5mpoj.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4eo9096cg6762yu3.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4eo9096cg6762yu3.o new file mode 100644 index 0000000..83e5071 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4eo9096cg6762yu3.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4gj42fp8opqzevxs.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4gj42fp8opqzevxs.o new file mode 100644 index 0000000..8184ddc Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4gj42fp8opqzevxs.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4glr0u6oyz66qffq.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4glr0u6oyz66qffq.o new file mode 100644 index 0000000..656cf51 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4glr0u6oyz66qffq.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4mc9ml3hwlmfexhf.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4mc9ml3hwlmfexhf.o new file mode 100644 index 0000000..417cd86 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4mc9ml3hwlmfexhf.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4z761h1ersufqo5p.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4z761h1ersufqo5p.o new file mode 100644 index 0000000..79708ef Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/4z761h1ersufqo5p.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/556kengi742qefva.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/556kengi742qefva.o new file mode 100644 index 0000000..0f0007e Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/556kengi742qefva.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/57tl013je3q88i1s.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/57tl013je3q88i1s.o new file mode 100644 index 0000000..b5777f1 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/57tl013je3q88i1s.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/7i7aozkhoyubttk.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/7i7aozkhoyubttk.o new file mode 100644 index 0000000..50d8d0b Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/7i7aozkhoyubttk.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/dep-graph.bin b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/dep-graph.bin new file mode 100644 index 0000000..23e51a2 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/dep-graph.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/evx7pf3egc4tlxi.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/evx7pf3egc4tlxi.o new file mode 100644 index 0000000..12d0b2f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/evx7pf3egc4tlxi.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jbrmdfgn6uozu5k.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jbrmdfgn6uozu5k.o new file mode 100644 index 0000000..e5b553f Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jbrmdfgn6uozu5k.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jiz326s5m1p6pyh.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jiz326s5m1p6pyh.o new file mode 100644 index 0000000..48f29cb Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/jiz326s5m1p6pyh.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/ojovsdgbm7b3282.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/ojovsdgbm7b3282.o new file mode 100644 index 0000000..3e0bc26 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/ojovsdgbm7b3282.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/query-cache.bin b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/query-cache.bin new file mode 100644 index 0000000..8b20055 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/query-cache.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/rggag69kdlh3j9x.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/rggag69kdlh3j9x.o new file mode 100644 index 0000000..abb6100 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/rggag69kdlh3j9x.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/work-products.bin b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/work-products.bin new file mode 100644 index 0000000..7a668e7 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/work-products.bin differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/wuz8oy91vqkk5az.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/wuz8oy91vqkk5az.o new file mode 100644 index 0000000..8d0d7e4 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/wuz8oy91vqkk5az.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/y14g302yov14udl.o b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/y14g302yov14udl.o new file mode 100644 index 0000000..42aea91 Binary files /dev/null and b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a-3qsttiajmt90m/y14g302yov14udl.o differ diff --git a/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a.lock b/health-statistics/target/debug/incremental/health_statistics-3u06mloo6asnz/s-gc680gv8le-1pd8v6a.lock new file mode 100755 index 0000000..e69de29 diff --git a/health-statistics/tests/health-statistics.rs b/health-statistics/tests/health-statistics.rs new file mode 100644 index 0000000..26ff2a7 --- /dev/null +++ b/health-statistics/tests/health-statistics.rs @@ -0,0 +1,43 @@ +use health_statistics::*; + +const NAME: &str = "Ebenezer"; +const AGE: u32 = 89; +const WEIGHT: f32 = 131.6; + +#[test] +fn test_name() { + let user = User::new(NAME.into(), AGE, WEIGHT); + assert_eq!(user.name(), NAME); +} + +#[test] +#[ignore] +fn test_age() { + let user = User::new(NAME.into(), AGE, WEIGHT); + assert_eq!(user.age(), AGE); +} + +#[test] +#[ignore] +fn test_weight() { + let user = User::new(NAME.into(), AGE, WEIGHT); + assert!((user.weight() - WEIGHT).abs() < f32::EPSILON); +} + +#[test] +#[ignore] +fn test_set_age() { + let new_age: u32 = 90; + let mut user = User::new(NAME.into(), AGE, WEIGHT); + user.set_age(new_age); + assert_eq!(user.age(), new_age); +} + +#[test] +#[ignore] +fn test_set_weight() { + let new_weight: f32 = 129.4; + let mut user = User::new(NAME.into(), AGE, WEIGHT); + user.set_weight(new_weight); + assert!((user.weight() - new_weight).abs() < f32::EPSILON); +} diff --git a/high-scores/.exercism/config.json b/high-scores/.exercism/config.json new file mode 100644 index 0000000..44e9276 --- /dev/null +++ b/high-scores/.exercism/config.json @@ -0,0 +1,25 @@ +{ + "blurb": "Manage a player's High Score list", + "authors": [ + "Br1ght0ne" + ], + "contributors": [ + "coriolinus", + "cwhakes", + "efx", + "ErikSchierboom" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/high-scores.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Tribute to the eighties' arcade game Frogger" +} diff --git a/high-scores/.exercism/metadata.json b/high-scores/.exercism/metadata.json new file mode 100644 index 0000000..f0a08d2 --- /dev/null +++ b/high-scores/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"high-scores","id":"024dda37cd244e269df7d69c653b766a","url":"https://exercism.org/tracks/rust/exercises/high-scores","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/high-scores/.gitignore b/high-scores/.gitignore new file mode 100644 index 0000000..e130ceb --- /dev/null +++ b/high-scores/.gitignore @@ -0,0 +1,8 @@ +# Generated by exercism rust track exercise tool +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/high-scores/Cargo.toml b/high-scores/Cargo.toml new file mode 100644 index 0000000..6e7360a --- /dev/null +++ b/high-scores/Cargo.toml @@ -0,0 +1,6 @@ +[dependencies] + +[package] +edition = "2021" +name = "high-scores" +version = "4.0.0" diff --git a/high-scores/HELP.md b/high-scores/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/high-scores/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/high-scores/README.md b/high-scores/README.md new file mode 100644 index 0000000..0627cb1 --- /dev/null +++ b/high-scores/README.md @@ -0,0 +1,30 @@ +# High Scores + +Welcome to High Scores on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Manage a game player's High Score list. + +Your task is to build a high-score component of the classic Frogger game, one of the highest selling and addictive games of all time, and a classic of the arcade era. Your task is to write methods that return the highest score from the list, the last added score and the three highest scores. + +Consider retaining a reference to `scores` in the struct - copying is not +necessary. You will require some lifetime annotations, though. + +## Source + +### Created by + +- @Br1ght0ne + +### Contributed to by + +- @coriolinus +- @cwhakes +- @efx +- @ErikSchierboom + +### Based on + +Tribute to the eighties' arcade game Frogger \ No newline at end of file diff --git a/high-scores/src/lib.rs b/high-scores/src/lib.rs new file mode 100644 index 0000000..e5c10ec --- /dev/null +++ b/high-scores/src/lib.rs @@ -0,0 +1,31 @@ +#[derive(Debug)] +pub struct HighScores<'a> { + scores: &'a [u32] +} + +impl<'a> HighScores<'a> { + pub fn new(scores: &'a [u32]) -> Self { + Self { + scores + } + } + + pub fn scores(&self) -> &[u32] { + self.scores + } + + pub fn latest(&self) -> Option { + self.scores.last().cloned() + } + + pub fn personal_best(&self) -> Option { + self.scores.iter().max().cloned() + } + + pub fn personal_top_three(&self) -> Vec { + let mut top_vec = self.scores.to_vec(); + top_vec.sort_unstable_by(|a, b| b.cmp(a)); + top_vec.truncate(3); + top_vec + } +} diff --git a/high-scores/tests/high-scores.rs b/high-scores/tests/high-scores.rs new file mode 100644 index 0000000..f47634c --- /dev/null +++ b/high-scores/tests/high-scores.rs @@ -0,0 +1,78 @@ +use high_scores::HighScores; + +#[test] +fn test_list_of_scores() { + let expected = [30, 50, 20, 70]; + let high_scores = HighScores::new(&expected); + assert_eq!(high_scores.scores(), &expected); +} + +#[test] +#[ignore] +fn test_latest_score() { + let high_scores = HighScores::new(&[100, 0, 90, 30]); + assert_eq!(high_scores.latest(), Some(30)); +} + +#[test] +#[ignore] +fn test_latest_score_empty() { + let high_scores = HighScores::new(&[]); + assert_eq!(high_scores.latest(), None); +} + +#[test] +#[ignore] +fn test_personal_best() { + let high_scores = HighScores::new(&[40, 100, 70]); + assert_eq!(high_scores.personal_best(), Some(100)); +} + +#[test] +#[ignore] +fn test_personal_best_empty() { + let high_scores = HighScores::new(&[]); + assert_eq!(high_scores.personal_best(), None); +} + +#[test] +#[ignore] +fn test_personal_top_three() { + let high_scores = HighScores::new(&[10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70]); + assert_eq!(high_scores.personal_top_three(), vec![100, 90, 70]); +} + +#[test] +#[ignore] +fn test_personal_top_three_highest_to_lowest() { + let high_scores = HighScores::new(&[20, 10, 30]); + assert_eq!(high_scores.personal_top_three(), vec![30, 20, 10]); +} + +#[test] +#[ignore] +fn test_personal_top_three_with_tie() { + let high_scores = HighScores::new(&[40, 20, 40, 30]); + assert_eq!(high_scores.personal_top_three(), vec![40, 40, 30]); +} + +#[test] +#[ignore] +fn test_personal_top_three_with_less_than_three_scores() { + let high_scores = HighScores::new(&[30, 70]); + assert_eq!(high_scores.personal_top_three(), vec![70, 30]); +} + +#[test] +#[ignore] +fn test_personal_top_three_only_one_score() { + let high_scores = HighScores::new(&[40]); + assert_eq!(high_scores.personal_top_three(), vec![40]); +} + +#[test] +#[ignore] +fn test_personal_top_three_empty() { + let high_scores = HighScores::new(&[]); + assert!(high_scores.personal_top_three().is_empty()); +} diff --git a/leap/.exercism/config.json b/leap/.exercism/config.json new file mode 100644 index 0000000..81e0d3b --- /dev/null +++ b/leap/.exercism/config.json @@ -0,0 +1,50 @@ +{ + "blurb": "Given a year, report if it is a leap year.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "andy5995", + "ashleygwilliams", + "ClashTheBunny", + "coriolinus", + "cwhakes", + "darnuria", + "EduardoBautista", + "efx", + "Emerentius", + "ErikSchierboom", + "hunger", + "IanWhitney", + "JIghtuse", + "jonasbn", + "kytrinyx", + "leoyvens", + "lutostag", + "mkantor", + "navossoc", + "nfiles", + "petertseng", + "pminten", + "rofrol", + "sshine", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/leap.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "JavaRanch Cattle Drive, exercise 3", + "source_url": "http://www.javaranch.com/leap.jsp" +} diff --git a/leap/.exercism/metadata.json b/leap/.exercism/metadata.json new file mode 100644 index 0000000..cf9e9ef --- /dev/null +++ b/leap/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"leap","id":"c35ab9ae8fba4e40ba03e6eaa273e2ed","url":"https://exercism.org/tracks/rust/exercises/leap","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/leap/.gitignore b/leap/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/leap/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/leap/Cargo.toml b/leap/Cargo.toml new file mode 100644 index 0000000..af78359 --- /dev/null +++ b/leap/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "leap" +version = "1.6.0" diff --git a/leap/HELP.md b/leap/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/leap/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/leap/README.md b/leap/README.md new file mode 100644 index 0000000..205b088 --- /dev/null +++ b/leap/README.md @@ -0,0 +1,72 @@ +# Leap + +Welcome to Leap on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a year, report if it is a leap year. + +The tricky thing here is that a leap year in the Gregorian calendar occurs: + +```text +on every year that is evenly divisible by 4 + except every year that is evenly divisible by 100 + unless the year is also evenly divisible by 400 +``` + +For example, 1997 is not a leap year, but 1996 is. 1900 is not a leap +year, but 2000 is. + +## Notes + +Though our exercise adopts some very simple rules, there is more to +learn! + +For a delightful, four minute explanation of the whole leap year +phenomenon, go watch [this youtube video][video]. + +[video]: http://www.youtube.com/watch?v=xX96xng7sAE + +You may use the [`arithmetic remainder` operator](https://doc.rust-lang.org/book/appendix-02-operators.html) to test for divisibility. + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @andy5995 +- @ashleygwilliams +- @ClashTheBunny +- @coriolinus +- @cwhakes +- @darnuria +- @EduardoBautista +- @efx +- @Emerentius +- @ErikSchierboom +- @hunger +- @IanWhitney +- @JIghtuse +- @jonasbn +- @kytrinyx +- @leoyvens +- @lutostag +- @mkantor +- @navossoc +- @nfiles +- @petertseng +- @pminten +- @rofrol +- @sshine +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +JavaRanch Cattle Drive, exercise 3 - http://www.javaranch.com/leap.jsp \ No newline at end of file diff --git a/leap/src/lib.rs b/leap/src/lib.rs new file mode 100644 index 0000000..3a34ef4 --- /dev/null +++ b/leap/src/lib.rs @@ -0,0 +1,8 @@ +pub fn is_leap_year(year: u64) -> bool { + match (year % 400, year % 100, year % 4) { + (0, _, _) => true, // Is divisible by 400 + (_, 0, _) => false, // Is divisible by 100 and 400 + (_, _, 0) => true, // Is divisible by 4, 100 and 400 + _ => false + } +} diff --git a/leap/tests/leap.rs b/leap/tests/leap.rs new file mode 100644 index 0000000..a8a69a4 --- /dev/null +++ b/leap/tests/leap.rs @@ -0,0 +1,100 @@ +fn process_leapyear_case(year: u64, expected: bool) { + assert_eq!(leap::is_leap_year(year), expected); +} + +#[test] +fn test_year_not_divisible_by_4_common_year() { + process_leapyear_case(2015, false); +} + +#[test] +#[ignore] +fn test_year_divisible_by_2_not_divisible_by_4_in_common_year() { + process_leapyear_case(1970, false); +} + +#[test] +#[ignore] +fn test_year_divisible_by_4_not_divisible_by_100_leap_year() { + process_leapyear_case(1996, true); +} + +#[test] +#[ignore] +fn test_year_divisible_by_4_and_5_is_still_a_leap_year() { + process_leapyear_case(1960, true); +} + +#[test] +#[ignore] +fn test_year_divisible_by_100_not_divisible_by_400_common_year() { + process_leapyear_case(2100, false); +} + +#[test] +#[ignore] +fn test_year_divisible_by_100_but_not_by_3_is_still_not_a_leap_year() { + process_leapyear_case(1900, false); +} + +#[test] +#[ignore] +fn test_year_divisible_by_400_leap_year() { + process_leapyear_case(2000, true); +} + +#[test] +#[ignore] +fn test_year_divisible_by_400_but_not_by_125_is_still_a_leap_year() { + process_leapyear_case(2400, true); +} + +#[test] +#[ignore] +fn test_year_divisible_by_200_not_divisible_by_400_common_year() { + process_leapyear_case(1800, false); +} + +#[test] +#[ignore] +fn test_any_old_year() { + process_leapyear_case(1997, false); +} + +#[test] +#[ignore] +fn test_early_years() { + process_leapyear_case(1, false); + process_leapyear_case(4, true); + process_leapyear_case(100, false); + process_leapyear_case(400, true); + process_leapyear_case(900, false); +} + +#[test] +#[ignore] +fn test_century() { + process_leapyear_case(1700, false); + process_leapyear_case(1800, false); + process_leapyear_case(1900, false); +} + +#[test] +#[ignore] +fn test_exceptional_centuries() { + process_leapyear_case(1600, true); + process_leapyear_case(2000, true); + process_leapyear_case(2400, true); +} + +#[test] +#[ignore] +fn test_years_1600_to_1699() { + let incorrect_years = (1600..1700) + .filter(|&year| leap::is_leap_year(year) != (year % 4 == 0)) + .collect::>(); + + if !incorrect_years.is_empty() { + panic!("incorrect result for years: {:?}", incorrect_years); + } +} diff --git a/low-power-embedded-game/.exercism/config.json b/low-power-embedded-game/.exercism/config.json new file mode 100644 index 0000000..3c04a59 --- /dev/null +++ b/low-power-embedded-game/.exercism/config.json @@ -0,0 +1,18 @@ +{ + "blurb": "Learn tuples while writing convenience functions for a low-power embedded game", + "authors": [ + "coriolinus" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/low-power-embedded-game.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + } +} diff --git a/low-power-embedded-game/.exercism/metadata.json b/low-power-embedded-game/.exercism/metadata.json new file mode 100644 index 0000000..a2f3115 --- /dev/null +++ b/low-power-embedded-game/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"low-power-embedded-game","id":"2fd7036aa0ff422eb2dafc8ca7ba5ff2","url":"https://exercism.org/tracks/rust/exercises/low-power-embedded-game","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/low-power-embedded-game/Cargo.lock b/low-power-embedded-game/Cargo.lock new file mode 100644 index 0000000..f10136f --- /dev/null +++ b/low-power-embedded-game/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "low_power_embedded_game" +version = "0.1.0" diff --git a/low-power-embedded-game/Cargo.toml b/low-power-embedded-game/Cargo.toml new file mode 100644 index 0000000..8cfaf6a --- /dev/null +++ b/low-power-embedded-game/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "low_power_embedded_game" +version = "0.1.0" +edition = "2021" diff --git a/low-power-embedded-game/HELP.md b/low-power-embedded-game/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/low-power-embedded-game/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/low-power-embedded-game/HINTS.md b/low-power-embedded-game/HINTS.md new file mode 100644 index 0000000..a056a5a --- /dev/null +++ b/low-power-embedded-game/HINTS.md @@ -0,0 +1,23 @@ +# Hints + +## General + +- [Rust Book: The Tuple Type](https://doc.rust-lang.org/book/ch03-02-data-types.html#the-tuple-type) +- [Rust By Example: Tuples](https://doc.rust-lang.org/stable/rust-by-example/primitives/tuples.html) +- [Rust By Example: Destructuring](https://doc.rust-lang.org/stable/rust-by-example/flow_control/match/destructuring.html) + +## 1. Write a function `divmod` which returns both the quotient and remainder of a division + +- Don't worry about optimizing for efficiency; the naive implementation is fine + +## 2. Write an iterator adaptor `evens` which returns the even items from an arbitrary iterator + +- Just chain together the suggested methods and everything will work out +- A number `n` is even if `n % 2 == 0` +- A closure is a function with abbreviated syntax: the argument name(s) go within a pair of `|` symbols, and the expression follows. Unlike normal functions, it is not always necessary to explicitly state the type of each argument, just the name. For example, here is how you can construct an iterator of odd squares: `(0..).map(|n| 2 * n + 1).map(|n| n * n)`. + +## 3. Implement a `manhattan` method on a `Position` tuple struct + +- Don't worry about method syntax; just replacing the `unimplemented` portion within the `impl Position` block will do the right thing. +- Consider that some values within a `Position` may be negative, but a distance is never negative. +- Calculating the absolute value is [built-in](https://doc.rust-lang.org/std/primitive.i16.html#method.abs) \ No newline at end of file diff --git a/low-power-embedded-game/README.md b/low-power-embedded-game/README.md new file mode 100644 index 0000000..9027657 --- /dev/null +++ b/low-power-embedded-game/README.md @@ -0,0 +1,162 @@ +# Low-Power Embedded Game + +Welcome to Low-Power Embedded Game on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Tuples are a lightweight way to group a fixed set of arbitrary types of data together. A tuple doesn't have +a particular name; naming a data structure turns it into a `struct`. A tuple's fields don't have names; +they are accessed by means of destructuring or by position. + +## Syntax + +### Creation + +Tuples are always created with a tuple expression: + +```rust +// pointless but legal +let unit = (); +// single element +let single_element = ("note the comma",); +// two element +let two_element = (123, "elements can be of differing types"); +``` + +Tuples can have an arbitrary number of elements. + +### Access by destructuring + +It is possible to access the elements of a tuple by destructuring. This just means assigning variable +names to the individual elements of the tuple, consuming it. + +```rust +let (elem1, _elem2) = two_element; +assert_eq!(elem1, 123); +``` + +### Access by position + +It is also possible to access the elements of a tuple by numeric positional index. Indexing, as always, +begins at 0. + +```rust +let notation = single_element.0; +assert_eq!(notation, "note the comma"); +``` + +## Tuple Structs + +You will also be asked to work with tuple structs. Like normal structs, these are named types; unlike +normal structs, they have anonymous fields. Their syntax is very similar to normal tuple syntax. It is +legal to use both destructuring and positional access. + +```rust +struct TupleStruct(u8, i32); +let my_tuple_struct = TupleStruct(123, -321); +let neg = my_tuple_struct.1; +let TupleStruct(byte, _) = my_tuple_struct; +assert_eq!(neg, -321); +assert_eq!(byte, 123); +``` + +### Field Visibility + +All fields of anonymous tuples are always public. However, fields of tuple structs have individual +visibility which defaults to private, just like fields of standard structs. You can make the fields +public with the `pub` modifier, just as in a standard struct. + +```rust +// fails due to private fields +mod tuple { pub struct TupleStruct(u8, i32); } +fn main() { let _my_tuple_struct = tuple::TupleStruct(123, -321); } +``` + +```rust +// succeeds: fields are public +mod tuple { pub struct TupleStruct(pub u8, pub i32); } +fn main() { let _my_tuple_struct = tuple::TupleStruct(123, -321); } +``` + +## Instructions + +You are working on a game targeting a low-power embedded system and need to write several convenience functions which will be used by other parts of the game. + +## 1. Calculate the quotient and remainder of a division + +A quotient is the output of a division. + +```rust +fn divmod(dividend: i16, divisor: i16) -> (i16, i16) +``` + +Example: + +```rust +assert_eq!(divmod(10, 3), (3, 1)); +``` + +## 2. Choose even-positioned items from an iterator + +This will be helpful to enable a screen-buffer optimization, your boss promises. + +Iterators are items which expose the methods defined by the [`Iterator` trait](https://doc.rust-lang.org/std/iter/trait.Iterator.html). That documentation is fairly extensive, because they offer many methods; here are the most relevant properties: + +- An iterator is an arbitrary-length stream of items +- They have an [`enumerate` method](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.enumerate) which returns a tuple `(i, val)` for each value +- They have a [`filter` method](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.filter) which uses a closure to determine whether to yield an element of the iterator +- They have a [`map` method](https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.map) which uses a closure to modify elements of the iterator + +Because your function can run on any kind of iterator, it uses `impl` to signify that this is a trait instance instead of a simple item. Likewise, the `` syntax just means that it doesn't matter what kind of item the iterator produces; your function can produce the even elements of any iterator. + +```rust +fn evens(iter: impl Iterator) -> impl Iterator +``` + +Examples: + +```rust +let mut even_ints = evens(0_u8..); +assert_eq!(even_ints.next(), Some(0)); +assert_eq!(even_ints.next(), Some(2)); +assert_eq!(even_ints.next(), Some(4)); +assert_eq!(even_ints.next(), Some(6)); +``` + +```rust +let mut evens_from_odds = evens(1_i16..); +assert_eq!(evens_from_odds.next(), Some(1)); +assert_eq!(evens_from_odds.next(), Some(3)); +assert_eq!(evens_from_odds.next(), Some(5)); +assert_eq!(evens_from_odds.next(), Some(7)); +``` + +## 3. Calculate the manhattan distance of a position from the origin + +For mapping convenience, you have a tuple struct `Position`: + +```rust +struct Position(i16, i16); +``` + +You need to implement a method `manhattan` on `Position` which returns the [manhattan distance](https://en.wikipedia.org/wiki/Taxicab_geometry) of that position from the origin (`Position(0, 0)`). + +```rust +impl Position { + fn manhattan(&self) -> i16 +} +``` + +Example: + +```rust +assert_eq!(Position(3, 4).manhattan(), 7); +``` + +## Source + +### Created by + +- @coriolinus \ No newline at end of file diff --git a/low-power-embedded-game/src/lib.rs b/low-power-embedded-game/src/lib.rs new file mode 100644 index 0000000..490e42d --- /dev/null +++ b/low-power-embedded-game/src/lib.rs @@ -0,0 +1,20 @@ +// This stub file contains items that aren't used yet; feel free to remove this module attribute +// to enable stricter warnings. +#![allow(unused)] + +pub fn divmod(dividend: i16, divisor: i16) -> (i16, i16) { + let quotient = dividend / divisor; + let rest = dividend % divisor; + (quotient, rest) +} + +pub fn evens(iter: impl Iterator) -> impl Iterator { + iter.step_by(2) +} + +pub struct Position(pub i16, pub i16); +impl Position { + pub fn manhattan(&self) -> i16 { + self.0.abs() + self.1.abs() + } +} diff --git a/low-power-embedded-game/tests/low-power-embedded-game.rs b/low-power-embedded-game/tests/low-power-embedded-game.rs new file mode 100644 index 0000000..10d965e --- /dev/null +++ b/low-power-embedded-game/tests/low-power-embedded-game.rs @@ -0,0 +1,110 @@ +mod divmod { + //! tests of divmod + //! + //! note that we're only testing positive quantities; no need to get into the mod/rem distinction + + use low_power_embedded_game::divmod; + + #[test] + fn example() { + assert_eq!(divmod(10, 3), (3, 1)); + } + + #[test] + #[ignore] + fn powerup() { + assert_eq!(divmod(100, 3), (33, 1)); + } + + #[test] + #[ignore] + fn less() { + assert_eq!(divmod(3, 10), (0, 3)); + } + + #[test] + #[ignore] + fn eq() { + assert_eq!(divmod(3, 3), (1, 0)); + } + + #[test] + #[ignore] + fn multiple() { + assert_eq!(divmod(9, 3), (3, 0)); + } +} + +mod evens { + use low_power_embedded_game::evens; + + #[test] + #[ignore] + fn simple_i32() { + let out: Vec = evens(0..).take(5).collect(); + assert_eq!(out, &[0, 2, 4, 6, 8]); + } + + #[test] + #[ignore] + fn reverse_i32() { + let out: Vec = evens((0..=10).rev()).collect(); + assert_eq!(out, &[10, 8, 6, 4, 2, 0]); + } + + #[test] + #[ignore] + fn offset_i32() { + let out: Vec = evens(1..).take(5).collect(); + assert_eq!(out, &[1, 3, 5, 7, 9]); + } + + #[test] + #[ignore] + fn strs() { + let input = "You really must never be above joking.".split_whitespace(); + let expected: Vec<_> = "You must be joking.".split_whitespace().collect(); + let out: Vec<_> = evens(input).collect(); + assert_eq!(out, expected); + } +} + +mod manhattan { + use low_power_embedded_game::Position; + + #[test] + #[ignore] + fn origin() { + assert_eq!(Position(0, 0).manhattan(), 0); + } + + #[test] + #[ignore] + fn q1_unit() { + assert_eq!(Position(1, 1).manhattan(), 2); + } + + #[test] + #[ignore] + fn q2_unit() { + assert_eq!(Position(1, -1).manhattan(), 2); + } + + #[test] + #[ignore] + fn q3_unit() { + assert_eq!(Position(-1, -1).manhattan(), 2); + } + + #[test] + #[ignore] + fn q4_unit() { + assert_eq!(Position(-1, 1).manhattan(), 2); + } + + #[test] + #[ignore] + fn relative_prime() { + assert_eq!(Position(30, 70).manhattan(), 100); + } +} diff --git a/magazine-cutout/.exercism/config.json b/magazine-cutout/.exercism/config.json new file mode 100644 index 0000000..73ef569 --- /dev/null +++ b/magazine-cutout/.exercism/config.json @@ -0,0 +1,18 @@ +{ + "blurb": "Use `HashMap` and the entry API methods to write an anonymous letter.", + "authors": [ + "seanchen1991" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/magazine-cutout.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + } +} diff --git a/magazine-cutout/.exercism/metadata.json b/magazine-cutout/.exercism/metadata.json new file mode 100644 index 0000000..a7a72b7 --- /dev/null +++ b/magazine-cutout/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"magazine-cutout","id":"eb285587ce1448bcb2de9d241e8d048c","url":"https://exercism.org/tracks/rust/exercises/magazine-cutout","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/magazine-cutout/Cargo.lock b/magazine-cutout/Cargo.lock new file mode 100644 index 0000000..4ebde29 --- /dev/null +++ b/magazine-cutout/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "magazine_cutout" +version = "0.1.0" diff --git a/magazine-cutout/Cargo.toml b/magazine-cutout/Cargo.toml new file mode 100644 index 0000000..2ad12ce --- /dev/null +++ b/magazine-cutout/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "magazine_cutout" +version = "0.1.0" +edition = "2021" diff --git a/magazine-cutout/HELP.md b/magazine-cutout/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/magazine-cutout/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/magazine-cutout/HINTS.md b/magazine-cutout/HINTS.md new file mode 100644 index 0000000..e18f204 --- /dev/null +++ b/magazine-cutout/HINTS.md @@ -0,0 +1,17 @@ +# Hints + +## General + +- Upon fetching an entry using the `entry` method, the entry can be modified in-place after dereferencing it. + +- The `or_insert` [method](https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_insert) inserts the given value in the case when the entry is vacant, and returns a mutable reference to the value in the entry. + +```rust +*counter.entry(key).or_insert(0) += 1; +``` + +- The `or_default` [method](https://doc.rust-lang.org/std/collections/hash_map/enum.Entry.html#method.or_default) ensures a value is in the entry by inserting the default value if empty, and returns a mutable reference to the value in the entry. + +```rust +*counter.entry(key).or_default() += 1; +``` \ No newline at end of file diff --git a/magazine-cutout/README.md b/magazine-cutout/README.md new file mode 100644 index 0000000..861f78d --- /dev/null +++ b/magazine-cutout/README.md @@ -0,0 +1,56 @@ +# Magazine Cutout + +Welcome to Magazine Cutout on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Rust's entry API provides a view into a single entry in map, which may be either a `HashMap` or a `BTreeMap`. The entry may be either occupied and vacant, and the API provides methods to modify the contents of the entry. + +## Instructions + +In this exercise you'll be using a `HashMap`, along with entry API methods, to solve a simple algorithm problem. + +Given `&[&str]` representing the words of a magazine article, and `&[&str]` representing the words of a note you would like to send, can you compose your note by cutting words out of the magazine and pasting them into a letter? + +Notes: + +- This implies physical cutting and pasting; the magazine needs to contain at least as many copies of each word as the note requires. +- Capitalization matters; just because you're pasting together a note composed from words of a magazine doesn't mean you're willing to be ungrammatical. + +You'll start with the following stubbed function signature: + +```rust +pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool { + unimplemented!() +} +``` + +Given the following input + +```rust +let magazine = "two times three is not four".split_whitespace().collect::>(); +let note = "two times two is four".split_whitespace().collect::>(); +assert!(!can_construct_note(&magazine, ¬e)); +``` + +The function returns `false` since the magazine only contains one instance of `"two"` when the note requires two of them. + +The following input will succeed: + +```rust +let magazine = "Astronomer Amy Mainzer spent hours chatting with Leonardo DiCaprio for Netflix's 'Don't Look Up'".split_whitespace().collect::>(); +let note = "Amy Mainzer chatting with Leonardo DiCaprio." + .split_whitespace() + .collect::>(); +assert!(can_construct_note(&magazine, ¬e)); +``` + +The function returns `true` since the magazine contains all the words that the note requires. + +## Source + +### Created by + +- @seanchen1991 \ No newline at end of file diff --git a/magazine-cutout/src/lib.rs b/magazine-cutout/src/lib.rs new file mode 100644 index 0000000..ba875bd --- /dev/null +++ b/magazine-cutout/src/lib.rs @@ -0,0 +1,25 @@ +// This stub file contains items that aren't used yet; feel free to remove this module attribute +// to enable stricter warnings. +#![allow(unused)] + +use std::collections::HashMap; + +pub fn can_construct_note(magazine: &[&str], note: &[&str]) -> bool { + let magazine_map = magazine + .iter() + .fold(HashMap::new(), |mut words, str| { + *words.entry(str).or_insert(0) += 1; + words + }); + + let note_map = note + .iter() + .fold(HashMap::new(), |mut words, str| { + *words.entry(str).or_insert(0) += 1; + words + }); + + note_map + .iter() + .all(&|(word, count)| magazine_map.get(word).unwrap_or(&0) >= count) +} diff --git a/magazine-cutout/tests/magazine-cutout.rs b/magazine-cutout/tests/magazine-cutout.rs new file mode 100644 index 0000000..e0b1a14 --- /dev/null +++ b/magazine-cutout/tests/magazine-cutout.rs @@ -0,0 +1,72 @@ +use magazine_cutout::*; + +#[test] +fn test_magazine_has_fewer_words_available_than_needed() { + let magazine = "two times three is not four" + .split_whitespace() + .collect::>(); + let note = "two times two is four" + .split_whitespace() + .collect::>(); + assert!(!can_construct_note(&magazine, ¬e)); +} + +#[test] +#[ignore] +fn test_fn_returns_true_for_good_input() { + let magazine = "The metro orchestra unveiled its new grand piano today. Its donor paraphrased Nathn Hale: \"I only regret that I have but one to give \"".split_whitespace().collect::>(); + let note = "give one grand today." + .split_whitespace() + .collect::>(); + assert!(can_construct_note(&magazine, ¬e)); +} + +#[test] +#[ignore] +fn test_fn_returns_false_for_bad_input() { + let magazine = "I've got a lovely bunch of coconuts." + .split_whitespace() + .collect::>(); + let note = "I've got som coconuts" + .split_whitespace() + .collect::>(); + assert!(!can_construct_note(&magazine, ¬e)); +} + +#[test] +#[ignore] +fn test_case_sensitivity() { + let magazine = "i've got some lovely coconuts" + .split_whitespace() + .collect::>(); + let note = "I've got some coconuts" + .split_whitespace() + .collect::>(); + assert!(!can_construct_note(&magazine, ¬e)); + + let magazine = "I've got some lovely coconuts" + .split_whitespace() + .collect::>(); + let note = "i've got some coconuts" + .split_whitespace() + .collect::>(); + assert!(!can_construct_note(&magazine, ¬e)); +} + +#[test] +#[ignore] +fn test_magzine_has_more_than_words_available_than_needed() { + let magazine = "Enough is enough when enough is enough" + .split_whitespace() + .collect::>(); + let note = "enough is enough".split_whitespace().collect::>(); + assert!(can_construct_note(&magazine, ¬e)); +} + +#[test] +#[ignore] +fn test_magazine_has_one_good_word_many_times_but_still_cant_construct() { + let magazine = "A A A".split_whitespace().collect::>(); + let note = "A nice day".split_whitespace().collect::>(); + assert!(!can_construct_note(&magazine, ¬e)); +} diff --git a/minesweeper/.exercism/config.json b/minesweeper/.exercism/config.json new file mode 100644 index 0000000..2039791 --- /dev/null +++ b/minesweeper/.exercism/config.json @@ -0,0 +1,38 @@ +{ + "blurb": "Add the numbers to a minesweeper board", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "ashleygwilliams", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "ffflorian", + "IanWhitney", + "kytrinyx", + "lutostag", + "mkantor", + "nfiles", + "petertseng", + "rofrol", + "stringparser", + "workingjubilee", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/minesweeper.rs" + ], + "example": [ + ".meta/example.rs" + ] + } +} diff --git a/minesweeper/.exercism/metadata.json b/minesweeper/.exercism/metadata.json new file mode 100644 index 0000000..0e7f753 --- /dev/null +++ b/minesweeper/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"minesweeper","id":"e0b259aa9e034660a9b3a0f926564e78","url":"https://exercism.org/tracks/rust/exercises/minesweeper","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/minesweeper/.gitignore b/minesweeper/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/minesweeper/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/minesweeper/Cargo.toml b/minesweeper/Cargo.toml new file mode 100644 index 0000000..5b53e26 --- /dev/null +++ b/minesweeper/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "minesweeper" +version = "1.1.0" diff --git a/minesweeper/HELP.md b/minesweeper/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/minesweeper/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/minesweeper/README.md b/minesweeper/README.md new file mode 100644 index 0000000..efca354 --- /dev/null +++ b/minesweeper/README.md @@ -0,0 +1,80 @@ +# Minesweeper + +Welcome to Minesweeper on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Add the mine counts to a completed Minesweeper board. + +Minesweeper is a popular game where the user has to find the mines using +numeric hints that indicate how many mines are directly adjacent +(horizontally, vertically, diagonally) to a square. + +In this exercise you have to create some code that counts the number of +mines adjacent to a given empty square and replaces that square with the +count. + +The board is a rectangle composed of blank space (' ') characters. A mine +is represented by an asterisk ('\*') character. + +If a given space has no adjacent mines at all, leave that square blank. + +## Examples + +For example you may receive a 5 x 4 board like this (empty spaces are +represented here with the '·' character for display on screen): + +``` +·*·*· +··*·· +··*·· +····· +``` + +And your code will transform it into this: + +``` +1*3*1 +13*31 +·2*2· +·111· +``` + +## Performance Hint + +All the inputs and outputs are in ASCII. Rust `String`s and `&str` are utf8, +so while one might expect "Hello".chars() to be simple, it actually has to +check each char to see if it's 1, 2, 3 or 4 `u8`s long. If we know a `&str` +is ASCII then we can call `.as_bytes()` and refer to the underlying data via a `&[u8]` slice. +Iterating over a u8 slice of ASCII is much quicker as there are no codepoints +involved - every ASCII char is one u8 long. + +Can you complete the challenge without cloning the input? + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @ashleygwilliams +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @ffflorian +- @IanWhitney +- @kytrinyx +- @lutostag +- @mkantor +- @nfiles +- @petertseng +- @rofrol +- @stringparser +- @workingjubilee +- @xakon +- @ZapAnton \ No newline at end of file diff --git a/minesweeper/src/lib.rs b/minesweeper/src/lib.rs new file mode 100644 index 0000000..50a9e2e --- /dev/null +++ b/minesweeper/src/lib.rs @@ -0,0 +1,39 @@ +pub fn annotate(minefield: &[&str]) -> Vec { + let valid_range = |x: usize, max_count: usize| { + (x.saturating_sub(1))..(x + 1).min(max_count.saturating_sub(1)).saturating_add(1) + }; + + let find_mines = |r: usize, c: usize| -> usize { + valid_range(r, minefield.len()) + .map(|r1| { + minefield + .get(r1 as usize) + .map(|&row| { + //println!("{} for {} {}", r1, r, row); + row.get(valid_range(c, row.len())) + .map(|ns| ns.chars().filter(|c| c == &'*').count()) + .unwrap_or(0) + }) + .unwrap_or(0) + }) + .sum::() + }; + + minefield + .iter() + .enumerate() + .map(|(row, &rowstr)| { + rowstr + .chars() + .enumerate() + .map(|(col, ch)| match ch { + '*' => '*', + _ => match find_mines(row, col) { + 0 => ' ', + k => char::from_digit(k as u32, 10).unwrap(), + }, + }) + .collect::() + }) + .collect::>() +} diff --git a/minesweeper/tests/minesweeper.rs b/minesweeper/tests/minesweeper.rs new file mode 100644 index 0000000..f05255e --- /dev/null +++ b/minesweeper/tests/minesweeper.rs @@ -0,0 +1,152 @@ +use minesweeper::annotate; + +fn remove_annotations(board: &[&str]) -> Vec { + board.iter().map(|r| remove_annotations_in_row(r)).collect() +} + +fn remove_annotations_in_row(row: &str) -> String { + row.chars() + .map(|ch| match ch { + '*' => '*', + _ => ' ', + }) + .collect() +} + +fn run_test(test_case: &[&str]) { + let cleaned = remove_annotations(test_case); + let cleaned_strs = cleaned.iter().map(|r| &r[..]).collect::>(); + let expected = test_case.iter().map(|&r| r.to_string()).collect::>(); + assert_eq!(expected, annotate(&cleaned_strs)); +} + +#[test] +fn no_rows() { + #[rustfmt::skip] + run_test(&[ + ]); +} + +#[test] +#[ignore] +fn no_columns() { + #[rustfmt::skip] + run_test(&[ + "", + ]); +} + +#[test] +#[ignore] +fn no_mines() { + #[rustfmt::skip] + run_test(&[ + " ", + " ", + " ", + ]); +} + +#[test] +#[ignore] +fn board_with_only_mines() { + #[rustfmt::skip] + run_test(&[ + "***", + "***", + "***", + ]); +} + +#[test] +#[ignore] +fn mine_surrounded_by_spaces() { + #[rustfmt::skip] + run_test(&[ + "111", + "1*1", + "111", + ]); +} + +#[test] +#[ignore] +fn space_surrounded_by_mines() { + #[rustfmt::skip] + run_test(&[ + "***", + "*8*", + "***", + ]); +} + +#[test] +#[ignore] +fn horizontal_line() { + #[rustfmt::skip] + run_test(&[ + "1*2*1", + ]); +} + +#[test] +#[ignore] +fn horizontal_line_mines_at_edges() { + #[rustfmt::skip] + run_test(&[ + "*1 1*", + ]); +} + +#[test] +#[ignore] +fn vertical_line() { + #[rustfmt::skip] + run_test(&[ + "1", + "*", + "2", + "*", + "1", + ]); +} + +#[test] +#[ignore] +fn vertical_line_mines_at_edges() { + #[rustfmt::skip] + run_test(&[ + "*", + "1", + " ", + "1", + "*", + ]); +} + +#[test] +#[ignore] +fn cross() { + #[rustfmt::skip] + run_test(&[ + " 2*2 ", + "25*52", + "*****", + "25*52", + " 2*2 ", + ]); +} + +#[test] +#[ignore] +fn large_board() { + #[rustfmt::skip] + run_test(&[ + "1*22*1", + "12*322", + " 123*2", + "112*4*", + "1*22*2", + "111111", + ]); +} diff --git a/paasio/.exercism/config.json b/paasio/.exercism/config.json new file mode 100644 index 0000000..8570268 --- /dev/null +++ b/paasio/.exercism/config.json @@ -0,0 +1,36 @@ +{ + "blurb": "Report network IO statistics", + "authors": [ + "coriolinus" + ], + "contributors": [ + "ccouzens", + "ClashTheBunny", + "cwhakes", + "efx", + "ErikSchierboom", + "petertseng", + "rofrol", + "shenek", + "stringparser", + "TheDarkula", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/paasio.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Brian Matsuo", + "source_url": "https://github.com/bmatsuo", + "custom": { + "ignore-count-ignores": true + } +} diff --git a/paasio/.exercism/metadata.json b/paasio/.exercism/metadata.json new file mode 100644 index 0000000..bfefd4c --- /dev/null +++ b/paasio/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"paasio","id":"af246ce4cd074c99bce6db004348cdcc","url":"https://exercism.org/tracks/rust/exercises/paasio","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/paasio/.gitignore b/paasio/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/paasio/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/paasio/Cargo.toml b/paasio/Cargo.toml new file mode 100644 index 0000000..91ee301 --- /dev/null +++ b/paasio/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "paasio" +version = "0.0.0" diff --git a/paasio/HELP.md b/paasio/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/paasio/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/paasio/README.md b/paasio/README.md new file mode 100644 index 0000000..433d7f8 --- /dev/null +++ b/paasio/README.md @@ -0,0 +1,48 @@ +# Paasio + +Welcome to Paasio on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Report network IO statistics. + +You are writing a [PaaS][], and you need a way to bill customers based +on network and filesystem usage. + +Create a wrapper for network connections and files that can report IO +statistics. The wrapper must report: + +- The total number of bytes read/written. +- The total number of read/write operations. + +[PaaS]: http://en.wikipedia.org/wiki/Platform_as_a_service + +Network and file operations are implemented in terms of the [`io::Read`][read] and [`io::Write`][write] traits. It will therefore be necessary to implement those traits for your types. + +[read]: https://doc.rust-lang.org/std/io/trait.Read.html +[write]: https://doc.rust-lang.org/std/io/trait.Write.html + +## Source + +### Created by + +- @coriolinus + +### Contributed to by + +- @ccouzens +- @ClashTheBunny +- @cwhakes +- @efx +- @ErikSchierboom +- @petertseng +- @rofrol +- @shenek +- @stringparser +- @TheDarkula +- @ZapAnton + +### Based on + +Brian Matsuo - https://github.com/bmatsuo \ No newline at end of file diff --git a/paasio/src/lib.rs b/paasio/src/lib.rs new file mode 100644 index 0000000..6e2c771 --- /dev/null +++ b/paasio/src/lib.rs @@ -0,0 +1,90 @@ +use std::io::{Read, Result, Write}; +use std::marker::PhantomData; + +pub struct ReadStats { + wrapped: R, + _phantom: PhantomData, + bytes_through: usize, + reads: usize, +} + +impl ReadStats { + // _wrapped is ignored because R is not bounded on Debug or Display and therefore + // can't be passed through format!(). For actual implementation you will likely + // wish to remove the leading underscore so the variable is not ignored. + pub fn new(_wrapped: R) -> ReadStats { + Self { + wrapped: _wrapped, + _phantom: PhantomData, + reads: 0, + bytes_through: 0 + } + } + + pub fn get_ref(&self) -> &R { + &self.wrapped + } + + pub fn bytes_through(&self) -> usize { + self.bytes_through + } + + pub fn reads(&self) -> usize { + self.reads + } +} + +impl Read for ReadStats { + fn read(&mut self, buf: &mut [u8]) -> Result { + let reads_bytes = self.wrapped.read(buf)?; + self.bytes_through += reads_bytes; + self.reads += 1; + Ok(reads_bytes) + } +} + +pub struct WriteStats { + wrapped: W, + _phantom: PhantomData, + bytes_through: usize, + writes: usize, +} + +impl WriteStats { + // _wrapped is ignored because W is not bounded on Debug or Display and therefore + // can't be passed through format!(). For actual implementation you will likely + // wish to remove the leading underscore so the variable is not ignored. + pub fn new(_wrapped: W) -> WriteStats { + Self { + wrapped: _wrapped, + _phantom: PhantomData, + bytes_through: 0, + writes: 0 + } + } + + pub fn get_ref(&self) -> &W { + &self.wrapped + } + + pub fn bytes_through(&self) -> usize { + self.bytes_through + } + + pub fn writes(&self) -> usize { + self.writes + } +} + +impl Write for WriteStats { + fn write(&mut self, buf: &[u8]) -> Result { + let write_bytes = self.wrapped.write(buf)?; + self.bytes_through += write_bytes; + self.writes += 1; + Ok(write_bytes) + } + + fn flush(&mut self) -> Result<()> { + self.wrapped.flush() + } +} diff --git a/paasio/tests/paasio.rs b/paasio/tests/paasio.rs new file mode 100644 index 0000000..d13c0d2 --- /dev/null +++ b/paasio/tests/paasio.rs @@ -0,0 +1,202 @@ +/// test a few read scenarios +macro_rules! test_read { + ($(#[$attr:meta])* $modname:ident ($input:expr, $len:expr)) => { + mod $modname { + use std::io::{Read, BufReader}; + use paasio::*; + + const CHUNK_SIZE: usize = 2; + + $(#[$attr])* + #[test] + fn test_read_passthrough() { + let data = $input; + let size = $len(&data); + let mut reader = ReadStats::new(data); + + let mut buffer = Vec::with_capacity(size); + let qty_read = reader.read_to_end(&mut buffer); + + assert!(qty_read.is_ok()); + assert_eq!(size, qty_read.unwrap()); + assert_eq!(size, buffer.len()); + // 2: first to read all the data, second to check that + // there wasn't any more pending data which simply didn't + // fit into the existing buffer + assert_eq!(2, reader.reads()); + assert_eq!(size, reader.bytes_through()); + } + + $(#[$attr])* + #[test] + fn test_read_chunks() { + let data = $input; + let size = $len(&data); + let mut reader = ReadStats::new(data); + + let mut buffer = [0_u8; CHUNK_SIZE]; + let mut chunks_read = 0; + while reader.read(&mut buffer[..]).unwrap_or_else(|_| panic!("read failed at chunk {}", chunks_read+1)) > 0 { + chunks_read += 1; + } + + assert_eq!(size / CHUNK_SIZE + std::cmp::min(1, size % CHUNK_SIZE), chunks_read); + // we read once more than the number of chunks, because the final + // read returns 0 new bytes + assert_eq!(1+chunks_read, reader.reads()); + assert_eq!(size, reader.bytes_through()); + } + + $(#[$attr])* + #[test] + fn test_read_buffered_chunks() { + let data = $input; + let size = $len(&data); + let mut reader = BufReader::new(ReadStats::new(data)); + + let mut buffer = [0_u8; CHUNK_SIZE]; + let mut chunks_read = 0; + while reader.read(&mut buffer[..]).unwrap_or_else(|_| panic!("read failed at chunk {}", chunks_read+1)) > 0 { + chunks_read += 1; + } + + assert_eq!(size / CHUNK_SIZE + std::cmp::min(1, size % CHUNK_SIZE), chunks_read); + // the BufReader should smooth out the reads, collecting into + // a buffer and performing only two read operations: + // the first collects everything into the buffer, + // and the second ensures that no data remains + assert_eq!(2, reader.get_ref().reads()); + assert_eq!(size, reader.get_ref().bytes_through()); + } + } + }; +} + +/// test a few write scenarios +macro_rules! test_write { + ($(#[$attr:meta])* $modname:ident ($input:expr, $len:expr)) => { + mod $modname { + use std::io::{self, Write, BufWriter}; + use paasio::*; + + const CHUNK_SIZE: usize = 2; + $(#[$attr])* + #[test] + fn test_write_passthrough() { + let data = $input; + let size = $len(&data); + let mut writer = WriteStats::new(Vec::with_capacity(size)); + let written = writer.write(data); + assert!(written.is_ok()); + assert_eq!(size, written.unwrap()); + assert_eq!(size, writer.bytes_through()); + assert_eq!(1, writer.writes()); + assert_eq!(data, writer.get_ref().as_slice()); + } + + $(#[$attr])* + #[test] + fn test_sink_oneshot() { + let data = $input; + let size = $len(&data); + let mut writer = WriteStats::new(io::sink()); + let written = writer.write(data); + assert!(written.is_ok()); + assert_eq!(size, written.unwrap()); + assert_eq!(size, writer.bytes_through()); + assert_eq!(1, writer.writes()); + } + + $(#[$attr])* + #[test] + fn test_sink_windowed() { + let data = $input; + let size = $len(&data); + let mut writer = WriteStats::new(io::sink()); + + let mut chunk_count = 0; + for chunk in data.chunks(CHUNK_SIZE) { + chunk_count += 1; + let written = writer.write(chunk); + assert!(written.is_ok()); + assert_eq!(CHUNK_SIZE, written.unwrap()); + } + assert_eq!(size, writer.bytes_through()); + assert_eq!(chunk_count, writer.writes()); + } + + $(#[$attr])* + #[test] + fn test_sink_buffered_windowed() { + let data = $input; + let size = $len(&data); + let mut writer = BufWriter::new(WriteStats::new(io::sink())); + + for chunk in data.chunks(CHUNK_SIZE) { + let written = writer.write(chunk); + assert!(written.is_ok()); + assert_eq!(CHUNK_SIZE, written.unwrap()); + } + // at this point, nothing should have yet been passed through to + // our writer + assert_eq!(0, writer.get_ref().bytes_through()); + assert_eq!(0, writer.get_ref().writes()); + + // after flushing, everything should pass through in one go + assert!(writer.flush().is_ok()); + assert_eq!(size, writer.get_ref().bytes_through()); + assert_eq!(1, writer.get_ref().writes()); + } + } + }; +} + +#[test] +fn test_create_stats() { + let mut data: Vec = Vec::new(); + let _ = paasio::ReadStats::new(data.as_slice()); + let _ = paasio::WriteStats::new(data.as_mut_slice()); +} + +test_read!(#[ignore] read_string ( + "Twas brillig, and the slithy toves/Did gyre and gimble in the wabe:/All mimsy were the borogoves,/And the mome raths outgrabe.".as_bytes(), + |d: &[u8]| d.len() +)); +test_write!(#[ignore] write_string ( + "Beware the Jabberwock, my son!/The jaws that bite, the claws that catch!/Beware the Jubjub bird, and shun/The frumious Bandersnatch!".as_bytes(), + |d: &[u8]| d.len() +)); + +test_read!( + #[ignore] + read_byte_literal( + &[1_u8, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144][..], + |d: &[u8]| d.len() + ) +); +test_write!( + #[ignore] + write_byte_literal( + &[2_u8, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61,][..], + |d: &[u8]| d.len() + ) +); + +test_read!( + #[ignore] + read_file( + ::std::fs::File::open("Cargo.toml").expect("Cargo.toml must be present"), + |f: &::std::fs::File| f.metadata().expect("metadata must be present").len() as usize + ) +); + +#[test] +#[ignore] +fn read_stats_by_ref_returns_wrapped_reader() { + use paasio::ReadStats; + + let input = + "Why, sometimes I've believed as many as six impossible things before breakfast".as_bytes(); + let reader = ReadStats::new(input); + assert_eq!(reader.get_ref(), &input); +} diff --git a/parallel-letter-frequency/.exercism/config.json b/parallel-letter-frequency/.exercism/config.json new file mode 100644 index 0000000..0ae63af --- /dev/null +++ b/parallel-letter-frequency/.exercism/config.json @@ -0,0 +1,42 @@ +{ + "blurb": "Count the frequency of letters in texts using parallel computation.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "ccouzens", + "ClashTheBunny", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "etrepum", + "glennpratt", + "IanWhitney", + "kytrinyx", + "lutostag", + "mkantor", + "nfiles", + "petertseng", + "rofrol", + "sjwarner-bp", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/parallel-letter-frequency.rs" + ], + "example": [ + ".meta/example.rs" + ] + } +} diff --git a/parallel-letter-frequency/.exercism/metadata.json b/parallel-letter-frequency/.exercism/metadata.json new file mode 100644 index 0000000..62feeea --- /dev/null +++ b/parallel-letter-frequency/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"parallel-letter-frequency","id":"eeb70666f1ea4f71b7f7a8fbed571e36","url":"https://exercism.org/tracks/rust/exercises/parallel-letter-frequency","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/parallel-letter-frequency/.gitignore b/parallel-letter-frequency/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/parallel-letter-frequency/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/parallel-letter-frequency/Cargo.toml b/parallel-letter-frequency/Cargo.toml new file mode 100644 index 0000000..8caaa08 --- /dev/null +++ b/parallel-letter-frequency/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "parallel-letter-frequency" +version = "0.0.0" diff --git a/parallel-letter-frequency/HELP.md b/parallel-letter-frequency/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/parallel-letter-frequency/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/parallel-letter-frequency/README.md b/parallel-letter-frequency/README.md new file mode 100644 index 0000000..3bea927 --- /dev/null +++ b/parallel-letter-frequency/README.md @@ -0,0 +1,75 @@ +# Parallel Letter Frequency + +Welcome to Parallel Letter Frequency on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Count the frequency of letters in texts using parallel computation. + +Parallelism is about doing things in parallel that can also be done +sequentially. A common example is counting the frequency of letters. +Create a function that returns the total frequency of each letter in a +list of texts and that employs parallelism. + +Learn more about concurrency in Rust here: + +- [Concurrency](https://doc.rust-lang.org/book/ch16-00-concurrency.html) + +## Bonus + +This exercise also includes a benchmark, with a sequential implementation as a +baseline. You can compare your solution to the benchmark. Observe the +effect different size inputs have on the performance of each. Can you +surpass the benchmark using concurrent programming techniques? + +As of this writing, test::Bencher is unstable and only available on +*nightly* Rust. Run the benchmarks with Cargo: + +``` +cargo bench +``` + +If you are using rustup.rs: + +``` +rustup run nightly cargo bench +``` + +- [Benchmark tests](https://doc.rust-lang.org/stable/unstable-book/library-features/test.html) + +Learn more about nightly Rust: + +- [Nightly Rust](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) +- [Installing Rust nightly](https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust) + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @ccouzens +- @ClashTheBunny +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @etrepum +- @glennpratt +- @IanWhitney +- @kytrinyx +- @lutostag +- @mkantor +- @nfiles +- @petertseng +- @rofrol +- @sjwarner-bp +- @stringparser +- @xakon +- @ZapAnton \ No newline at end of file diff --git a/parallel-letter-frequency/benches/benchmark.rs b/parallel-letter-frequency/benches/benchmark.rs new file mode 100644 index 0000000..0e5bbee --- /dev/null +++ b/parallel-letter-frequency/benches/benchmark.rs @@ -0,0 +1,102 @@ +#![feature(test)] +extern crate parallel_letter_frequency; +extern crate test; + +use std::collections::HashMap; +use test::Bencher; + +#[bench] +fn bench_tiny_parallel(b: &mut Bencher) { + let tiny = &["a"]; + b.iter(|| parallel_letter_frequency::frequency(tiny, 3)); +} + +#[bench] +fn bench_tiny_sequential(b: &mut Bencher) { + let tiny = &["a"]; + b.iter(|| frequency(tiny)); +} + +#[bench] +fn bench_small_parallel(b: &mut Bencher) { + let texts = all_texts(1); + b.iter(|| parallel_letter_frequency::frequency(&texts, 3)); +} + +#[bench] +fn bench_small_sequential(b: &mut Bencher) { + let texts = all_texts(1); + b.iter(|| frequency(&texts)); +} + +#[bench] +fn bench_large_parallel(b: &mut Bencher) { + let texts = all_texts(30); + b.iter(|| parallel_letter_frequency::frequency(&texts, 3)); +} + +#[bench] +fn bench_large_sequential(b: &mut Bencher) { + let texts = all_texts(30); + b.iter(|| frequency(&texts)); +} + +/// Simple sequential char frequency. Can it be beat? +pub fn frequency(texts: &[&str]) -> HashMap { + let mut map = HashMap::new(); + + for line in texts { + for chr in line.chars().filter(|c| c.is_alphabetic()) { + if let Some(c) = chr.to_lowercase().next() { + (*map.entry(c).or_insert(0)) += 1; + } + } + } + + map +} + +fn all_texts(repeat: usize) -> Vec<&'static str> { + [ODE_AN_DIE_FREUDE, WILHELMUS, STAR_SPANGLED_BANNER] + .iter() + .cycle() + .take(3 * repeat) + .flat_map(|anthem| anthem.iter().cloned()) + .collect() +} + +// Poem by Friedrich Schiller. The corresponding music is the European Anthem. +pub const ODE_AN_DIE_FREUDE: [&str; 8] = [ + "Freude schöner Götterfunken", + "Tochter aus Elysium,", + "Wir betreten feuertrunken,", + "Himmlische, dein Heiligtum!", + "Deine Zauber binden wieder", + "Was die Mode streng geteilt;", + "Alle Menschen werden Brüder,", + "Wo dein sanfter Flügel weilt.", +]; + +// Dutch national anthem +pub const WILHELMUS: [&str; 8] = [ + "Wilhelmus van Nassouwe", + "ben ik, van Duitsen bloed,", + "den vaderland getrouwe", + "blijf ik tot in den dood.", + "Een Prinse van Oranje", + "ben ik, vrij, onverveerd,", + "den Koning van Hispanje", + "heb ik altijd geëerd.", +]; + +// American national anthem +pub const STAR_SPANGLED_BANNER: [&str; 8] = [ + "O say can you see by the dawn's early light,", + "What so proudly we hailed at the twilight's last gleaming,", + "Whose broad stripes and bright stars through the perilous fight,", + "O'er the ramparts we watched, were so gallantly streaming?", + "And the rockets' red glare, the bombs bursting in air,", + "Gave proof through the night that our flag was still there;", + "O say does that star-spangled banner yet wave,", + "O'er the land of the free and the home of the brave?", +]; diff --git a/parallel-letter-frequency/src/lib.rs b/parallel-letter-frequency/src/lib.rs new file mode 100644 index 0000000..5a67232 --- /dev/null +++ b/parallel-letter-frequency/src/lib.rs @@ -0,0 +1,41 @@ +use std::collections::HashMap; +use std::thread; + +// RESULTS +// test bench_large_parallel ... bench: 114,105 ns/iter (+/- 1,816) +// test bench_large_sequential ... bench: 397,330 ns/iter (+/- 3,721) +// test bench_small_parallel ... bench: 47,283 ns/iter (+/- 585) +// test bench_small_sequential ... bench: 14,012 ns/iter (+/- 1,005) +// test bench_tiny_parallel ... bench: 15,059 ns/iter (+/- 299) +// test bench_tiny_sequential ... bench: 44 ns/iter (+/- 0) + +pub fn frequency(input: &[&str], worker_count: usize) -> HashMap { + let mut thread_pool = vec![]; + let mut letters: HashMap = HashMap::new(); + + for lines in input.chunks(input.len() / worker_count + 1) { + let string = lines.join(""); + let worker = thread::spawn(move || { + let mut letters: HashMap = HashMap::new(); + for c in string + .chars() + .filter(|c| c.is_alphabetic()) + .map(|c| c.to_ascii_lowercase()) { + if c .is_alphabetic() { + *letters.entry(c).or_default() += 1; + } + } + letters + }); + thread_pool.push(worker); + } + + for thread in thread_pool { + let response = thread.join().unwrap(); + for (key, value) in response { + *letters.entry(key).or_default() += value; + } + } + + letters +} diff --git a/parallel-letter-frequency/tests/parallel-letter-frequency.rs b/parallel-letter-frequency/tests/parallel-letter-frequency.rs new file mode 100644 index 0000000..8e79fea --- /dev/null +++ b/parallel-letter-frequency/tests/parallel-letter-frequency.rs @@ -0,0 +1,131 @@ +use std::collections::HashMap; + +use parallel_letter_frequency as frequency; + +// Poem by Friedrich Schiller. The corresponding music is the European Anthem. +const ODE_AN_DIE_FREUDE: [&str; 8] = [ + "Freude schöner Götterfunken", + "Tochter aus Elysium,", + "Wir betreten feuertrunken,", + "Himmlische, dein Heiligtum!", + "Deine Zauber binden wieder", + "Was die Mode streng geteilt;", + "Alle Menschen werden Brüder,", + "Wo dein sanfter Flügel weilt.", +]; + +// Dutch national anthem +const WILHELMUS: [&str; 8] = [ + "Wilhelmus van Nassouwe", + "ben ik, van Duitsen bloed,", + "den vaderland getrouwe", + "blijf ik tot in den dood.", + "Een Prinse van Oranje", + "ben ik, vrij, onverveerd,", + "den Koning van Hispanje", + "heb ik altijd geëerd.", +]; + +// American national anthem +const STAR_SPANGLED_BANNER: [&str; 8] = [ + "O say can you see by the dawn's early light,", + "What so proudly we hailed at the twilight's last gleaming,", + "Whose broad stripes and bright stars through the perilous fight,", + "O'er the ramparts we watched, were so gallantly streaming?", + "And the rockets' red glare, the bombs bursting in air,", + "Gave proof through the night that our flag was still there;", + "O say does that star-spangled banner yet wave,", + "O'er the land of the free and the home of the brave?", +]; + +#[test] +fn test_no_texts() { + assert_eq!(frequency::frequency(&[], 4), HashMap::new()); +} + +#[test] +#[ignore] +fn test_one_letter() { + let mut hm = HashMap::new(); + hm.insert('a', 1); + assert_eq!(frequency::frequency(&["a"], 4), hm); +} + +#[test] +#[ignore] +fn test_case_insensitivity() { + let mut hm = HashMap::new(); + hm.insert('a', 2); + assert_eq!(frequency::frequency(&["aA"], 4), hm); +} + +#[test] +#[ignore] +fn test_many_empty_lines() { + let v = vec![""; 1000]; + assert_eq!(frequency::frequency(&v[..], 4), HashMap::new()); +} + +#[test] +#[ignore] +fn test_many_times_same_text() { + let v = vec!["abc"; 1000]; + let mut hm = HashMap::new(); + hm.insert('a', 1000); + hm.insert('b', 1000); + hm.insert('c', 1000); + assert_eq!(frequency::frequency(&v[..], 4), hm); +} + +#[test] +#[ignore] +fn test_punctuation_doesnt_count() { + assert!(!frequency::frequency(&WILHELMUS, 4).contains_key(&',')); +} + +#[test] +#[ignore] +fn test_numbers_dont_count() { + assert!(!frequency::frequency(&["Testing, 1, 2, 3"], 4).contains_key(&'1')); +} + +#[test] +#[ignore] +fn test_all_three_anthems_1_worker() { + let mut v = Vec::new(); + for anthem in [ODE_AN_DIE_FREUDE, WILHELMUS, STAR_SPANGLED_BANNER].iter() { + for line in anthem.iter() { + v.push(*line); + } + } + let freqs = frequency::frequency(&v[..], 1); + assert_eq!(freqs.get(&'a'), Some(&49)); + assert_eq!(freqs.get(&'t'), Some(&56)); + assert_eq!(freqs.get(&'ü'), Some(&2)); +} + +#[test] +#[ignore] +fn test_all_three_anthems_3_workers() { + let mut v = Vec::new(); + for anthem in [ODE_AN_DIE_FREUDE, WILHELMUS, STAR_SPANGLED_BANNER].iter() { + for line in anthem.iter() { + v.push(*line); + } + } + let freqs = frequency::frequency(&v[..], 3); + assert_eq!(freqs.get(&'a'), Some(&49)); + assert_eq!(freqs.get(&'t'), Some(&56)); + assert_eq!(freqs.get(&'ü'), Some(&2)); +} + +#[test] +#[ignore] +fn test_non_integer_multiple_of_threads() { + let v = vec!["abc"; 999]; + let mut hm = HashMap::new(); + hm.insert('a', 999); + hm.insert('b', 999); + hm.insert('c', 999); + assert_eq!(frequency::frequency(&v[..], 4), hm); +} diff --git a/proverb/.exercism/config.json b/proverb/.exercism/config.json new file mode 100644 index 0000000..0387881 --- /dev/null +++ b/proverb/.exercism/config.json @@ -0,0 +1,36 @@ +{ + "blurb": "For want of a horseshoe nail, a kingdom was lost, or so the saying goes. Output the full text of this proverbial rhyme.", + "authors": [ + "sacherjj" + ], + "contributors": [ + "attilahorvath", + "coriolinus", + "cwhakes", + "efx", + "ErikSchierboom", + "leoyvens", + "lutostag", + "navossoc", + "nfiles", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/proverb.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Wikipedia", + "source_url": "http://en.wikipedia.org/wiki/For_Want_of_a_Nail" +} diff --git a/proverb/.exercism/metadata.json b/proverb/.exercism/metadata.json new file mode 100644 index 0000000..4318f5f --- /dev/null +++ b/proverb/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"proverb","id":"045dc530c8d848b9a92ba8dc127f72c6","url":"https://exercism.org/tracks/rust/exercises/proverb","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/proverb/.gitignore b/proverb/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/proverb/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/proverb/Cargo.toml b/proverb/Cargo.toml new file mode 100644 index 0000000..eb39770 --- /dev/null +++ b/proverb/Cargo.toml @@ -0,0 +1,6 @@ +[package] +edition = "2021" +name = "proverb" +version = "1.1.0" + +[dependencies] diff --git a/proverb/HELP.md b/proverb/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/proverb/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/proverb/README.md b/proverb/README.md new file mode 100644 index 0000000..c09fcd3 --- /dev/null +++ b/proverb/README.md @@ -0,0 +1,49 @@ +# Proverb + +Welcome to Proverb on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +For want of a horseshoe nail, a kingdom was lost, or so the saying goes. + +Given a list of inputs, generate the relevant proverb. For example, given the list `["nail", "shoe", "horse", "rider", "message", "battle", "kingdom"]`, you will output the full text of this proverbial rhyme: + +```text +For want of a nail the shoe was lost. +For want of a shoe the horse was lost. +For want of a horse the rider was lost. +For want of a rider the message was lost. +For want of a message the battle was lost. +For want of a battle the kingdom was lost. +And all for the want of a nail. +``` + +Note that the list of inputs may vary; your solution should be able to handle lists of arbitrary length (including zero elements, generating empty output) and content. No line of the output text should be a static, unchanging string; all should vary according to the input given. + +## Source + +### Created by + +- @sacherjj + +### Contributed to by + +- @attilahorvath +- @coriolinus +- @cwhakes +- @efx +- @ErikSchierboom +- @leoyvens +- @lutostag +- @navossoc +- @nfiles +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Wikipedia - http://en.wikipedia.org/wiki/For_Want_of_a_Nail \ No newline at end of file diff --git a/proverb/src/lib.rs b/proverb/src/lib.rs new file mode 100644 index 0000000..0f8fbc0 --- /dev/null +++ b/proverb/src/lib.rs @@ -0,0 +1,11 @@ +use std::iter::once; + +pub fn build_proverb(list: &[&str]) -> String { + match list.first() { + None => String::new(), + Some(word) => list.windows(2) + .map(|w| format!("For want of a {} the {} was lost.\n", w[0], w[1])) + .chain(once(format!("And all for the want of a {}.", word))) + .collect() + } +} diff --git a/proverb/tests/proverb.rs b/proverb/tests/proverb.rs new file mode 100644 index 0000000..fbf8e8c --- /dev/null +++ b/proverb/tests/proverb.rs @@ -0,0 +1,75 @@ +use proverb::build_proverb; + +#[test] +fn test_two_pieces() { + let input = vec!["nail", "shoe"]; + let expected = vec![ + "For want of a nail the shoe was lost.", + "And all for the want of a nail.", + ] + .join("\n"); + assert_eq!(build_proverb(&input), expected); +} + +// Notice the change in the last line at three pieces. +#[test] +#[ignore] +fn test_three_pieces() { + let input = vec!["nail", "shoe", "horse"]; + let expected = vec![ + "For want of a nail the shoe was lost.", + "For want of a shoe the horse was lost.", + "And all for the want of a nail.", + ] + .join("\n"); + assert_eq!(build_proverb(&input), expected); +} + +#[test] +#[ignore] +fn test_one_piece() { + let input = vec!["nail"]; + let expected = String::from("And all for the want of a nail."); + assert_eq!(build_proverb(&input), expected); +} + +#[test] +#[ignore] +fn test_zero_pieces() { + let input: Vec<&str> = vec![]; + let expected = String::new(); + assert_eq!(build_proverb(&input), expected); +} + +#[test] +#[ignore] +fn test_full() { + let input = vec![ + "nail", "shoe", "horse", "rider", "message", "battle", "kingdom", + ]; + let expected = vec![ + "For want of a nail the shoe was lost.", + "For want of a shoe the horse was lost.", + "For want of a horse the rider was lost.", + "For want of a rider the message was lost.", + "For want of a message the battle was lost.", + "For want of a battle the kingdom was lost.", + "And all for the want of a nail.", + ] + .join("\n"); + assert_eq!(build_proverb(&input), expected); +} + +#[test] +#[ignore] +fn test_three_pieces_modernized() { + let input = vec!["pin", "gun", "soldier", "battle"]; + let expected = vec![ + "For want of a pin the gun was lost.", + "For want of a gun the soldier was lost.", + "For want of a soldier the battle was lost.", + "And all for the want of a pin.", + ] + .join("\n"); + assert_eq!(build_proverb(&input), expected); +} diff --git a/resistor-color/.exercism/config.json b/resistor-color/.exercism/config.json new file mode 100644 index 0000000..7d5443d --- /dev/null +++ b/resistor-color/.exercism/config.json @@ -0,0 +1,23 @@ +{ + "blurb": "Convert a resistor band's color to its numeric representation and back, using external crates", + "authors": [ + "still-flow", + "coriolinus" + ], + "contributors": [], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/resistor-color.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + }, + "source": "Maud de Vries, Erik Schierboom", + "source_url": "https://github.com/exercism/problem-specifications/issues/1458", + "test_runner": false +} diff --git a/resistor-color/.exercism/metadata.json b/resistor-color/.exercism/metadata.json new file mode 100644 index 0000000..b164b69 --- /dev/null +++ b/resistor-color/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"resistor-color","id":"7f2913b8ffb44f7b8997c2a2aacb699d","url":"https://exercism.org/tracks/rust/exercises/resistor-color","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/resistor-color/.gitignore b/resistor-color/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/resistor-color/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/resistor-color/Cargo.toml b/resistor-color/Cargo.toml new file mode 100644 index 0000000..d792e07 --- /dev/null +++ b/resistor-color/Cargo.toml @@ -0,0 +1,8 @@ +[package] +edition = "2021" +name = "resistor-color" +version = "1.0.0" + +[dependencies] +int-enum = "0.4.0" +enum-iterator = "1.1.1" diff --git a/resistor-color/HELP.md b/resistor-color/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/resistor-color/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/resistor-color/HINTS.md b/resistor-color/HINTS.md new file mode 100644 index 0000000..6fbfe6b --- /dev/null +++ b/resistor-color/HINTS.md @@ -0,0 +1,11 @@ +# Hints + +## General + +- Use the `enum-iterator` crate to be able to iterate over enums. Check out [docs](https://docs.rs/enum-iterator/1.1.1/enum_iterator/) to find out how. + +- Use the `int-enum` crate to be able to convert from int to enum. See the [docs](https://docs.rs/int-enum/0.4.0/int_enum/) for details. + +- The `Debug` trait is there because you'll likely need it. + +- You'll need to extend the list of `derive`d traits on your colors enum. \ No newline at end of file diff --git a/resistor-color/README.md b/resistor-color/README.md new file mode 100644 index 0000000..cdbc368 --- /dev/null +++ b/resistor-color/README.md @@ -0,0 +1,65 @@ +# Resistor Color + +Welcome to Resistor Color on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Most programs have dependencies on some libraries. Managing those by hand can be a pain. Luckily, the Rust ecosystem comes standard with `cargo`! `cargo` can manage dependencies for a project. + +You will often see external packages being referred to as "crates" in Rust. A crate is a compilation unit in Rust. A crate can be compiled into a binary or into a library. + +Most of the time, adding an external dependency is as simple as adding a line to your `Cargo.toml` file. + +In this exercise, [`enum-iterator`](https://docs.rs/enum-iterator/1.1.1/enum_iterator/) and [`int-enum`](https://docs.rs/int-enum/0.4.0/int_enum/) dependencies were added for you. + +## Instructions + +If you want to build something using a Raspberry Pi, you'll probably use _resistors_. +For this exercise, you need to know two things about them: + +- Each resistor has a resistance value. +- Resistors are small - so small in fact that if you printed the resistance value on them, it would be hard to read. + +To get around this problem, manufacturers print color-coded bands onto the resistors to denote their resistance values. +Each band has a position and a numeric value. + +The first 2 bands of a resistor have a simple encoding scheme: each color maps to a single number. + +In this exercise you are going to create a helpful program so that you don't have to remember the values of the bands. + +These colors are encoded as follows: + +- Black: 0 +- Brown: 1 +- Red: 2 +- Orange: 3 +- Yellow: 4 +- Green: 5 +- Blue: 6 +- Violet: 7 +- Grey: 8 +- White: 9 + +The goal of this exercise is to create a way: +- to look up the numerical value associated with a particular color band +- to convert the numerical value into a string representing color +- to list the different band colors + +For tasks number two and three, you will need external crates [`enum-iterator`](https://docs.rs/enum-iterator/1.1.1/enum_iterator/) and [`int-enum`](https://docs.rs/int-enum/0.4.0/int_enum/), which are included in this exercise's `Cargo.toml`. Be sure to check the crates' documentation to learn how to use them. + +Mnemonics map the colors to the numbers, that, when stored as an array, happen to map to their index in the array: Better Be Right Or Your Great Big Values Go Wrong. + +More information on the color encoding of resistors can be found in the [Electronic color code Wikipedia article](https://en.wikipedia.org/wiki/Electronic_color_code) + +## Source + +### Created by + +- @still-flow +- @coriolinus + +### Based on + +Maud de Vries, Erik Schierboom - https://github.com/exercism/problem-specifications/issues/1458 \ No newline at end of file diff --git a/resistor-color/src/lib.rs b/resistor-color/src/lib.rs new file mode 100644 index 0000000..c8a4f30 --- /dev/null +++ b/resistor-color/src/lib.rs @@ -0,0 +1,68 @@ +#[derive(Debug, PartialEq, Eq)] +pub enum ResistorColor { + Black, + Blue, + Brown, + Green, + Grey, + Orange, + Red, + Violet, + White, + Yellow, +} + +fn value_to_color(value: u32) -> ResistorColor { + match value { + 0 => ResistorColor::Black, + 1 => ResistorColor::Brown, + 2 => ResistorColor::Red, + 3 => ResistorColor::Orange, + 4 => ResistorColor::Yellow, + 5 => ResistorColor::Green, + 6 => ResistorColor::Blue, + 7 => ResistorColor::Violet, + 8 => ResistorColor::Grey, + 9 => ResistorColor::White, + _ => ResistorColor::Black + } +} + +pub fn color_to_value(_color: ResistorColor) -> u32 { + match _color { + ResistorColor::Black => 0, + ResistorColor::Brown => 1, + ResistorColor::Red => 2, + ResistorColor::Orange => 3, + ResistorColor::Yellow => 4, + ResistorColor::Green => 5, + ResistorColor::Blue => 6, + ResistorColor::Violet => 7, + ResistorColor::Grey => 8, + ResistorColor::White => 9, + } +} + +pub fn value_to_color_string(value: u32) -> String { + match value { + 0 => String::from("Black"), + 1 => String::from("Brown"), + 2 => String::from("Red"), + 3 => String::from("Orange"), + 4 => String::from("Yellow"), + 5 => String::from("Green"), + 6 => String::from("Blue"), + 7 => String::from("Violet"), + 8 => String::from("Grey"), + 9 => String::from("White"), + _ => String::from("value out of range") + } +} + +pub fn colors() -> Vec { + let mut colors = vec![]; + for i in 0..=9 { + colors.push(value_to_color(i)); + } + colors +} diff --git a/resistor-color/tests/resistor-color.rs b/resistor-color/tests/resistor-color.rs new file mode 100644 index 0000000..1e6523b --- /dev/null +++ b/resistor-color/tests/resistor-color.rs @@ -0,0 +1,55 @@ +use resistor_color::{color_to_value, colors, value_to_color_string, ResistorColor}; + +#[test] +fn test_black() { + assert_eq!(color_to_value(ResistorColor::Black), 0); +} + +#[test] +#[ignore] +fn test_orange() { + assert_eq!(color_to_value(ResistorColor::Orange), 3); +} + +#[test] +#[ignore] +fn test_white() { + assert_eq!(color_to_value(ResistorColor::White), 9); +} + +#[test] +#[ignore] +fn test_2() { + assert_eq!(value_to_color_string(2), String::from("Red")); +} + +#[test] +#[ignore] +fn test_6() { + assert_eq!(value_to_color_string(6), String::from("Blue")); +} + +#[test] +#[ignore] +fn test_8() { + assert_eq!(value_to_color_string(8), String::from("Grey")); +} + +#[test] +#[ignore] +fn test_11_out_of_range() { + assert_eq!( + value_to_color_string(11), + String::from("value out of range") + ); +} + +#[test] +#[ignore] +fn test_all_colors() { + use ResistorColor::*; + assert_eq!( + colors(), + vec![Black, Brown, Red, Orange, Yellow, Green, Blue, Violet, Grey, White] + ); +} diff --git a/reverse-string/.exercism/config.json b/reverse-string/.exercism/config.json new file mode 100644 index 0000000..463d410 --- /dev/null +++ b/reverse-string/.exercism/config.json @@ -0,0 +1,38 @@ +{ + "blurb": "Reverse a string", + "authors": [ + "coriolinus" + ], + "contributors": [ + "cbzehner", + "ccouzens", + "cwhakes", + "efx", + "ErikSchierboom", + "hunger", + "lutostag", + "ocstl", + "PaulT89", + "petertseng", + "rofrol", + "rrredface", + "stringparser", + "TheDarkula", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/reverse-string.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Introductory challenge to reverse an input string", + "source_url": "https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb" +} diff --git a/reverse-string/.exercism/metadata.json b/reverse-string/.exercism/metadata.json new file mode 100644 index 0000000..2993a10 --- /dev/null +++ b/reverse-string/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"reverse-string","id":"c03f86d7d6bf42ee989170bc1067d1c7","url":"https://exercism.org/tracks/rust/exercises/reverse-string","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/reverse-string/.gitignore b/reverse-string/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/reverse-string/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/reverse-string/Cargo.toml b/reverse-string/Cargo.toml new file mode 100644 index 0000000..52b902c --- /dev/null +++ b/reverse-string/Cargo.toml @@ -0,0 +1,9 @@ +[dependencies] + +[features] +grapheme = [] + +[package] +edition = "2021" +name = "reverse_string" +version = "1.2.0" diff --git a/reverse-string/HELP.md b/reverse-string/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/reverse-string/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/reverse-string/README.md b/reverse-string/README.md new file mode 100644 index 0000000..7d2852f --- /dev/null +++ b/reverse-string/README.md @@ -0,0 +1,55 @@ +# Reverse String + +Welcome to Reverse String on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Reverse a string + +For example: +input: "cool" +output: "looc" + +Test your function on this string: `uüu` and see what happens. Try to write a function that properly +reverses this string. Hint: grapheme clusters + +To get the bonus test to run, remove the ignore flag (`#[ignore]`) from the +last test, and execute the tests with: + +```bash +$ cargo test --features grapheme +``` + +You will need to use external libraries (a `crate` in rust lingo) for the bonus task. A good place to look for those is [crates.io](https://crates.io/), the official repository of crates. + +[Check the documentation](https://doc.rust-lang.org/cargo/guide/dependencies.html) for instructions on how to use external crates in your projects. + +## Source + +### Created by + +- @coriolinus + +### Contributed to by + +- @cbzehner +- @ccouzens +- @cwhakes +- @efx +- @ErikSchierboom +- @hunger +- @lutostag +- @ocstl +- @PaulT89 +- @petertseng +- @rofrol +- @rrredface +- @stringparser +- @TheDarkula +- @xakon +- @ZapAnton + +### Based on + +Introductory challenge to reverse an input string - https://medium.freecodecamp.org/how-to-reverse-a-string-in-javascript-in-3-different-ways-75e4763c68cb \ No newline at end of file diff --git a/reverse-string/src/lib.rs b/reverse-string/src/lib.rs new file mode 100644 index 0000000..b55d381 --- /dev/null +++ b/reverse-string/src/lib.rs @@ -0,0 +1,3 @@ +pub fn reverse(input: &str) -> String { + input.chars().rev().collect::() +} diff --git a/reverse-string/tests/reverse-string.rs b/reverse-string/tests/reverse-string.rs new file mode 100644 index 0000000..b6f5b85 --- /dev/null +++ b/reverse-string/tests/reverse-string.rs @@ -0,0 +1,69 @@ +//! Tests for reverse-string +//! +//! Generated by [script][script] using [canonical data][canonical-data] +//! +//! [script]: https://github.com/exercism/rust/blob/b829ce2/bin/init_exercise.py +//! [canonical-data]: https://raw.githubusercontent.com/exercism/problem-specifications/main/exercises/reverse-string/canonical_data.json + +use reverse_string::*; + +/// Process a single test case for the property `reverse` +fn process_reverse_case(input: &str, expected: &str) { + assert_eq!(&reverse(input), expected) +} + +#[test] +/// empty string +fn test_an_empty_string() { + process_reverse_case("", ""); +} + +#[test] +#[ignore] +/// a word +fn test_a_word() { + process_reverse_case("robot", "tobor"); +} + +#[test] +#[ignore] +/// a capitalized word +fn test_a_capitalized_word() { + process_reverse_case("Ramen", "nemaR"); +} + +#[test] +#[ignore] +/// a sentence with punctuation +fn test_a_sentence_with_punctuation() { + process_reverse_case("I'm hungry!", "!yrgnuh m'I"); +} + +#[test] +#[ignore] +/// a palindrome +fn test_a_palindrome() { + process_reverse_case("racecar", "racecar"); +} + +#[test] +#[ignore] +/// an even-sized word +fn test_an_even_sized_word() { + process_reverse_case("drawer", "reward"); +} + +#[test] +#[ignore] +/// wide characters +fn test_wide_characters() { + process_reverse_case("子猫", "猫子"); +} + +#[test] +#[ignore] +#[cfg(feature = "grapheme")] +/// grapheme clusters +fn test_grapheme_clusters() { + process_reverse_case("uüu", "uüu"); +} diff --git a/robot-simulator/.exercism/config.json b/robot-simulator/.exercism/config.json new file mode 100644 index 0000000..cef8f92 --- /dev/null +++ b/robot-simulator/.exercism/config.json @@ -0,0 +1,34 @@ +{ + "blurb": "Write a robot simulator.", + "authors": [ + "IanWhitney" + ], + "contributors": [ + "ashleygwilliams", + "coriolinus", + "cwhakes", + "efx", + "ErikSchierboom", + "IanWhitney", + "lutostag", + "nfiles", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/robot-simulator.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Inspired by an interview question at a famous company." +} diff --git a/robot-simulator/.exercism/metadata.json b/robot-simulator/.exercism/metadata.json new file mode 100644 index 0000000..5d8ecfe --- /dev/null +++ b/robot-simulator/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"robot-simulator","id":"5906f62c2a124ee1b77c8a2ce963571e","url":"https://exercism.org/tracks/rust/exercises/robot-simulator","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/robot-simulator/.gitignore b/robot-simulator/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/robot-simulator/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/robot-simulator/Cargo.toml b/robot-simulator/Cargo.toml new file mode 100644 index 0000000..c82b015 --- /dev/null +++ b/robot-simulator/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "robot-simulator" +version = "2.2.0" diff --git a/robot-simulator/HELP.md b/robot-simulator/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/robot-simulator/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/robot-simulator/README.md b/robot-simulator/README.md new file mode 100644 index 0000000..4dcf1f9 --- /dev/null +++ b/robot-simulator/README.md @@ -0,0 +1,59 @@ +# Robot Simulator + +Welcome to Robot Simulator on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Write a robot simulator. + +A robot factory's test facility needs a program to verify robot movements. + +The robots have three possible movements: + +- turn right +- turn left +- advance + +Robots are placed on a hypothetical infinite grid, facing a particular +direction (north, east, south, or west) at a set of {x,y} coordinates, +e.g., {3,8}, with coordinates increasing to the north and east. + +The robot then receives a number of instructions, at which point the +testing facility verifies the robot's new position, and in which +direction it is pointing. + +- The letter-string "RAALAL" means: + - Turn right + - Advance twice + - Turn left + - Advance once + - Turn left yet again +- Say a robot starts at {7, 3} facing north. Then running this stream + of instructions should leave it at {9, 4} facing west. + +## Source + +### Created by + +- @IanWhitney + +### Contributed to by + +- @ashleygwilliams +- @coriolinus +- @cwhakes +- @efx +- @ErikSchierboom +- @IanWhitney +- @lutostag +- @nfiles +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Inspired by an interview question at a famous company. \ No newline at end of file diff --git a/robot-simulator/src/lib.rs b/robot-simulator/src/lib.rs new file mode 100644 index 0000000..732b5ce --- /dev/null +++ b/robot-simulator/src/lib.rs @@ -0,0 +1,77 @@ +// The code below is a stub. Just enough to satisfy the compiler. +// In order to pass the tests you can add-to or change any of this code. + +#[derive(PartialEq, Eq, Debug)] +pub enum Direction { + North, + East, + South, + West, +} + +pub struct Robot { + x: i32, + y: i32, + direction: Direction +} + +impl Robot { + pub fn new(x: i32, y: i32, direction: Direction) -> Self { + Self { + x, + y, + direction + } + } + + #[must_use] + pub fn turn_right(self) -> Self { + match self.direction { + Direction::North => Self { direction: Direction::East, ..self }, + Direction::East => Self { direction: Direction::South, ..self }, + Direction::South => Self { direction: Direction::West, ..self }, + Direction::West => Self { direction: Direction::North, ..self } + } + } + + #[must_use] + pub fn turn_left(self) -> Self { + match self.direction { + Direction::North => Self { direction: Direction::West, ..self }, + Direction::West => Self { direction: Direction::South, ..self }, + Direction::South => Self { direction: Direction::East, ..self }, + Direction::East => Self { direction: Direction::North, ..self }, + } + } + + #[must_use] + pub fn advance(self) -> Self { + match self.direction { + Direction::North => Self { y: self.y + 1, ..self }, + Direction::West => Self { x: self.x - 1, ..self }, + Direction::South => Self { y: self.y - 1, ..self }, + Direction::East => Self { x: self.x + 1, ..self }, + } + } + + #[must_use] + pub fn instructions(self, instructions: &str) -> Self { + instructions + .chars() + .fold(self, |robot, ch| + match ch { + 'L' => robot.turn_left(), + 'R' => robot.turn_right(), + 'A' => robot.advance(), + _ => robot + }) + } + + pub fn position(&self) -> (i32, i32) { + (self.x, self.y) + } + + pub fn direction(&self) -> &Direction { + &self.direction + } +} diff --git a/robot-simulator/tests/robot-simulator.rs b/robot-simulator/tests/robot-simulator.rs new file mode 100644 index 0000000..1c33c2f --- /dev/null +++ b/robot-simulator/tests/robot-simulator.rs @@ -0,0 +1,145 @@ +use robot_simulator::*; + +#[test] +fn robots_are_created_with_position_and_direction() { + let robot = Robot::new(0, 0, Direction::North); + assert_eq!((0, 0), robot.position()); + assert_eq!(&Direction::North, robot.direction()); +} + +#[test] +#[ignore] +fn positions_can_be_negative() { + let robot = Robot::new(-1, -1, Direction::South); + assert_eq!((-1, -1), robot.position()); + assert_eq!(&Direction::South, robot.direction()); +} + +#[test] +#[ignore] +fn turning_right_does_not_change_position() { + let robot = Robot::new(0, 0, Direction::North).turn_right(); + assert_eq!((0, 0), robot.position()); +} + +#[test] +#[ignore] +fn turning_right_from_north_points_the_robot_east() { + let robot = Robot::new(0, 0, Direction::North).turn_right(); + assert_eq!(&Direction::East, robot.direction()); +} + +#[test] +#[ignore] +fn turning_right_from_east_points_the_robot_south() { + let robot = Robot::new(0, 0, Direction::East).turn_right(); + assert_eq!(&Direction::South, robot.direction()); +} + +#[test] +#[ignore] +fn turning_right_from_south_points_the_robot_west() { + let robot = Robot::new(0, 0, Direction::South).turn_right(); + assert_eq!(&Direction::West, robot.direction()); +} + +#[test] +#[ignore] +fn turning_right_from_west_points_the_robot_north() { + let robot = Robot::new(0, 0, Direction::West).turn_right(); + assert_eq!(&Direction::North, robot.direction()); +} + +#[test] +#[ignore] +fn turning_left_does_not_change_position() { + let robot = Robot::new(0, 0, Direction::North).turn_left(); + assert_eq!((0, 0), robot.position()); +} + +#[test] +#[ignore] +fn turning_left_from_north_points_the_robot_west() { + let robot = Robot::new(0, 0, Direction::North).turn_left(); + assert_eq!(&Direction::West, robot.direction()); +} + +#[test] +#[ignore] +fn turning_left_from_west_points_the_robot_south() { + let robot = Robot::new(0, 0, Direction::West).turn_left(); + assert_eq!(&Direction::South, robot.direction()); +} + +#[test] +#[ignore] +fn turning_left_from_south_points_the_robot_east() { + let robot = Robot::new(0, 0, Direction::South).turn_left(); + assert_eq!(&Direction::East, robot.direction()); +} + +#[test] +#[ignore] +fn turning_left_from_east_points_the_robot_north() { + let robot = Robot::new(0, 0, Direction::East).turn_left(); + assert_eq!(&Direction::North, robot.direction()); +} + +#[test] +#[ignore] +fn advance_does_not_change_the_direction() { + let robot = Robot::new(0, 0, Direction::North).advance(); + assert_eq!(&Direction::North, robot.direction()); +} + +#[test] +#[ignore] +fn advance_increases_the_y_coordinate_by_one_when_facing_north() { + let robot = Robot::new(0, 0, Direction::North).advance(); + assert_eq!((0, 1), robot.position()); +} + +#[test] +#[ignore] +fn advance_decreases_the_y_coordinate_by_one_when_facing_south() { + let robot = Robot::new(0, 0, Direction::South).advance(); + assert_eq!((0, -1), robot.position()); +} + +#[test] +#[ignore] +fn advance_increases_the_x_coordinate_by_one_when_facing_east() { + let robot = Robot::new(0, 0, Direction::East).advance(); + assert_eq!((1, 0), robot.position()); +} + +#[test] +#[ignore] +fn advance_decreases_the_x_coordinate_by_one_when_facing_west() { + let robot = Robot::new(0, 0, Direction::West).advance(); + assert_eq!((-1, 0), robot.position()); +} + +#[test] +#[ignore] +fn follow_instructions_to_move_west_and_north() { + let robot = Robot::new(0, 0, Direction::North).instructions("LAAARALA"); + assert_eq!((-4, 1), robot.position()); + assert_eq!(&Direction::West, robot.direction()); +} + +#[test] +#[ignore] +fn follow_instructions_to_move_west_and_south() { + let robot = Robot::new(2, -7, Direction::East).instructions("RRAAAAALA"); + assert_eq!((-3, -8), robot.position()); + assert_eq!(&Direction::South, robot.direction()); +} + +#[test] +#[ignore] +fn follow_instructions_to_move_east_and_north() { + let robot = Robot::new(8, 4, Direction::South).instructions("LAAARRRALLLL"); + assert_eq!((11, 5), robot.position()); + assert_eq!(&Direction::North, robot.direction()); +} diff --git a/role-playing-game/.exercism/config.json b/role-playing-game/.exercism/config.json new file mode 100644 index 0000000..d711e12 --- /dev/null +++ b/role-playing-game/.exercism/config.json @@ -0,0 +1,22 @@ +{ + "blurb": "Learn about the `Option` enum by creating a minimal role-playing game", + "authors": [ + "seanchen1991", + "coriolinus" + ], + "contributors": [ + "PaulT89" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/role-playing-game.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + } +} diff --git a/role-playing-game/.exercism/metadata.json b/role-playing-game/.exercism/metadata.json new file mode 100644 index 0000000..c448745 --- /dev/null +++ b/role-playing-game/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"role-playing-game","id":"366a0289c4164436aec4e054eee6af25","url":"https://exercism.org/tracks/rust/exercises/role-playing-game","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/role-playing-game/Cargo.lock b/role-playing-game/Cargo.lock new file mode 100644 index 0000000..76f994c --- /dev/null +++ b/role-playing-game/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "role_playing_game" +version = "0.1.0" diff --git a/role-playing-game/Cargo.toml b/role-playing-game/Cargo.toml new file mode 100644 index 0000000..ab9f24f --- /dev/null +++ b/role-playing-game/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "role_playing_game" +version = "0.1.0" +edition = "2021" diff --git a/role-playing-game/HELP.md b/role-playing-game/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/role-playing-game/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/role-playing-game/HINTS.md b/role-playing-game/HINTS.md new file mode 100644 index 0000000..de2efd2 --- /dev/null +++ b/role-playing-game/HINTS.md @@ -0,0 +1 @@ +# Hints \ No newline at end of file diff --git a/role-playing-game/README.md b/role-playing-game/README.md new file mode 100644 index 0000000..c3d17d0 --- /dev/null +++ b/role-playing-game/README.md @@ -0,0 +1,163 @@ +# Role-Playing Game + +Welcome to Role-Playing Game on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +## Null-References + +If you have ever used another programming language (C/C++, Python, Java, Ruby, Lisp, etc.), it is likely that you have encountered `null` or `nil` before. +The use of `null` or `nil` is the way that these languages indicate that a particular variable has no value. +However, this makes accidentally using a variable that points to `null` an easy (and frequent) mistake to make. +As you might imagine, trying to call a function that isn't there, or access a value that doesn't exist can lead to all sorts of bugs and crashes. +The creator of `null` went so far as to call it his ['billion-dollar mistake'.](https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/) + +## The `Option` Type + +To avoid these problems, Rust does not use null-references. +However, it still needs a safe way to indicate that a particular variable has no value. +This is where `Option` comes in. +Instead of having a variable which lacks a value, Rust variables can use the `Option` enum. +This enum has two variants: `None`, Rust's null-equivalent; and `Some(T)`, where T is a value of any type. + +It looks like this: + +```rust +enum Option { + None, + Some(T), +} +``` + +You can think of `Option` as a layer of safety between you and the problems that null-references can cause, while still retaining their conceptual usefulness. + +## Using `Option` + +Setting a variable to `None` is fairly straightforward: + +```rust +let nothing: Option = None; // Variable nothing is set to None +``` + +However, if you wish for the `Option` type to carry a value, you cannot assign this value directly. +An `Option` type variable and, say, an `i32` type variable are not equivalent. +You will need to use `Some`: + +```rust +let wrong_way: Option = -4; // This will not work + +let right_way: Option = Some(-4); // This will work +let another_right_way = Some(-4); // Compiler infers that this is Option +``` + +It's also for this reason that the following will not work: + +```rust +let number = 47; +let option_number = Some(15); + +let compile_error = number + option_number; // Cannot add an i32 and an Option - they are of different types +``` + +If you wish to get the value that is contained by Some, you will first need to check that it exists: + +```rust +let mut some_words = Some("choose something to say"); // some_words set to something + +match some_words { + Some(str) => println!("Here, we will {}", str), + None => println!("I've got nothing to say"), +} // Prints "Here, we will choose something to say" + +some_words = None; // some_words now set to None + +// exactly the same match block as above +match some_words { + Some(str) => println!("Here, we will {}", str), + None => println!("I've got nothing to say"), +} // Prints "I've got nothing to say" +``` + +Besides `match`, Rust has other tools available for checking and accessing values contained within `Option`, but `match` should be familiar to you by now. + +Additionally, consider this a demonstration of why Rust uses `Option` instead of a null-reference. +The point is that **you _must_ check** whether or not the `Option` variable is `Some` (in which case you can go ahead and extract and use the value contained within), or `None`. +Anything else, and your program will not compile; the compiler is keeping you safe from `null`. + +## Instructions + +You're working on implementing a role-playing game. The player's character is represented by the following: + +```rust +pub struct Player { + health: u32, + mana: Option, + level: u32, +} +``` + +Players in this game must reach level 10 before they unlock a mana pool so that they can start casting spells. Before that point, the Player's mana is `None`. + +You're working on two pieces of functionality in this game, the revive mechanic and the spell casting mechanic. + +The `revive` method should check to ensure that the Player is indeed dead (their health has reached 0), and if they are, the method should return a new Player instance with 100 health. +If the Player's level is 10 or above, they should also be revived with 100 mana. +If the Player's level is below 10, their mana should be `None`. The `revive` method should preserve the Player's level. + +```rust +let dead_player = Player { health: 0, mana: None, level: 2 }; +dead_player.revive() +// Returns Player { health: 100, mana: None, level: 2 } +``` + +If the `revive` method is called on a Player whose health is 1 or above, then the method should return `None`. + +```rust +let alive_player = Player { health: 1, mana: Some(15), level: 11 }; +alive_player.revive() +// Returns None +``` + +The `cast_spell` method takes a mutable reference to the Player as well as a `mana_cost` parameter indicating how much mana the spell costs. It returns the amount of damage that the cast spell performs, which will always be two times the mana cost of the spell if the spell is successfully cast. + +- If the player does not have access to a mana pool, attempting to cast the spell must decrease their health by the mana cost of the spell. The damage returned must be 0. + + ```rust + let not_a_wizard_yet = Player { health: 79, mana: None, level: 9 }; + assert_eq!(not_a_wizard_yet.cast_spell(5), 0) + assert_eq!(not_a_wizard_yet.health, 74); + assert_eq!(not_a_wizard_yet.mana, None); + ``` + +- If the player has a mana pool but insufficient mana, the method should not affect the pool, but instead return 0 + + ```rust + let low_mana_wizard = Player { health: 93, mana: Some(3), level: 12 }; + assert_eq!(low_mana_wizard.cast_spell(10), 0); + assert_eq!(low_mana_wizard.health, 93); + assert_eq!(low_mana_wizard.mana, Some(3)); + ``` + +- Otherwise, the `mana_cost` should be deducted from the Player's mana pool and the appropriate amount of damage should be returned. + + ```rust + let wizard = Player { health: 123, mana: Some(30), level: 18 }; + assert_eq!(wizard.cast_spell(10), 20); + assert_eq!(wizard.health, 123); + assert_eq!(wizard.mana, Some(20)); + ``` + +Have fun! + +## Source + +### Created by + +- @seanchen1991 +- @coriolinus + +### Contributed to by + +- @PaulT89 \ No newline at end of file diff --git a/role-playing-game/src/lib.rs b/role-playing-game/src/lib.rs new file mode 100644 index 0000000..59662d0 --- /dev/null +++ b/role-playing-game/src/lib.rs @@ -0,0 +1,49 @@ +// This stub file contains items that aren't used yet; feel free to remove this module attribute +// to enable stricter warnings. +#![allow(unused)] + +pub struct Player { + pub health: u32, + pub mana: Option, + pub level: u32, +} + +impl Player { + pub fn revive(&self) -> Option { + if self.health > 0 { + None + } else { + if self.level >= 10 { + Some(Player { + health: 100, + mana: Some(100), + level: self.level, + }) + } else { + Some(Player { + health: 100, + mana: None, + level: self.level, + }) + } + } + } + + pub fn cast_spell(&mut self, mana_cost: u32) -> u32 { + if self.level >= 10 { + if self.mana < Some(mana_cost) { + 0 + } else { + self.mana = Some(self.mana.unwrap() - mana_cost); + mana_cost * 2 + } + } else { + if self.health > mana_cost { + self.health -= mana_cost; + } else { + self.health = 0; + } + 0 + } + } +} diff --git a/role-playing-game/target/.rustc_info.json b/role-playing-game/target/.rustc_info.json new file mode 100644 index 0000000..dfdb849 --- /dev/null +++ b/role-playing-game/target/.rustc_info.json @@ -0,0 +1 @@ +{"rustc_fingerprint":547482148007961314,"outputs":{"2797684049618456168":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n","stderr":""},"931469667778813386":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.dylib\nlib___.dylib\nlib___.a\nlib___.dylib\n/Users/arthurdanjou/.rustup/toolchains/stable-aarch64-apple-darwin\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_arch=\"aarch64\"\ntarget_endian=\"little\"\ntarget_env=\"\"\ntarget_family=\"unix\"\ntarget_feature=\"aes\"\ntarget_feature=\"crc\"\ntarget_feature=\"dit\"\ntarget_feature=\"dotprod\"\ntarget_feature=\"dpb\"\ntarget_feature=\"dpb2\"\ntarget_feature=\"fcma\"\ntarget_feature=\"fhm\"\ntarget_feature=\"flagm\"\ntarget_feature=\"fp16\"\ntarget_feature=\"frintts\"\ntarget_feature=\"jsconv\"\ntarget_feature=\"lor\"\ntarget_feature=\"lse\"\ntarget_feature=\"neon\"\ntarget_feature=\"paca\"\ntarget_feature=\"pacg\"\ntarget_feature=\"pan\"\ntarget_feature=\"pmuv3\"\ntarget_feature=\"ras\"\ntarget_feature=\"rcpc\"\ntarget_feature=\"rcpc2\"\ntarget_feature=\"rdm\"\ntarget_feature=\"sb\"\ntarget_feature=\"sha2\"\ntarget_feature=\"sha3\"\ntarget_feature=\"ssbs\"\ntarget_feature=\"vh\"\ntarget_has_atomic=\"128\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"macos\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"apple\"\nunix\n","stderr":""},"17598535894874457435":{"success":true,"status":"","code":0,"stdout":"rustc 1.61.0 (fe5b13d68 2022-05-18)\nbinary: rustc\ncommit-hash: fe5b13d681f25ee6474be29d748c65adcd91f69e\ncommit-date: 2022-05-18\nhost: aarch64-apple-darwin\nrelease: 1.61.0\nLLVM version: 14.0.0\n","stderr":""}},"successes":{}} \ No newline at end of file diff --git a/role-playing-game/target/CACHEDIR.TAG b/role-playing-game/target/CACHEDIR.TAG new file mode 100644 index 0000000..20d7c31 --- /dev/null +++ b/role-playing-game/target/CACHEDIR.TAG @@ -0,0 +1,3 @@ +Signature: 8a477f597d28d172789f06886806bc55 +# This file is a cache directory tag created by cargo. +# For information about cache directory tags see https://bford.info/cachedir/ diff --git a/role-playing-game/target/debug/.cargo-lock b/role-playing-game/target/debug/.cargo-lock new file mode 100644 index 0000000..e69de29 diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/dep-test-integration-test-role-playing-game b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/dep-test-integration-test-role-playing-game new file mode 100644 index 0000000..97cffbf Binary files /dev/null and b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/dep-test-integration-test-role-playing-game differ diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/invoked.timestamp b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game new file mode 100644 index 0000000..6ca2f20 --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game @@ -0,0 +1 @@ +7473300256011276 \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game.json b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game.json new file mode 100644 index 0000000..a4b65ee --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-1660573da999ec42/test-integration-test-role-playing-game.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":14117091745346596221,"profile":4734105543796642768,"path":5566495501568878768,"deps":[[12933633828201121903,"role_playing_game",false,11591825979736083808]],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/role_playing_game-1660573da999ec42/dep-test-integration-test-role-playing-game"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/dep-test-lib-role_playing_game b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/dep-test-lib-role_playing_game new file mode 100644 index 0000000..fb1fbec Binary files /dev/null and b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/dep-test-lib-role_playing_game differ diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/invoked.timestamp b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game new file mode 100644 index 0000000..8ee5b6f --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game @@ -0,0 +1 @@ +ab1178d9de276473 \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game.json b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game.json new file mode 100644 index 0000000..3c6a8d3 --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-701c6c9e456a6926/test-lib-role_playing_game.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":13769912428744468190,"profile":4734105543796642768,"path":17523903030608720598,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/role_playing_game-701c6c9e456a6926/dep-test-lib-role_playing_game"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/dep-lib-role_playing_game b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/dep-lib-role_playing_game new file mode 100644 index 0000000..fb1fbec Binary files /dev/null and b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/dep-lib-role_playing_game differ diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/invoked.timestamp b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/invoked.timestamp new file mode 100644 index 0000000..e00328d --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/invoked.timestamp @@ -0,0 +1 @@ +This file has an mtime of when this was started. \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game new file mode 100644 index 0000000..4f539d4 --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game @@ -0,0 +1 @@ +604d50fc4f70dea0 \ No newline at end of file diff --git a/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game.json b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game.json new file mode 100644 index 0000000..bf4eb1c --- /dev/null +++ b/role-playing-game/target/debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/lib-role_playing_game.json @@ -0,0 +1 @@ +{"rustc":5055087155190864114,"features":"[]","target":13769912428744468190,"profile":11736316127369858332,"path":17523903030608720598,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/role_playing_game-daccff4ebcf3cde0/dep-lib-role_playing_game"}}],"rustflags":[],"metadata":7797948686568424061,"config":2202906307356721367,"compile_kind":0} \ No newline at end of file diff --git a/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rlib b/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rlib new file mode 100644 index 0000000..baf1ba8 Binary files /dev/null and b/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rlib differ diff --git a/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rmeta b/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rmeta new file mode 100644 index 0000000..e16a1d6 Binary files /dev/null and b/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rmeta differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42 b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42 new file mode 100755 index 0000000..2f8d014 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42 differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1533tp1kbvw5bq0t.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1533tp1kbvw5bq0t.rcgu.o new file mode 100644 index 0000000..40bd8b3 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1533tp1kbvw5bq0t.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1cn7xkn5q0p3p9by.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1cn7xkn5q0p3p9by.rcgu.o new file mode 100644 index 0000000..34ed9f3 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1cn7xkn5q0p3p9by.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1how2768iwnwgw9l.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1how2768iwnwgw9l.rcgu.o new file mode 100644 index 0000000..fb21a88 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.1how2768iwnwgw9l.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2093ehvk7u8fqtbw.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2093ehvk7u8fqtbw.rcgu.o new file mode 100644 index 0000000..ab3e731 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2093ehvk7u8fqtbw.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.287pzhzk6x3t4i5m.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.287pzhzk6x3t4i5m.rcgu.o new file mode 100644 index 0000000..1c6d033 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.287pzhzk6x3t4i5m.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2iemr5jzalattxuw.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2iemr5jzalattxuw.rcgu.o new file mode 100644 index 0000000..d69663a Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.2iemr5jzalattxuw.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.335shigblqvvufnq.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.335shigblqvvufnq.rcgu.o new file mode 100644 index 0000000..aac579e Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.335shigblqvvufnq.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.33zj0aevdu9d4z6v.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.33zj0aevdu9d4z6v.rcgu.o new file mode 100644 index 0000000..f20d540 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.33zj0aevdu9d4z6v.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3cwmmueuvv580it4.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3cwmmueuvv580it4.rcgu.o new file mode 100644 index 0000000..f505bca Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3cwmmueuvv580it4.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3r2ctwa1dmos3or8.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3r2ctwa1dmos3or8.rcgu.o new file mode 100644 index 0000000..f6799b8 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.3r2ctwa1dmos3or8.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4f4j5sguzhvzidet.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4f4j5sguzhvzidet.rcgu.o new file mode 100644 index 0000000..d9870e4 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4f4j5sguzhvzidet.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4t4yk8xdkkwelm12.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4t4yk8xdkkwelm12.rcgu.o new file mode 100644 index 0000000..350fb9e Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4t4yk8xdkkwelm12.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4xjao9ugmyl2cfv4.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4xjao9ugmyl2cfv4.rcgu.o new file mode 100644 index 0000000..e51f4b0 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.4xjao9ugmyl2cfv4.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.57n6tlbr4er5qzih.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.57n6tlbr4er5qzih.rcgu.o new file mode 100644 index 0000000..7c7f1d7 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.57n6tlbr4er5qzih.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.59rplhfzvhhpcp7e.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.59rplhfzvhhpcp7e.rcgu.o new file mode 100644 index 0000000..8aa2b69 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.59rplhfzvhhpcp7e.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.d b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.d new file mode 100644 index 0000000..8b27e4f --- /dev/null +++ b/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.d @@ -0,0 +1,5 @@ +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42: tests/role-playing-game.rs + +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-1660573da999ec42.d: tests/role-playing-game.rs + +tests/role-playing-game.rs: diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926 b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926 new file mode 100755 index 0000000..4474a3f Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926 differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.185uo2bzec4a5hyg.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.185uo2bzec4a5hyg.rcgu.o new file mode 100644 index 0000000..21b970f Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.185uo2bzec4a5hyg.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1a8gyf1ywtshfdp5.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1a8gyf1ywtshfdp5.rcgu.o new file mode 100644 index 0000000..f5c9409 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1a8gyf1ywtshfdp5.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1ak679xcfowyuvkq.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1ak679xcfowyuvkq.rcgu.o new file mode 100644 index 0000000..0a07d6c Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.1ak679xcfowyuvkq.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.2ixzut5gl4mk1p6w.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.2ixzut5gl4mk1p6w.rcgu.o new file mode 100644 index 0000000..1742fef Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.2ixzut5gl4mk1p6w.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3r8hgdfnrpe7mr9o.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3r8hgdfnrpe7mr9o.rcgu.o new file mode 100644 index 0000000..9812a46 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3r8hgdfnrpe7mr9o.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3sbcof928f7zzg82.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3sbcof928f7zzg82.rcgu.o new file mode 100644 index 0000000..0c1eeb4 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.3sbcof928f7zzg82.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.d b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.d new file mode 100644 index 0000000..499bfe4 --- /dev/null +++ b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.d @@ -0,0 +1,5 @@ +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.d: src/lib.rs + +src/lib.rs: diff --git a/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.zpp9e1bwdulr2jb.rcgu.o b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.zpp9e1bwdulr2jb.rcgu.o new file mode 100644 index 0000000..29bc749 Binary files /dev/null and b/role-playing-game/target/debug/deps/role_playing_game-701c6c9e456a6926.zpp9e1bwdulr2jb.rcgu.o differ diff --git a/role-playing-game/target/debug/deps/role_playing_game-daccff4ebcf3cde0.d b/role-playing-game/target/debug/deps/role_playing_game-daccff4ebcf3cde0.d new file mode 100644 index 0000000..c49063e --- /dev/null +++ b/role-playing-game/target/debug/deps/role_playing_game-daccff4ebcf3cde0.d @@ -0,0 +1,7 @@ +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-daccff4ebcf3cde0.rmeta: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/librole_playing_game-daccff4ebcf3cde0.rlib: src/lib.rs + +/Users/arthurdanjou/Exercism/rust/role-playing-game/target/debug/deps/role_playing_game-daccff4ebcf3cde0.d: src/lib.rs + +src/lib.rs: diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/2zu8ar06u1jm991y.o b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/2zu8ar06u1jm991y.o new file mode 100644 index 0000000..d8244cb Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/2zu8ar06u1jm991y.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/367cpkl7hsj4fdpb.o b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/367cpkl7hsj4fdpb.o new file mode 100644 index 0000000..6342492 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/367cpkl7hsj4fdpb.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/3qp5bcvkby1cdr6k.o b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/3qp5bcvkby1cdr6k.o new file mode 100644 index 0000000..8f06993 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/3qp5bcvkby1cdr6k.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/dep-graph.bin b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/dep-graph.bin new file mode 100644 index 0000000..7fcebf1 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/dep-graph.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/query-cache.bin b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/query-cache.bin new file mode 100644 index 0000000..7a64d27 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/query-cache.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/work-products.bin b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/work-products.bin new file mode 100644 index 0000000..e1093a5 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w-2sayitsz0ounc/work-products.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w.lock b/role-playing-game/target/debug/incremental/role_playing_game-3oztlnv4mqe9f/s-gc88m65fev-1kb7z5w.lock new file mode 100755 index 0000000..e69de29 diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1533tp1kbvw5bq0t.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1533tp1kbvw5bq0t.o new file mode 100644 index 0000000..40bd8b3 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1533tp1kbvw5bq0t.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1cn7xkn5q0p3p9by.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1cn7xkn5q0p3p9by.o new file mode 100644 index 0000000..34ed9f3 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1cn7xkn5q0p3p9by.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1how2768iwnwgw9l.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1how2768iwnwgw9l.o new file mode 100644 index 0000000..fb21a88 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/1how2768iwnwgw9l.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2093ehvk7u8fqtbw.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2093ehvk7u8fqtbw.o new file mode 100644 index 0000000..ab3e731 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2093ehvk7u8fqtbw.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/287pzhzk6x3t4i5m.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/287pzhzk6x3t4i5m.o new file mode 100644 index 0000000..1c6d033 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/287pzhzk6x3t4i5m.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2iemr5jzalattxuw.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2iemr5jzalattxuw.o new file mode 100644 index 0000000..d69663a Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/2iemr5jzalattxuw.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/335shigblqvvufnq.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/335shigblqvvufnq.o new file mode 100644 index 0000000..aac579e Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/335shigblqvvufnq.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/33zj0aevdu9d4z6v.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/33zj0aevdu9d4z6v.o new file mode 100644 index 0000000..f20d540 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/33zj0aevdu9d4z6v.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3cwmmueuvv580it4.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3cwmmueuvv580it4.o new file mode 100644 index 0000000..f505bca Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3cwmmueuvv580it4.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3r2ctwa1dmos3or8.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3r2ctwa1dmos3or8.o new file mode 100644 index 0000000..f6799b8 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/3r2ctwa1dmos3or8.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4f4j5sguzhvzidet.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4f4j5sguzhvzidet.o new file mode 100644 index 0000000..d9870e4 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4f4j5sguzhvzidet.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4t4yk8xdkkwelm12.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4t4yk8xdkkwelm12.o new file mode 100644 index 0000000..350fb9e Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4t4yk8xdkkwelm12.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4xjao9ugmyl2cfv4.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4xjao9ugmyl2cfv4.o new file mode 100644 index 0000000..e51f4b0 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/4xjao9ugmyl2cfv4.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/57n6tlbr4er5qzih.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/57n6tlbr4er5qzih.o new file mode 100644 index 0000000..7c7f1d7 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/57n6tlbr4er5qzih.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/59rplhfzvhhpcp7e.o b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/59rplhfzvhhpcp7e.o new file mode 100644 index 0000000..8aa2b69 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/59rplhfzvhhpcp7e.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/dep-graph.bin b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/dep-graph.bin new file mode 100644 index 0000000..04709ea Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/dep-graph.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/query-cache.bin b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/query-cache.bin new file mode 100644 index 0000000..3446da6 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/query-cache.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/work-products.bin b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/work-products.bin new file mode 100644 index 0000000..3b712cf Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43-38gpqzva7rs1q/work-products.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43.lock b/role-playing-game/target/debug/incremental/role_playing_game-7235j44ou0j9/s-gc88m66yup-1y3xn43.lock new file mode 100755 index 0000000..e69de29 diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/185uo2bzec4a5hyg.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/185uo2bzec4a5hyg.o new file mode 100644 index 0000000..21b970f Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/185uo2bzec4a5hyg.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1a8gyf1ywtshfdp5.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1a8gyf1ywtshfdp5.o new file mode 100644 index 0000000..f5c9409 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1a8gyf1ywtshfdp5.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1ak679xcfowyuvkq.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1ak679xcfowyuvkq.o new file mode 100644 index 0000000..0a07d6c Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/1ak679xcfowyuvkq.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/2ixzut5gl4mk1p6w.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/2ixzut5gl4mk1p6w.o new file mode 100644 index 0000000..1742fef Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/2ixzut5gl4mk1p6w.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3r8hgdfnrpe7mr9o.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3r8hgdfnrpe7mr9o.o new file mode 100644 index 0000000..9812a46 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3r8hgdfnrpe7mr9o.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3sbcof928f7zzg82.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3sbcof928f7zzg82.o new file mode 100644 index 0000000..0c1eeb4 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/3sbcof928f7zzg82.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/dep-graph.bin b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/dep-graph.bin new file mode 100644 index 0000000..01c69e0 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/dep-graph.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/query-cache.bin b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/query-cache.bin new file mode 100644 index 0000000..555e38b Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/query-cache.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/work-products.bin b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/work-products.bin new file mode 100644 index 0000000..15c494c Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/work-products.bin differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/zpp9e1bwdulr2jb.o b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/zpp9e1bwdulr2jb.o new file mode 100644 index 0000000..29bc749 Binary files /dev/null and b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu-28k6455q70uk2/zpp9e1bwdulr2jb.o differ diff --git a/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu.lock b/role-playing-game/target/debug/incremental/role_playing_game-sre5fnwnk92w/s-gc88m65fev-1io75mu.lock new file mode 100755 index 0000000..e69de29 diff --git a/role-playing-game/tests/role-playing-game.rs b/role-playing-game/tests/role-playing-game.rs new file mode 100644 index 0000000..4993207 --- /dev/null +++ b/role-playing-game/tests/role-playing-game.rs @@ -0,0 +1,136 @@ +use role_playing_game::*; + +#[test] +fn test_reviving_dead_player() { + let dead_player = Player { + health: 0, + mana: Some(0), + level: 34, + }; + let revived_player = dead_player + .revive() + .expect("reviving a dead player must return Some(player)"); + assert_eq!(revived_player.health, 100); + assert_eq!(revived_player.mana, Some(100)); + assert_eq!(revived_player.level, dead_player.level); +} + +#[test] +#[ignore] +fn test_reviving_dead_level9_player() { + let dead_player = Player { + health: 0, + mana: None, + level: 9, + }; + let revived_player = dead_player + .revive() + .expect("reviving a dead player must return Some(player)"); + assert_eq!(revived_player.health, 100); + assert_eq!(revived_player.mana, None); + assert_eq!(revived_player.level, dead_player.level); +} + +#[test] +#[ignore] +fn test_reviving_dead_level10_player() { + let dead_player = Player { + health: 0, + mana: Some(0), + level: 10, + }; + let revived_player = dead_player + .revive() + .expect("reviving a dead player must return Some(player)"); + assert_eq!(revived_player.health, 100); + assert_eq!(revived_player.mana, Some(100)); + assert_eq!(revived_player.level, dead_player.level); +} + +#[test] +#[ignore] +fn test_reviving_alive_player() { + let alive_player = Player { + health: 1, + mana: None, + level: 8, + }; + assert!(alive_player.revive().is_none()); +} + +#[test] +#[ignore] +fn test_cast_spell_with_enough_mana() { + const HEALTH: u32 = 99; + const MANA: u32 = 100; + const LEVEL: u32 = 100; + const MANA_COST: u32 = 3; + + let mut accomplished_wizard = Player { + health: HEALTH, + mana: Some(MANA), + level: LEVEL, + }; + + assert_eq!(accomplished_wizard.cast_spell(MANA_COST), MANA_COST * 2); + assert_eq!(accomplished_wizard.health, HEALTH); + assert_eq!(accomplished_wizard.mana, Some(MANA - MANA_COST)); + assert_eq!(accomplished_wizard.level, LEVEL); +} + +#[test] +#[ignore] +fn test_cast_spell_with_insufficient_mana() { + let mut no_mana_wizard = Player { + health: 56, + mana: Some(2), + level: 22, + }; + + // we want to clone so we can compare before-and-after effects of casting the spell, + // but we don't want to introduce that concept to the student yet, so we have to do it manually + let clone = Player { ..no_mana_wizard }; + + assert_eq!(no_mana_wizard.cast_spell(3), 0); + assert_eq!(no_mana_wizard.health, clone.health); + assert_eq!(no_mana_wizard.mana, clone.mana); + assert_eq!(no_mana_wizard.level, clone.level); +} + +#[test] +#[ignore] +fn test_cast_spell_with_no_mana_pool() { + const MANA_COST: u32 = 10; + + let mut underleveled_player = Player { + health: 87, + mana: None, + level: 6, + }; + + let clone = Player { + ..underleveled_player + }; + + assert_eq!(underleveled_player.cast_spell(MANA_COST), 0); + assert_eq!(underleveled_player.health, clone.health - MANA_COST); + assert_eq!(underleveled_player.mana, clone.mana); + assert_eq!(underleveled_player.level, clone.level); +} + +#[test] +#[ignore] +fn test_cast_large_spell_with_no_mana_pool() { + const MANA_COST: u32 = 30; + + let mut underleveled_player = Player { + health: 20, + mana: None, + level: 6, + }; + + assert_eq!(underleveled_player.cast_spell(MANA_COST), 0); + assert_eq!(underleveled_player.health, 0); + assert_eq!(underleveled_player.mana, None); + assert_eq!(underleveled_player.level, 6); +} diff --git a/scrabble-score/.exercism/config.json b/scrabble-score/.exercism/config.json new file mode 100644 index 0000000..f50d4d5 --- /dev/null +++ b/scrabble-score/.exercism/config.json @@ -0,0 +1,40 @@ +{ + "blurb": "Given a word, compute the Scrabble score for that word.", + "authors": [ + "IanWhitney" + ], + "contributors": [ + "ashleygwilliams", + "AvasDream", + "coriolinus", + "cwhakes", + "efx", + "ErikSchierboom", + "IanWhitney", + "juleskers", + "kotp", + "lutostag", + "mkantor", + "navossoc", + "nfiles", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/scrabble-score.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Inspired by the Extreme Startup game", + "source_url": "https://github.com/rchatley/extreme_startup" +} diff --git a/scrabble-score/.exercism/metadata.json b/scrabble-score/.exercism/metadata.json new file mode 100644 index 0000000..d0eeec7 --- /dev/null +++ b/scrabble-score/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"scrabble-score","id":"c7ce834e65f24c8796c171280ce49bee","url":"https://exercism.org/tracks/rust/exercises/scrabble-score","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/scrabble-score/.gitignore b/scrabble-score/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/scrabble-score/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/scrabble-score/Cargo.toml b/scrabble-score/Cargo.toml new file mode 100644 index 0000000..7de526a --- /dev/null +++ b/scrabble-score/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "scrabble-score" +version = "1.1.0" diff --git a/scrabble-score/HELP.md b/scrabble-score/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/scrabble-score/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/scrabble-score/README.md b/scrabble-score/README.md new file mode 100644 index 0000000..943624f --- /dev/null +++ b/scrabble-score/README.md @@ -0,0 +1,76 @@ +# Scrabble Score + +Welcome to Scrabble Score on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given a word, compute the Scrabble score for that word. + +## Letter Values + +You'll need these: + +```text +Letter Value +A, E, I, O, U, L, N, R, S, T 1 +D, G 2 +B, C, M, P 3 +F, H, V, W, Y 4 +K 5 +J, X 8 +Q, Z 10 +``` + +## Examples + +"cabbage" should be scored as worth 14 points: + +- 3 points for C +- 1 point for A, twice +- 3 points for B, twice +- 2 points for G +- 1 point for E + +And to total: + +- `3 + 2*1 + 2*3 + 2 + 1` +- = `3 + 2 + 6 + 3` +- = `5 + 9` +- = 14 + +## Extensions + +- You can play a double or a triple letter. +- You can play a double or a triple word. + +## Source + +### Created by + +- @IanWhitney + +### Contributed to by + +- @ashleygwilliams +- @AvasDream +- @coriolinus +- @cwhakes +- @efx +- @ErikSchierboom +- @IanWhitney +- @juleskers +- @kotp +- @lutostag +- @mkantor +- @navossoc +- @nfiles +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Inspired by the Extreme Startup game - https://github.com/rchatley/extreme_startup \ No newline at end of file diff --git a/scrabble-score/src/lib.rs b/scrabble-score/src/lib.rs new file mode 100644 index 0000000..4a5fab9 --- /dev/null +++ b/scrabble-score/src/lib.rs @@ -0,0 +1,21 @@ +fn get_score(letter: char) -> u64 { + match letter { + 'A' | 'E' | 'I' | 'O' | 'U' | 'L' | 'N' | 'R' | 'S' | 'T' => 1, + 'D' | 'G' => 2, + 'B' | 'C' | 'M' | 'P' => 3, + 'F' | 'H' | 'V' | 'W' | 'Y' => 4, + 'K' => 5, + 'J' | 'X' => 8, + 'Q' | 'Z' => 10, + _ => 0 + } +} + +/// Compute the Scrabble score for a word. +pub fn score(word: &str) -> u64 { + word + .chars() + .map(|ch| ch.to_ascii_uppercase()) + .map(|letter| get_score(letter)) + .sum() +} diff --git a/scrabble-score/tests/scrabble-score.rs b/scrabble-score/tests/scrabble-score.rs new file mode 100644 index 0000000..ab7439a --- /dev/null +++ b/scrabble-score/tests/scrabble-score.rs @@ -0,0 +1,74 @@ +use scrabble_score::*; + +#[test] +fn a_is_worth_one_point() { + assert_eq!(score("a"), 1); +} + +#[test] +#[ignore] +fn scoring_is_case_insensitive() { + assert_eq!(score("A"), 1); +} + +#[test] +#[ignore] +fn f_is_worth_four() { + assert_eq!(score("f"), 4); +} + +#[test] +#[ignore] +fn two_one_point_letters_make_a_two_point_word() { + assert_eq!(score("at"), 2); +} + +#[test] +#[ignore] +fn three_letter_word() { + assert_eq!(score("zoo"), 12); +} + +#[test] +#[ignore] +fn medium_word() { + assert_eq!(score("street"), 6); +} + +#[test] +#[ignore] +fn longer_words_with_valuable_letters() { + assert_eq!(score("quirky"), 22); +} + +#[test] +#[ignore] +fn long_mixed_case_word() { + assert_eq!(score("OxyphenButazone"), 41); +} + +#[test] +#[ignore] +fn non_english_scrabble_letters_do_not_score() { + assert_eq!(score("pinata"), 8, "'n' should score 1"); + assert_eq!(score("piñata"), 7, "'ñ' should score 0"); +} + +#[test] +#[ignore] +fn empty_words_are_worth_zero() { + assert_eq!(score(""), 0); +} + +#[test] +#[ignore] +fn all_letters_work() { + assert_eq!(score("abcdefghijklmnopqrstuvwxyz"), 87); +} + +#[test] +#[ignore] +fn german_letters_do_not_score() { + assert_eq!(score("STRASSE"), 7, "\"SS\" should score 2"); + assert_eq!(score("STRAßE"), 5, "'ß' should score 0"); +} diff --git a/short-fibonacci/.exercism/config.json b/short-fibonacci/.exercism/config.json new file mode 100644 index 0000000..460bce3 --- /dev/null +++ b/short-fibonacci/.exercism/config.json @@ -0,0 +1,19 @@ +{ + "blurb": "Learn the `vec!` macro to build a short Fibonacci Sequence.", + "authors": [ + "efx", + "coriolinus" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/short-fibonacci.rs" + ], + "exemplar": [ + ".meta/exemplar.rs" + ] + } +} diff --git a/short-fibonacci/.exercism/metadata.json b/short-fibonacci/.exercism/metadata.json new file mode 100644 index 0000000..5588326 --- /dev/null +++ b/short-fibonacci/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"short-fibonacci","id":"f46665ffc496441fbe2066036813ebb0","url":"https://exercism.org/tracks/rust/exercises/short-fibonacci","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/short-fibonacci/.gitignore b/short-fibonacci/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/short-fibonacci/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/short-fibonacci/Cargo.toml b/short-fibonacci/Cargo.toml new file mode 100644 index 0000000..d2ee550 --- /dev/null +++ b/short-fibonacci/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "short_fibonacci" +version = "0.1.0" +edition = "2021" diff --git a/short-fibonacci/HELP.md b/short-fibonacci/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/short-fibonacci/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/short-fibonacci/HINTS.md b/short-fibonacci/HINTS.md new file mode 100644 index 0000000..deb22bb --- /dev/null +++ b/short-fibonacci/HINTS.md @@ -0,0 +1,5 @@ +# Hints + +## General + +- Check out the Rust documentation on [the `vec!` macro](https://doc.rust-lang.org/std/macro.vec.html). \ No newline at end of file diff --git a/short-fibonacci/README.md b/short-fibonacci/README.md new file mode 100644 index 0000000..ec045a2 --- /dev/null +++ b/short-fibonacci/README.md @@ -0,0 +1,40 @@ +# A Short Fibonacci Sequence + +Welcome to A Short Fibonacci Sequence on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. +If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :) + +## Introduction + +Rust provides a macro `vec![]` to help you create Vectors. +This comes in quite handy when you need to initialize lists. + +## Instructions + +You are going to initialize empty buffers and list the first five numbers, or elements, of the Fibonacci sequence. + +The Fibonacci sequence is a set of numbers where the next element is the sum of the prior two. We start the sequence at one. So the first two elements are 1 and 1. + +## 1. Create a buffer of `count` zeroes. + +Create a function that creates a buffer of `count` zeroes. +```rust +let my_buffer = create_buffer(5); +// [0, 0, 0, 0, 0] +``` + +## 2. List the first five elements of the Fibonacci sequence + +Create a function that returns the first five numbers of the Fibonacci sequence. +Its first five elements are `1, 1, 2, 3, 5` +```rust +let first_five = fibonacci(); +// [1, 1, 2, 3, 5] +``` + +## Source + +### Created by + +- @efx +- @coriolinus \ No newline at end of file diff --git a/short-fibonacci/src/lib.rs b/short-fibonacci/src/lib.rs new file mode 100644 index 0000000..9f6697c --- /dev/null +++ b/short-fibonacci/src/lib.rs @@ -0,0 +1,19 @@ +/// Create an empty vector +pub fn create_empty() -> Vec { + Vec::new() +} + +/// Create a buffer of `count` zeroes. +/// +/// Applications often use buffers when serializing data to send over the network. +pub fn create_buffer(count: usize) -> Vec { + vec![0;count] +} + +/// Create a vector containing the first five elements of the Fibonacci sequence. +/// +/// Fibonacci's sequence is the list of numbers where the next number is a sum of the previous two. +/// Its first five elements are `1, 1, 2, 3, 5`. +pub fn fibonacci() -> Vec { + vec![1, 1, 2, 3, 5] +} diff --git a/short-fibonacci/tests/short-fibonacci.rs b/short-fibonacci/tests/short-fibonacci.rs new file mode 100644 index 0000000..db6b2eb --- /dev/null +++ b/short-fibonacci/tests/short-fibonacci.rs @@ -0,0 +1,26 @@ +use short_fibonacci::*; + +#[test] +fn test_empty() { + assert_eq!(create_empty(), Vec::new()); +} +#[test] +#[ignore] +fn test_buffer() { + for n in 0..10 { + let zeroized = create_buffer(n); + assert_eq!(zeroized.len(), n); + assert!(zeroized.iter().all(|&v| v == 0)); + } +} +#[test] +#[ignore] +fn test_fibonacci() { + let fibb = fibonacci(); + assert_eq!(fibb.len(), 5); + assert_eq!(fibb[0], 1); + assert_eq!(fibb[1], 1); + for window in fibb.windows(3) { + assert_eq!(window[0] + window[1], window[2]); + } +} diff --git a/space-age/.exercism/config.json b/space-age/.exercism/config.json new file mode 100644 index 0000000..b4c21a4 --- /dev/null +++ b/space-age/.exercism/config.json @@ -0,0 +1,40 @@ +{ + "blurb": "Given an age in seconds, calculate how old someone is in terms of a given planet's solar years.", + "authors": [ + "IanWhitney" + ], + "contributors": [ + "ashleygwilliams", + "bobahop", + "coriolinus", + "cwhakes", + "durka", + "eddyp", + "efx", + "ErikSchierboom", + "IanWhitney", + "joshgoebel", + "lutostag", + "nfiles", + "ocstl", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/space-age.rs" + ], + "example": [ + ".meta/example.rs" + ] + }, + "source": "Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial.", + "source_url": "http://pine.fm/LearnToProgram/?Chapter=01" +} diff --git a/space-age/.exercism/metadata.json b/space-age/.exercism/metadata.json new file mode 100644 index 0000000..ab8bd5d --- /dev/null +++ b/space-age/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"space-age","id":"cbf279b07c06422f850ac2c853bf6447","url":"https://exercism.org/tracks/rust/exercises/space-age","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/space-age/.gitignore b/space-age/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/space-age/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/space-age/Cargo.toml b/space-age/Cargo.toml new file mode 100644 index 0000000..9640244 --- /dev/null +++ b/space-age/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "space-age" +version = "1.2.0" diff --git a/space-age/HELP.md b/space-age/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/space-age/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/space-age/README.md b/space-age/README.md new file mode 100644 index 0000000..9724784 --- /dev/null +++ b/space-age/README.md @@ -0,0 +1,69 @@ +# Space Age + +Welcome to Space Age on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given an age in seconds, calculate how old someone would be on: + + - Mercury: orbital period 0.2408467 Earth years + - Venus: orbital period 0.61519726 Earth years + - Earth: orbital period 1.0 Earth years, 365.25 Earth days, or 31557600 seconds + - Mars: orbital period 1.8808158 Earth years + - Jupiter: orbital period 11.862615 Earth years + - Saturn: orbital period 29.447498 Earth years + - Uranus: orbital period 84.016846 Earth years + - Neptune: orbital period 164.79132 Earth years + +So if you were told someone were 1,000,000,000 seconds old, you should +be able to say that they're 31.69 Earth-years old. + +If you're wondering why Pluto didn't make the cut, go watch [this +youtube video](http://www.youtube.com/watch?v=Z_2gbGXzFbs). + +Some Rust topics you may want to read about while solving this problem: + +- Traits, both the From trait and implementing your own traits +- Default method implementations for traits +- Macros, the use of a macro could reduce boilerplate and increase readability + for this exercise. For instance, + [a macro can implement a trait for multiple types at once](https://stackoverflow.com/questions/39150216/implementing-a-trait-for-multiple-types-at-once), + though it is fine to implement `years_during` in the Planet trait itself. A macro could + define both the structs and their implementations. Info to get started with macros can + be found at: + + - [The Macros chapter in The Rust Programming Language](https://doc.rust-lang.org/stable/book/ch19-06-macros.html) + - [an older version of the Macros chapter with helpful detail](https://doc.rust-lang.org/1.30.0/book/first-edition/macros.html) + - [Rust By Example](https://doc.rust-lang.org/stable/rust-by-example/macros.html) + +## Source + +### Created by + +- @IanWhitney + +### Contributed to by + +- @ashleygwilliams +- @bobahop +- @coriolinus +- @cwhakes +- @durka +- @eddyp +- @efx +- @ErikSchierboom +- @IanWhitney +- @joshgoebel +- @lutostag +- @nfiles +- @ocstl +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton + +### Based on + +Partially inspired by Chapter 1 in Chris Pine's online Learn to Program tutorial. - http://pine.fm/LearnToProgram/?Chapter=01 \ No newline at end of file diff --git a/space-age/src/lib.rs b/space-age/src/lib.rs new file mode 100644 index 0000000..6e0cc98 --- /dev/null +++ b/space-age/src/lib.rs @@ -0,0 +1,25 @@ +pub struct Duration(f64); + +impl From for Duration { + fn from(s: u64) -> Self { Duration((s as f64) / (31557600 as f64)) } +} + +pub trait Planet { + fn period() -> f64; + fn years_during(duration: &Duration) -> f64 { duration.0 / Self::period() } +} + +macro_rules! planet { + ($n:ident, $p:expr) => { + pub struct $n; impl Planet for $n { fn period() -> f64 { $p } } + } +} + +planet!(Earth, 1.0); +planet!(Mercury, 0.2408467); +planet!(Venus, 0.61519726); +planet!(Mars, 1.8808158); +planet!(Jupiter, 11.862615); +planet!(Saturn, 29.447498); +planet!(Uranus, 84.016846); +planet!(Neptune, 164.79132); diff --git a/space-age/tests/space-age.rs b/space-age/tests/space-age.rs new file mode 100644 index 0000000..b54e2f4 --- /dev/null +++ b/space-age/tests/space-age.rs @@ -0,0 +1,67 @@ +use space_age::*; + +fn assert_in_delta(expected: f64, actual: f64) { + let diff: f64 = (expected - actual).abs(); + let delta: f64 = 0.01; + if diff > delta { + panic!( + "Your result of {} should be within {} of the expected result {}", + actual, delta, expected + ) + } +} + +#[test] +fn earth_age() { + let duration = Duration::from(1_000_000_000); + assert_in_delta(31.69, Earth::years_during(&duration)); +} + +#[test] +#[ignore] +fn mercury_age() { + let duration = Duration::from(2_134_835_688); + assert_in_delta(280.88, Mercury::years_during(&duration)); +} + +#[test] +#[ignore] +fn venus_age() { + let duration = Duration::from(189_839_836); + assert_in_delta(9.78, Venus::years_during(&duration)); +} + +#[test] +#[ignore] +fn mars_age() { + let duration = Duration::from(2_129_871_239); + assert_in_delta(35.88, Mars::years_during(&duration)); +} + +#[test] +#[ignore] +fn jupiter_age() { + let duration = Duration::from(901_876_382); + assert_in_delta(2.41, Jupiter::years_during(&duration)); +} + +#[test] +#[ignore] +fn saturn_age() { + let duration = Duration::from(2_000_000_000); + assert_in_delta(2.15, Saturn::years_during(&duration)); +} + +#[test] +#[ignore] +fn uranus_age() { + let duration = Duration::from(1_210_123_456); + assert_in_delta(0.46, Uranus::years_during(&duration)); +} + +#[test] +#[ignore] +fn neptune_age() { + let duration = Duration::from(1_821_023_456); + assert_in_delta(0.35, Neptune::years_during(&duration)); +} diff --git a/sublist/.exercism/config.json b/sublist/.exercism/config.json new file mode 100644 index 0000000..021f1f6 --- /dev/null +++ b/sublist/.exercism/config.json @@ -0,0 +1,37 @@ +{ + "blurb": "Write a function to determine if a list is a sublist of another list.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "ashleygwilliams", + "coriolinus", + "cwhakes", + "eddyp", + "EduardoBautista", + "efx", + "ErikSchierboom", + "IanWhitney", + "kytrinyx", + "lutostag", + "mkantor", + "nfiles", + "petertseng", + "rofrol", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/sublist.rs" + ], + "example": [ + ".meta/example.rs" + ] + } +} diff --git a/sublist/.exercism/metadata.json b/sublist/.exercism/metadata.json new file mode 100644 index 0000000..041fc54 --- /dev/null +++ b/sublist/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"sublist","id":"fae3987b02fd4ddba52b6e5639e75dcf","url":"https://exercism.org/tracks/rust/exercises/sublist","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/sublist/.gitignore b/sublist/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/sublist/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/sublist/Cargo.toml b/sublist/Cargo.toml new file mode 100644 index 0000000..6493981 --- /dev/null +++ b/sublist/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "sublist" +version = "0.0.0" diff --git a/sublist/HELP.md b/sublist/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/sublist/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/sublist/README.md b/sublist/README.md new file mode 100644 index 0000000..2c905a4 --- /dev/null +++ b/sublist/README.md @@ -0,0 +1,49 @@ +# Sublist + +Welcome to Sublist on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Given two lists determine if the first list is contained within the second +list, if the second list is contained within the first list, if both lists are +contained within each other or if none of these are true. + +Specifically, a list A is a sublist of list B if by dropping 0 or more elements +from the front of B and 0 or more elements from the back of B you get a list +that's completely equal to A. + +Examples: + + * A = [1, 2, 3], B = [1, 2, 3, 4, 5], A is a sublist of B + * A = [3, 4, 5], B = [1, 2, 3, 4, 5], A is a sublist of B + * A = [3, 4], B = [1, 2, 3, 4, 5], A is a sublist of B + * A = [1, 2, 3], B = [1, 2, 3], A is equal to B + * A = [1, 2, 3, 4, 5], B = [2, 3, 4], A is a superlist of B + * A = [1, 2, 4], B = [1, 2, 3, 4, 5], A is not a superlist of, sublist of or equal to B + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @ashleygwilliams +- @coriolinus +- @cwhakes +- @eddyp +- @EduardoBautista +- @efx +- @ErikSchierboom +- @IanWhitney +- @kytrinyx +- @lutostag +- @mkantor +- @nfiles +- @petertseng +- @rofrol +- @stringparser +- @xakon +- @ZapAnton \ No newline at end of file diff --git a/sublist/src/lib.rs b/sublist/src/lib.rs new file mode 100644 index 0000000..1022d0b --- /dev/null +++ b/sublist/src/lib.rs @@ -0,0 +1,33 @@ +#[derive(Debug, PartialEq, Eq)] +pub enum Comparison { + Equal, + Sublist, + Superlist, + Unequal, +} + +pub trait HasPart { + fn has_part(&self, rhs: &Self) -> bool; +} + +impl HasPart for [T] { + fn has_part(&self, second: &Self) -> bool { + if second.is_empty() { + return true; + } + self.windows(second.len()).any(|curr| curr == second) + } +} + + +pub fn sublist(_first_list: &[T], _second_list: &[T]) -> Comparison { + if _first_list == _second_list { + Comparison::Equal + } else if _first_list.has_part(_second_list) { + Comparison::Superlist + } else if _second_list.has_part(_first_list) { + Comparison::Sublist + } else { + Comparison::Unequal + } +} \ No newline at end of file diff --git a/sublist/tests/sublist.rs b/sublist/tests/sublist.rs new file mode 100644 index 0000000..9653ab1 --- /dev/null +++ b/sublist/tests/sublist.rs @@ -0,0 +1,127 @@ +use sublist::{sublist, Comparison}; + +#[test] +fn empty_equals_empty() { + let v: &[u32] = &[]; + + assert_eq!(Comparison::Equal, sublist(v, v)); +} + +#[test] +#[ignore] +fn test_empty_is_a_sublist_of_anything() { + assert_eq!(Comparison::Sublist, sublist(&[], &['a', 's', 'd', 'f'])); +} + +#[test] +#[ignore] +fn test_anything_is_a_superlist_of_empty() { + assert_eq!(Comparison::Superlist, sublist(&['a', 's', 'd', 'f'], &[])); +} + +#[test] +#[ignore] +fn test_1_is_not_2() { + assert_eq!(Comparison::Unequal, sublist(&[1], &[2])); +} + +#[test] +#[ignore] +fn test_compare_larger_equal_lists() { + use std::iter::repeat; + + let v: Vec = repeat('x').take(1000).collect(); + + assert_eq!(Comparison::Equal, sublist(&v, &v)); +} + +#[test] +#[ignore] +fn test_sublist_at_start() { + assert_eq!(Comparison::Sublist, sublist(&[1, 2, 3], &[1, 2, 3, 4, 5])); +} + +#[test] +#[ignore] +fn sublist_in_middle() { + assert_eq!(Comparison::Sublist, sublist(&[4, 3, 2], &[5, 4, 3, 2, 1])); +} + +#[test] +#[ignore] +fn sublist_at_end() { + assert_eq!(Comparison::Sublist, sublist(&[3, 4, 5], &[1, 2, 3, 4, 5])); +} + +#[test] +#[ignore] +fn partially_matching_sublist_at_start() { + assert_eq!(Comparison::Sublist, sublist(&[1, 1, 2], &[1, 1, 1, 2])); +} + +#[test] +#[ignore] +fn sublist_early_in_huge_list() { + let huge: Vec = (1..1_000_000).collect(); + + assert_eq!(Comparison::Sublist, sublist(&[3, 4, 5], &huge)); +} + +#[test] +#[ignore] +fn huge_sublist_not_in_huge_list() { + let v1: Vec = (10..1_000_001).collect(); + let v2: Vec = (1..1_000_000).collect(); + + assert_eq!(Comparison::Unequal, sublist(&v1, &v2)); +} + +#[test] +#[ignore] +fn superlist_at_start() { + assert_eq!(Comparison::Superlist, sublist(&[1, 2, 3, 4, 5], &[1, 2, 3])); +} + +#[test] +#[ignore] +fn superlist_in_middle() { + assert_eq!(Comparison::Superlist, sublist(&[5, 4, 3, 2, 1], &[4, 3, 2])); +} + +#[test] +#[ignore] +fn superlist_at_end() { + assert_eq!(Comparison::Superlist, sublist(&[1, 2, 3, 4, 5], &[3, 4, 5])); +} + +#[test] +#[ignore] +fn second_list_missing_element_from_first_list() { + assert_eq!(Comparison::Unequal, sublist(&[1, 2, 3], &[1, 3])); +} + +#[test] +#[ignore] +fn superlist_early_in_huge_list() { + let huge: Vec = (1..1_000_000).collect(); + + assert_eq!(Comparison::Superlist, sublist(&huge, &[3, 4, 5])); +} + +#[test] +#[ignore] +fn recurring_values_sublist() { + assert_eq!( + Comparison::Sublist, + sublist(&[1, 2, 1, 2, 3], &[1, 2, 3, 1, 2, 1, 2, 3, 2, 1]) + ); +} + +#[test] +#[ignore] +fn recurring_values_unequal() { + assert_eq!( + Comparison::Unequal, + sublist(&[1, 2, 1, 2, 3], &[1, 2, 3, 1, 2, 3, 2, 3, 2, 1]) + ); +} diff --git a/tournament/.exercism/config.json b/tournament/.exercism/config.json new file mode 100644 index 0000000..291a4a5 --- /dev/null +++ b/tournament/.exercism/config.json @@ -0,0 +1,41 @@ +{ + "blurb": "Tally the results of a small football competition.", + "authors": [ + "EduardoBautista" + ], + "contributors": [ + "andrewclarkson", + "ashleygwilliams", + "ClashTheBunny", + "coriolinus", + "cwhakes", + "EduardoBautista", + "efx", + "ErikSchierboom", + "etrepum", + "IanWhitney", + "kytrinyx", + "lutostag", + "mkantor", + "navossoc", + "nfiles", + "petertseng", + "rofrol", + "samcday", + "stringparser", + "xakon", + "ZapAnton" + ], + "files": { + "solution": [ + "src/lib.rs", + "Cargo.toml" + ], + "test": [ + "tests/tournament.rs" + ], + "example": [ + ".meta/example.rs" + ] + } +} diff --git a/tournament/.exercism/metadata.json b/tournament/.exercism/metadata.json new file mode 100644 index 0000000..e61e57b --- /dev/null +++ b/tournament/.exercism/metadata.json @@ -0,0 +1 @@ +{"track":"rust","exercise":"tournament","id":"aafb92c191a349b0bafd436bc2dfed05","url":"https://exercism.org/tracks/rust/exercises/tournament","handle":"ArthurDanjou","is_requester":true,"auto_approve":false} \ No newline at end of file diff --git a/tournament/.gitignore b/tournament/.gitignore new file mode 100644 index 0000000..db7f315 --- /dev/null +++ b/tournament/.gitignore @@ -0,0 +1,8 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ +**/*.rs.bk + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock +Cargo.lock diff --git a/tournament/Cargo.toml b/tournament/Cargo.toml new file mode 100644 index 0000000..e9209b3 --- /dev/null +++ b/tournament/Cargo.toml @@ -0,0 +1,4 @@ +[package] +edition = "2021" +name = "tournament" +version = "1.4.0" diff --git a/tournament/HELP.md b/tournament/HELP.md new file mode 100644 index 0000000..40d8a33 --- /dev/null +++ b/tournament/HELP.md @@ -0,0 +1,85 @@ +# Help + +## Running the tests + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, open the tests source file which is located in the `tests` directory +and remove the `#[ignore]` flag from the next test and get the tests to pass +again. Each separate test is a function with `#[test]` flag above it. +Continue, until you pass every test. + +If you wish to run _only ignored_ tests without editing the tests source file, use: + +```bash +$ cargo test -- --ignored +``` + +If you are using Rust 1.51 or later, you can run _all_ tests with + +```bash +$ cargo test -- --include-ignored +``` + +To run a specific test, for example `some_test`, you can use: + +```bash +$ cargo test some_test +``` + +If the specific test is ignored, use: + +```bash +$ cargo test some_test -- --ignored +``` + +To learn more about Rust tests refer to the online [test documentation][rust-tests]. + +[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html + +## Submitting your solution + +You can submit your solution using the `exercism submit src/lib.rs Cargo.toml` command. +This command will upload your solution to the Exercism website and print the solution page's URL. + +It's possible to submit an incomplete solution which allows you to: + +- See how others have completed the exercise +- Request help from a mentor + +## Need to get help? + +If you'd like help solving the exercise, check the following pages: + +- The [Rust track's documentation](https://exercism.org/docs/tracks/rust) +- [Exercism's support channel on gitter](https://gitter.im/exercism/support) +- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs) + +Should those resources not suffice, you could submit your (incomplete) solution to request mentoring. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Submitting the solution + +Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. + +## Feedback, Issues, Pull Requests + +The GitHub [track repository][github] is the home for all of the Rust exercises. If you have feedback about an exercise, or want to help implement new exercises, head over there and create an issue. Members of the rust track team are happy to help! + +If you want to know more about Exercism, take a look at the [contribution guide]. + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. + +[help-page]: https://exercism.org/tracks/rust/learning +[github]: https://github.com/exercism/rust +[contribution guide]: https://exercism.org/docs/community/contributors \ No newline at end of file diff --git a/tournament/README.md b/tournament/README.md new file mode 100644 index 0000000..f80688d --- /dev/null +++ b/tournament/README.md @@ -0,0 +1,98 @@ +# Tournament + +Welcome to Tournament on Exercism's Rust Track. +If you need help running the tests or submitting your code, check out `HELP.md`. + +## Instructions + +Tally the results of a small football competition. + +Based on an input file containing which team played against which and what the +outcome was, create a file with a table like this: + +```text +Team | MP | W | D | L | P +Devastating Donkeys | 3 | 2 | 1 | 0 | 7 +Allegoric Alaskans | 3 | 2 | 0 | 1 | 6 +Blithering Badgers | 3 | 1 | 0 | 2 | 3 +Courageous Californians | 3 | 0 | 1 | 2 | 1 +``` + +What do those abbreviations mean? + +- MP: Matches Played +- W: Matches Won +- D: Matches Drawn (Tied) +- L: Matches Lost +- P: Points + +A win earns a team 3 points. A draw earns 1. A loss earns 0. + +The outcome should be ordered by points, descending. In case of a tie, teams are ordered alphabetically. + +## Input + +Your tallying program will receive input that looks like: + +```text +Allegoric Alaskans;Blithering Badgers;win +Devastating Donkeys;Courageous Californians;draw +Devastating Donkeys;Allegoric Alaskans;win +Courageous Californians;Blithering Badgers;loss +Blithering Badgers;Devastating Donkeys;loss +Allegoric Alaskans;Courageous Californians;win +``` + +The result of the match refers to the first team listed. So this line: + +```text +Allegoric Alaskans;Blithering Badgers;win +``` + +means that the Allegoric Alaskans beat the Blithering Badgers. + +This line: + +```text +Courageous Californians;Blithering Badgers;loss +``` + +means that the Blithering Badgers beat the Courageous Californians. + +And this line: + +```text +Devastating Donkeys;Courageous Californians;draw +``` + +means that the Devastating Donkeys and Courageous Californians tied. + +## Source + +### Created by + +- @EduardoBautista + +### Contributed to by + +- @andrewclarkson +- @ashleygwilliams +- @ClashTheBunny +- @coriolinus +- @cwhakes +- @EduardoBautista +- @efx +- @ErikSchierboom +- @etrepum +- @IanWhitney +- @kytrinyx +- @lutostag +- @mkantor +- @navossoc +- @nfiles +- @petertseng +- @rofrol +- @samcday +- @stringparser +- @xakon +- @ZapAnton \ No newline at end of file diff --git a/tournament/src/lib.rs b/tournament/src/lib.rs new file mode 100644 index 0000000..dc84bc4 --- /dev/null +++ b/tournament/src/lib.rs @@ -0,0 +1,112 @@ +extern crate core; + +use std::collections::HashMap; + +const HEADER: &str = "Team | MP | W | D | L | P"; + +#[derive(Default, Eq, PartialEq)] +struct Team { + name: String, + matches: u8, + wins: u8, + draws: u8, + losses: u8, + points: u8 +} + +impl Team { + fn new(name: String) -> Self { + Self { + name, + ..Default::default() + } + } + + fn win(&mut self) { + self.wins += 1; + self.matches += 1; + self.points += 3; + } + + fn draw(&mut self) { + self.draws += 1; + self.matches += 1; + self.points += 1; + } + + fn lose(&mut self) { + self.losses += 1; + self.matches += 1; + } + + fn add_match(&mut self, result: &MatchResult) { + match result { + MatchResult::Win => self.win(), + MatchResult::Draw => self.draw(), + MatchResult::Loss => self.lose() + } + } +} + +impl From<&Team> for String { + fn from(team: &Team) -> String { + format!( + "{:<30} | {:>2} | {:>2} | {:>2} | {:>2} | {:>2}", + team.name, team.matches, team.wins, team.draws, team.losses, team.points + ) + } +} + +enum MatchResult { + Win, + Draw, + Loss +} + +impl From<&str> for MatchResult { + fn from(result: &str) -> Self { + match result { + "win" => MatchResult::Win, + "draw" => MatchResult::Draw, + "loss" => MatchResult::Loss, + _ => panic!() + } + } +} + +impl MatchResult { + fn reverse(&self) -> Self { + match self { + MatchResult::Win => MatchResult::Loss, + MatchResult::Draw => MatchResult::Draw, + MatchResult::Loss => MatchResult::Win + } + } +} + +pub fn tally(match_results: &str) -> String { + let mut scores: HashMap = HashMap::new(); + match_results.lines().for_each(|line| { + let frags: Vec<&str> = line.split(";").collect(); + let home = frags[0]; + let away = frags[1]; + let result = frags[2].into(); + scores + .entry(home.into()) + .or_insert(Team::new(home.into())) + .add_match(&result); + scores + .entry(away.into()) + .or_insert(Team::new(away.into())) + .add_match(&result.reverse()); + }); + + let mut score_values: Vec<&Team> = scores.values().collect(); + score_values.sort_by(|a, b| b.points.cmp(&a.points).then_with(|| a.name.cmp(&b.name))); + + vec![String::from(HEADER)] + .into_iter() + .chain(score_values.into_iter().map(|t| t.into())) + .collect::>() + .join("\n") +} diff --git a/tournament/tests/tournament.rs b/tournament/tests/tournament.rs new file mode 100644 index 0000000..398e918 --- /dev/null +++ b/tournament/tests/tournament.rs @@ -0,0 +1,152 @@ +#[test] +fn just_the_header_if_no_input() { + let input = ""; + let expected = "Team | MP | W | D | L | P"; + + assert_eq!(tournament::tally(input), expected); +} + +#[test] +#[ignore] +fn a_win_is_three_points_a_loss_is_zero_points() { + let input = "Allegoric Alaskans;Blithering Badgers;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" + + "Blithering Badgers | 1 | 0 | 0 | 1 | 0"; + + assert_eq!(tournament::tally(input), expected); +} + +#[test] +#[ignore] +fn a_win_can_also_be_expressed_as_a_loss() { + let input = "Blithering Badgers;Allegoric Alaskans;loss"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 1 | 1 | 0 | 0 | 3\n" + + "Blithering Badgers | 1 | 0 | 0 | 1 | 0"; + + assert_eq!(tournament::tally(input), expected); +} + +#[test] +#[ignore] +fn a_different_team_can_win() { + let input = "Blithering Badgers;Allegoric Alaskans;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Blithering Badgers | 1 | 1 | 0 | 0 | 3\n" + + "Allegoric Alaskans | 1 | 0 | 0 | 1 | 0"; + + assert_eq!(tournament::tally(input), expected); +} + +#[test] +#[ignore] +fn there_can_be_more_than_one_match() { + let input = "Allegoric Alaskans;Blithering Badgers;win\n".to_string() + + "Allegoric Alaskans;Blithering Badgers;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" + + "Blithering Badgers | 2 | 0 | 0 | 2 | 0"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn a_draw_is_one_point_each() { + let input = "Allegoric Alaskans;Blithering Badgers;draw\n".to_string() + + "Allegoric Alaskans;Blithering Badgers;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 2 | 1 | 1 | 0 | 4\n" + + "Blithering Badgers | 2 | 0 | 1 | 1 | 1"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn there_can_be_more_than_one_winner() { + let input = "Allegoric Alaskans;Blithering Badgers;loss\n".to_string() + + "Allegoric Alaskans;Blithering Badgers;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 2 | 1 | 0 | 1 | 3\n" + + "Blithering Badgers | 2 | 1 | 0 | 1 | 3"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn there_can_be_more_than_two_teams() { + let input = "Allegoric Alaskans;Blithering Badgers;win\n".to_string() + + "Blithering Badgers;Courageous Californians;win\n" + + "Courageous Californians;Allegoric Alaskans;loss"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 2 | 2 | 0 | 0 | 6\n" + + "Blithering Badgers | 2 | 1 | 0 | 1 | 3\n" + + "Courageous Californians | 2 | 0 | 0 | 2 | 0"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn typical_input() { + let input = "Allegoric Alaskans;Blithering Badgers;win\n".to_string() + + "Devastating Donkeys;Courageous Californians;draw\n" + + "Devastating Donkeys;Allegoric Alaskans;win\n" + + "Courageous Californians;Blithering Badgers;loss\n" + + "Blithering Badgers;Devastating Donkeys;loss\n" + + "Allegoric Alaskans;Courageous Californians;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Devastating Donkeys | 3 | 2 | 1 | 0 | 7\n" + + "Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" + + "Blithering Badgers | 3 | 1 | 0 | 2 | 3\n" + + "Courageous Californians | 3 | 0 | 1 | 2 | 1"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn incomplete_competition_not_all_pairs_have_played() { + let input = "Allegoric Alaskans;Blithering Badgers;loss\n".to_string() + + "Devastating Donkeys;Allegoric Alaskans;loss\n" + + "Courageous Californians;Blithering Badgers;draw\n" + + "Allegoric Alaskans;Courageous Californians;win"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 3 | 2 | 0 | 1 | 6\n" + + "Blithering Badgers | 2 | 1 | 1 | 0 | 4\n" + + "Courageous Californians | 2 | 0 | 1 | 1 | 1\n" + + "Devastating Donkeys | 1 | 0 | 0 | 1 | 0"; + + assert_eq!(tournament::tally(&input), expected); +} + +#[test] +#[ignore] +fn ties_broken_alphabetically() { + let input = "Courageous Californians;Devastating Donkeys;win\n".to_string() + + "Allegoric Alaskans;Blithering Badgers;win\n" + + "Devastating Donkeys;Allegoric Alaskans;loss\n" + + "Courageous Californians;Blithering Badgers;win\n" + + "Blithering Badgers;Devastating Donkeys;draw\n" + + "Allegoric Alaskans;Courageous Californians;draw"; + let expected = "".to_string() + + "Team | MP | W | D | L | P\n" + + "Allegoric Alaskans | 3 | 2 | 1 | 0 | 7\n" + + "Courageous Californians | 3 | 2 | 1 | 0 | 7\n" + + "Blithering Badgers | 3 | 0 | 1 | 2 | 1\n" + + "Devastating Donkeys | 3 | 0 | 1 | 2 | 1"; + + assert_eq!(tournament::tally(&input), expected); +}