From a4e9b1d58f6cb0291e5cfb68b1f44df58e2d861f Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Thu, 12 Apr 2018 08:13:29 +0200 Subject: [PATCH 01/24] inital --- exercises/palindrome-products/Cargo.toml | 6 ++++++ exercises/palindrome-products/src/lib.rs | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 exercises/palindrome-products/Cargo.toml create mode 100644 exercises/palindrome-products/src/lib.rs diff --git a/exercises/palindrome-products/Cargo.toml b/exercises/palindrome-products/Cargo.toml new file mode 100644 index 000000000..9fec34052 --- /dev/null +++ b/exercises/palindrome-products/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "palindrome-products" +version = "0.1.0" +authors = ["Kirill Meng "] + +[dependencies] diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs new file mode 100644 index 000000000..31e1bb209 --- /dev/null +++ b/exercises/palindrome-products/src/lib.rs @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn it_works() { + assert_eq!(2 + 2, 4); + } +} From cbb099c3b533aaf5479a09cad2723d67310b3c05 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Thu, 12 Apr 2018 08:42:41 +0200 Subject: [PATCH 02/24] add README.MD --- exercises/palindrome-products/README.MD | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 exercises/palindrome-products/README.MD diff --git a/exercises/palindrome-products/README.MD b/exercises/palindrome-products/README.MD new file mode 100644 index 000000000..2898b8660 --- /dev/null +++ b/exercises/palindrome-products/README.MD @@ -0,0 +1,66 @@ +# Palindrome Products +Detect palindrome products in a given range. + +A palindromic number is a number that remains the same when its digits are +reversed. For example, `121` is a palindromic number but `112` is not. + +Given a range of numbers, find the largest and smallest palindromes which +are products of numbers within that range. + +Your solution should return the largest and smallest palindromes, along with the +factors of each within the range. If the largest or smallest palindrome has more +than one pair of factors within the range, then return all the pairs. + +## Example 1 + +Given the range `[1, 9]` (both inclusive)... + +And given the list of all possible products within this range: +`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]` + +The palindrome products are all single digit numbers (in this case): +`[1, 2, 3, 4, 5, 6, 7, 8, 9]` + +The smallest palindrome product is `1`. Its factors are `(1, 1)`. +The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`. + +## Example 2 + +Given the range `[10, 99]` (both inclusive)... + +The smallest palindrome product is `121`. Its factors are `(11, 11)`. +The largest palindrome product is `9009`. Its factors are `(91, 99)`. + +## Rust Installation +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Writing the Code + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests +to pass again. The test file is located in the `tests` directory. You can +also remove the ignore flag from all the tests to get them to run all at once +if you wish. + +Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you +haven't already, it will help you with organizing your files. + +## Feedback, Issues, Pull Requests + +The [exercism/rust](https://github.com/exercism/rust) repository on 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](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md). + +[help-page]: http://exercism.io/languages/rust +[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html +[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. \ No newline at end of file From ca7fd00a3ecd8808424e979de9457974c204bc35 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Thu, 12 Apr 2018 10:32:09 +0200 Subject: [PATCH 03/24] add tests --- .../tests/palindrome-products.rs | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 exercises/palindrome-products/tests/palindrome-products.rs diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs new file mode 100644 index 000000000..e0c8093ab --- /dev/null +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -0,0 +1,62 @@ +extern crate palindrome_products; +use palindrome_products::*; + +#[test] +fn smallest_palindrome_single_digits(){ + assert_eq!(get_palindrome_product(1,9), Ok(1)); +} + +#[test] +fn largest_palindrome_single_digits(){ + assert_eq!(get_palindrome_product(1,9), Ok(9)); +} + +#[test] +fn smallest_palindrome_double_digits(){ + assert_eq!(get_palindrome_product(10,99), Ok(121)); +} + +#[test] +fn largest_palindrome_double_digits(){ + assert_eq!(get_palindrome_product(10,99), Ok(9009)); +} + +#[test] +fn smallest_palindrome_triple_digits(){ + assert_eq!(get_palindrome_product(100,999), Ok(10201)); +} + +#[test] +fn largest_palindrome_triple_digits(){ + assert_eq!(get_palindrome_product(100,999), Ok(906609)); +} + +#[test] +fn smallest_palindrome_four_digits(){ + assert_eq!(get_palindrome_product(1000,9999), Ok(1002001)); +} + +#[test] +fn largest_palindrome_four_digits(){ + assert_eq!(get_palindrome_product(1000,9999), Ok(99000099)); +} + +#[test] +fn empty_result_for_smallest_palindrome(){ + assert_eq!(get_palindrome_product(1002, 1003), Err(Error::Empty)); +} + +#[test] +fn empty_result_for_largest_palindrome(){ + assert_eq!(get_palindrome_product(15, 15), Err(Error::Empty)); +} + +#[test] +fn error_smallest_palindrome_when_min_bt_max(){ + assert_eq!(get_palindrome_product(1000, 1), Err(Error::RangeFailure)); +} + +#[test] +fn error_largest_palindrome_when_min_bt_max(){ + assert_eq!(get_palindrome_product(2, 1), Err(Error::RangeFailure)); +} \ No newline at end of file From ba4508f5989b057db5c7551a957ddc210511607f Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Thu, 12 Apr 2018 10:34:45 +0200 Subject: [PATCH 04/24] add empty example.rs file - pass 3 range failure tests by if statement in lib.rs --- exercises/palindrome-products/example.rs | 0 exercises/palindrome-products/src/lib.rs | 17 +++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 exercises/palindrome-products/example.rs diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs new file mode 100644 index 000000000..e69de29bb diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 31e1bb209..da74936fd 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -1,7 +1,12 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } +#[derive(Debug, PartialEq)] +pub enum Error{ + Empty, + RangeFailure, } + +pub fn get_palindrome_product(min: i32, max: i32) -> Result{ + if min > max{ + return Err(Error::RangeFailure); + } + Ok(1) +} \ No newline at end of file From d684347f1e30c5d96cd345174eb3db0a9692a125 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Sun, 15 Apr 2018 18:47:57 +0200 Subject: [PATCH 05/24] add factors check in tests - add exmaple.rs ref. solution --- exercises/palindrome-products/src/lib.rs | 87 ++++++++++++++++++- .../tests/palindrome-products.rs | 37 +++++--- 2 files changed, 109 insertions(+), 15 deletions(-) diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index da74936fd..83100e0de 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -4,9 +4,92 @@ pub enum Error{ RangeFailure, } -pub fn get_palindrome_product(min: i32, max: i32) -> Result{ +#[allow(dead_code)] +#[derive(Debug, PartialEq)] +pub struct ReturnVals{ + pub result: i32, + pub factors: Vec<(i32, i32)>, +} + +pub fn get_smallest_palindrome_product(min: i32, max: i32) -> Result{ + if min > max{ + return Err(Error::RangeFailure); + } + + let palindrome: Result = get_smallest_palindrome(min, max); + if palindrome.is_err(){ + return Err(palindrome.unwrap_err()); + } + let p = palindrome.unwrap(); + Ok(ReturnVals{ + result: p, + factors: get_factors(p, min, max), + }) +} + +pub fn get_largest_palindrome_product(min: i32, max: i32) -> Result{ if min > max{ return Err(Error::RangeFailure); } - Ok(1) + + let palindrome: Result = get_largest_palindrome(min, max); + if palindrome.is_err(){ + return Err(palindrome.unwrap_err()); + } + let p = palindrome.unwrap(); + Ok(ReturnVals{ + result: p, + factors: get_factors(p, min, max), + }) +} + +fn get_factors(n: i32, min: i32, max:i32)-> Vec<(i32, i32)>{ + let mut factors = Vec::new(); + + for number in min .. max{ + let div = n/number; + if n % number == 0 && div <= max && div >= min && !factors.contains(&(div, number)){ + factors.push((number, n/number)); + } + } + factors +} + +fn get_smallest_palindrome(min: i32, max:i32)-> Result{ + let l:Vec = (min*min .. max*max).collect(); + let filtered: Vec = l.iter() + .cloned() + .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) + .collect::>(); + if filtered.is_empty(){ + return Err(Error::Empty); + } else{ + Ok(*filtered.iter().min().unwrap()) + } +} + +fn get_largest_palindrome(min: i32, max:i32)-> Result{ + let l:Vec = (min*min .. max*max).collect(); + let filtered: Vec = l.iter() + .cloned() + .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) + .collect::>(); + if filtered.is_empty(){ + return Err(Error::Empty); + } else{ + Ok(*filtered.iter().max().unwrap()) + } + +} + +fn has_factors(n: i32, min:i32, max:i32)->bool{ + let fac = get_factors(n, min, max); + !fac.is_empty() +} + +fn is_palindrome(s: i32)->bool{ + let s1 = s.to_string(); + let s2 = s1.chars().rev().collect::(); + + s1 == s2 } \ No newline at end of file diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index e0c8093ab..5a6e88d1a 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -1,62 +1,73 @@ extern crate palindrome_products; use palindrome_products::*; +enum GET{ + Smallest, + Largest, +} + +fn test(e: GET, (min, max): (i32, i32))->Result{ + match e{ + GET::Smallest => return get_smallest_palindrome_product(min, max), + GET::Largest => return get_largest_palindrome_product(min, max), + } +} #[test] fn smallest_palindrome_single_digits(){ - assert_eq!(get_palindrome_product(1,9), Ok(1)); + assert_eq!(test(GET::Smallest, (1,9)), Ok(ReturnVals{result: 1, factors: vec!((1,1))})); } #[test] fn largest_palindrome_single_digits(){ - assert_eq!(get_palindrome_product(1,9), Ok(9)); + assert_eq!(test(GET::Largest, (1,9)), Ok(ReturnVals{result: 9, factors: vec!((1,9), (3,3))})); } #[test] fn smallest_palindrome_double_digits(){ - assert_eq!(get_palindrome_product(10,99), Ok(121)); + assert_eq!(test(GET::Smallest, (10,99)), Ok(ReturnVals{result: 121, factors: vec!((11,11))})) } #[test] fn largest_palindrome_double_digits(){ - assert_eq!(get_palindrome_product(10,99), Ok(9009)); + assert_eq!(test(GET::Largest, (10,99)), Ok(ReturnVals{result: 9009, factors: vec!((91,99))})) } #[test] fn smallest_palindrome_triple_digits(){ - assert_eq!(get_palindrome_product(100,999), Ok(10201)); + assert_eq!(test(GET::Smallest, (100,999)), Ok(ReturnVals{result: 10201, factors: vec!((101,101))})) } #[test] fn largest_palindrome_triple_digits(){ - assert_eq!(get_palindrome_product(100,999), Ok(906609)); + assert_eq!(test(GET::Largest, (100,999)), Ok(ReturnVals{result: 906609, factors: vec!((913,993))})) } #[test] fn smallest_palindrome_four_digits(){ - assert_eq!(get_palindrome_product(1000,9999), Ok(1002001)); + assert_eq!(test(GET::Smallest, (1000,9999)), Ok(ReturnVals{result: 1002001, factors: vec!((1001,1001))})) } #[test] fn largest_palindrome_four_digits(){ - assert_eq!(get_palindrome_product(1000,9999), Ok(99000099)); + assert_eq!(test(GET::Largest, (1000,9999)), Ok(ReturnVals{result: 99000099, factors: vec!((9901,9999))})) } #[test] fn empty_result_for_smallest_palindrome(){ - assert_eq!(get_palindrome_product(1002, 1003), Err(Error::Empty)); + assert_eq!(test(GET::Smallest, (1002,1003)), Err(Error::Empty)); } #[test] fn empty_result_for_largest_palindrome(){ - assert_eq!(get_palindrome_product(15, 15), Err(Error::Empty)); + assert_eq!(test(GET::Largest, (15,15)), Err(Error::Empty)); } #[test] fn error_smallest_palindrome_when_min_bt_max(){ - assert_eq!(get_palindrome_product(1000, 1), Err(Error::RangeFailure)); + assert_eq!(test(GET::Smallest, (1000,1)), Err(Error::RangeFailure)); } #[test] fn error_largest_palindrome_when_min_bt_max(){ - assert_eq!(get_palindrome_product(2, 1), Err(Error::RangeFailure)); -} \ No newline at end of file + assert_eq!(test(GET::Largest, (2,1)), Err(Error::RangeFailure)); +} From e8f28f14631492345c6a02cd4cee1d33d95aba98 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Sun, 15 Apr 2018 22:20:51 +0200 Subject: [PATCH 06/24] register exercise in config.json - move ref solution from lib to example.rs --- config.json | 10 +++ exercises/palindrome-products/example.rs | 95 ++++++++++++++++++++++++ exercises/palindrome-products/src/lib.rs | 95 ------------------------ 3 files changed, 105 insertions(+), 95 deletions(-) diff --git a/config.json b/config.json index 92ffe5629..eb618303e 100644 --- a/config.json +++ b/config.json @@ -925,6 +925,16 @@ "Generics" ] }, + { + "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", + "slug": "palindrome-products", + "core": false, + "unlocked_by": null, + "topics": [ + "string comparison", + "calculation" + ] + }, { "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c", "slug": "react", diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs index e69de29bb..83100e0de 100644 --- a/exercises/palindrome-products/example.rs +++ b/exercises/palindrome-products/example.rs @@ -0,0 +1,95 @@ +#[derive(Debug, PartialEq)] +pub enum Error{ + Empty, + RangeFailure, +} + +#[allow(dead_code)] +#[derive(Debug, PartialEq)] +pub struct ReturnVals{ + pub result: i32, + pub factors: Vec<(i32, i32)>, +} + +pub fn get_smallest_palindrome_product(min: i32, max: i32) -> Result{ + if min > max{ + return Err(Error::RangeFailure); + } + + let palindrome: Result = get_smallest_palindrome(min, max); + if palindrome.is_err(){ + return Err(palindrome.unwrap_err()); + } + let p = palindrome.unwrap(); + Ok(ReturnVals{ + result: p, + factors: get_factors(p, min, max), + }) +} + +pub fn get_largest_palindrome_product(min: i32, max: i32) -> Result{ + if min > max{ + return Err(Error::RangeFailure); + } + + let palindrome: Result = get_largest_palindrome(min, max); + if palindrome.is_err(){ + return Err(palindrome.unwrap_err()); + } + let p = palindrome.unwrap(); + Ok(ReturnVals{ + result: p, + factors: get_factors(p, min, max), + }) +} + +fn get_factors(n: i32, min: i32, max:i32)-> Vec<(i32, i32)>{ + let mut factors = Vec::new(); + + for number in min .. max{ + let div = n/number; + if n % number == 0 && div <= max && div >= min && !factors.contains(&(div, number)){ + factors.push((number, n/number)); + } + } + factors +} + +fn get_smallest_palindrome(min: i32, max:i32)-> Result{ + let l:Vec = (min*min .. max*max).collect(); + let filtered: Vec = l.iter() + .cloned() + .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) + .collect::>(); + if filtered.is_empty(){ + return Err(Error::Empty); + } else{ + Ok(*filtered.iter().min().unwrap()) + } +} + +fn get_largest_palindrome(min: i32, max:i32)-> Result{ + let l:Vec = (min*min .. max*max).collect(); + let filtered: Vec = l.iter() + .cloned() + .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) + .collect::>(); + if filtered.is_empty(){ + return Err(Error::Empty); + } else{ + Ok(*filtered.iter().max().unwrap()) + } + +} + +fn has_factors(n: i32, min:i32, max:i32)->bool{ + let fac = get_factors(n, min, max); + !fac.is_empty() +} + +fn is_palindrome(s: i32)->bool{ + let s1 = s.to_string(); + let s2 = s1.chars().rev().collect::(); + + s1 == s2 +} \ No newline at end of file diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 83100e0de..e69de29bb 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -1,95 +0,0 @@ -#[derive(Debug, PartialEq)] -pub enum Error{ - Empty, - RangeFailure, -} - -#[allow(dead_code)] -#[derive(Debug, PartialEq)] -pub struct ReturnVals{ - pub result: i32, - pub factors: Vec<(i32, i32)>, -} - -pub fn get_smallest_palindrome_product(min: i32, max: i32) -> Result{ - if min > max{ - return Err(Error::RangeFailure); - } - - let palindrome: Result = get_smallest_palindrome(min, max); - if palindrome.is_err(){ - return Err(palindrome.unwrap_err()); - } - let p = palindrome.unwrap(); - Ok(ReturnVals{ - result: p, - factors: get_factors(p, min, max), - }) -} - -pub fn get_largest_palindrome_product(min: i32, max: i32) -> Result{ - if min > max{ - return Err(Error::RangeFailure); - } - - let palindrome: Result = get_largest_palindrome(min, max); - if palindrome.is_err(){ - return Err(palindrome.unwrap_err()); - } - let p = palindrome.unwrap(); - Ok(ReturnVals{ - result: p, - factors: get_factors(p, min, max), - }) -} - -fn get_factors(n: i32, min: i32, max:i32)-> Vec<(i32, i32)>{ - let mut factors = Vec::new(); - - for number in min .. max{ - let div = n/number; - if n % number == 0 && div <= max && div >= min && !factors.contains(&(div, number)){ - factors.push((number, n/number)); - } - } - factors -} - -fn get_smallest_palindrome(min: i32, max:i32)-> Result{ - let l:Vec = (min*min .. max*max).collect(); - let filtered: Vec = l.iter() - .cloned() - .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) - .collect::>(); - if filtered.is_empty(){ - return Err(Error::Empty); - } else{ - Ok(*filtered.iter().min().unwrap()) - } -} - -fn get_largest_palindrome(min: i32, max:i32)-> Result{ - let l:Vec = (min*min .. max*max).collect(); - let filtered: Vec = l.iter() - .cloned() - .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) - .collect::>(); - if filtered.is_empty(){ - return Err(Error::Empty); - } else{ - Ok(*filtered.iter().max().unwrap()) - } - -} - -fn has_factors(n: i32, min:i32, max:i32)->bool{ - let fac = get_factors(n, min, max); - !fac.is_empty() -} - -fn is_palindrome(s: i32)->bool{ - let s1 = s.to_string(); - let s2 = s1.chars().rev().collect::(); - - s1 == s2 -} \ No newline at end of file From 73fc7ff22bd8ad5277fc78965d9565cd15a3bb97 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Mon, 16 Apr 2018 15:08:27 +0200 Subject: [PATCH 07/24] remove README.MD --- exercises/palindrome-products/README.MD | 66 ------------------------- 1 file changed, 66 deletions(-) delete mode 100644 exercises/palindrome-products/README.MD diff --git a/exercises/palindrome-products/README.MD b/exercises/palindrome-products/README.MD deleted file mode 100644 index 2898b8660..000000000 --- a/exercises/palindrome-products/README.MD +++ /dev/null @@ -1,66 +0,0 @@ -# Palindrome Products -Detect palindrome products in a given range. - -A palindromic number is a number that remains the same when its digits are -reversed. For example, `121` is a palindromic number but `112` is not. - -Given a range of numbers, find the largest and smallest palindromes which -are products of numbers within that range. - -Your solution should return the largest and smallest palindromes, along with the -factors of each within the range. If the largest or smallest palindrome has more -than one pair of factors within the range, then return all the pairs. - -## Example 1 - -Given the range `[1, 9]` (both inclusive)... - -And given the list of all possible products within this range: -`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]` - -The palindrome products are all single digit numbers (in this case): -`[1, 2, 3, 4, 5, 6, 7, 8, 9]` - -The smallest palindrome product is `1`. Its factors are `(1, 1)`. -The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`. - -## Example 2 - -Given the range `[10, 99]` (both inclusive)... - -The smallest palindrome product is `121`. Its factors are `(11, 11)`. -The largest palindrome product is `9009`. Its factors are `(91, 99)`. - -## Rust Installation -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Writing the Code - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests -to pass again. The test file is located in the `tests` directory. You can -also remove the ignore flag from all the tests to get them to run all at once -if you wish. - -Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you -haven't already, it will help you with organizing your files. - -## Feedback, Issues, Pull Requests - -The [exercism/rust](https://github.com/exercism/rust) repository on 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](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md). - -[help-page]: http://exercism.io/languages/rust -[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html -[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. \ No newline at end of file From 32a0dcb08288fa3e48084b15d9e7be21c0c620f1 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Mon, 16 Apr 2018 15:08:59 +0200 Subject: [PATCH 08/24] add README.md --- exercises/palindrome-products/README.md | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 exercises/palindrome-products/README.md diff --git a/exercises/palindrome-products/README.md b/exercises/palindrome-products/README.md new file mode 100644 index 000000000..2898b8660 --- /dev/null +++ b/exercises/palindrome-products/README.md @@ -0,0 +1,66 @@ +# Palindrome Products +Detect palindrome products in a given range. + +A palindromic number is a number that remains the same when its digits are +reversed. For example, `121` is a palindromic number but `112` is not. + +Given a range of numbers, find the largest and smallest palindromes which +are products of numbers within that range. + +Your solution should return the largest and smallest palindromes, along with the +factors of each within the range. If the largest or smallest palindrome has more +than one pair of factors within the range, then return all the pairs. + +## Example 1 + +Given the range `[1, 9]` (both inclusive)... + +And given the list of all possible products within this range: +`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]` + +The palindrome products are all single digit numbers (in this case): +`[1, 2, 3, 4, 5, 6, 7, 8, 9]` + +The smallest palindrome product is `1`. Its factors are `(1, 1)`. +The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`. + +## Example 2 + +Given the range `[10, 99]` (both inclusive)... + +The smallest palindrome product is `121`. Its factors are `(11, 11)`. +The largest palindrome product is `9009`. Its factors are `(91, 99)`. + +## Rust Installation +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Writing the Code + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests +to pass again. The test file is located in the `tests` directory. You can +also remove the ignore flag from all the tests to get them to run all at once +if you wish. + +Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you +haven't already, it will help you with organizing your files. + +## Feedback, Issues, Pull Requests + +The [exercism/rust](https://github.com/exercism/rust) repository on 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](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md). + +[help-page]: http://exercism.io/languages/rust +[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html +[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. \ No newline at end of file From 6ac02e16fcf01688af05bc7206028880eee76acc Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Mon, 16 Apr 2018 15:13:03 +0200 Subject: [PATCH 09/24] add ignore attributes --- .../palindrome-products/tests/palindrome-products.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 5a6e88d1a..576a09f16 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -18,56 +18,67 @@ fn smallest_palindrome_single_digits(){ } #[test] +#[ignore] fn largest_palindrome_single_digits(){ assert_eq!(test(GET::Largest, (1,9)), Ok(ReturnVals{result: 9, factors: vec!((1,9), (3,3))})); } #[test] +#[ignore] fn smallest_palindrome_double_digits(){ assert_eq!(test(GET::Smallest, (10,99)), Ok(ReturnVals{result: 121, factors: vec!((11,11))})) } #[test] +#[ignore] fn largest_palindrome_double_digits(){ assert_eq!(test(GET::Largest, (10,99)), Ok(ReturnVals{result: 9009, factors: vec!((91,99))})) } #[test] +#[ignore] fn smallest_palindrome_triple_digits(){ assert_eq!(test(GET::Smallest, (100,999)), Ok(ReturnVals{result: 10201, factors: vec!((101,101))})) } #[test] +#[ignore] fn largest_palindrome_triple_digits(){ assert_eq!(test(GET::Largest, (100,999)), Ok(ReturnVals{result: 906609, factors: vec!((913,993))})) } #[test] +#[ignore] fn smallest_palindrome_four_digits(){ assert_eq!(test(GET::Smallest, (1000,9999)), Ok(ReturnVals{result: 1002001, factors: vec!((1001,1001))})) } #[test] +#[ignore] fn largest_palindrome_four_digits(){ assert_eq!(test(GET::Largest, (1000,9999)), Ok(ReturnVals{result: 99000099, factors: vec!((9901,9999))})) } #[test] +#[ignore] fn empty_result_for_smallest_palindrome(){ assert_eq!(test(GET::Smallest, (1002,1003)), Err(Error::Empty)); } #[test] +#[ignore] fn empty_result_for_largest_palindrome(){ assert_eq!(test(GET::Largest, (15,15)), Err(Error::Empty)); } #[test] +#[ignore] fn error_smallest_palindrome_when_min_bt_max(){ assert_eq!(test(GET::Smallest, (1000,1)), Err(Error::RangeFailure)); } #[test] +#[ignore] fn error_largest_palindrome_when_min_bt_max(){ assert_eq!(test(GET::Largest, (2,1)), Err(Error::RangeFailure)); } From e6decd8de8a360c973fc268f9bff2f7255308e38 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Mon, 16 Apr 2018 15:45:00 +0200 Subject: [PATCH 10/24] add difficulty to exercise and place it to similar exercises --- config.json | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/config.json b/config.json index eb618303e..cef318402 100644 --- a/config.json +++ b/config.json @@ -767,6 +767,18 @@ "difficulty": 4, "topics": [] }, + { + "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", + "slug": "palindrome-products", + "core": false, + "unlocked_by": null, + "difficulty": 5, + "topics": [ + "string comparison", + "calculation", + "structs" + ] + }, { "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977", "slug": "poker", @@ -925,16 +937,6 @@ "Generics" ] }, - { - "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", - "slug": "palindrome-products", - "core": false, - "unlocked_by": null, - "topics": [ - "string comparison", - "calculation" - ] - }, { "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c", "slug": "react", From 2509fbb5239b24106d846bd93fc42d78e046c29a Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Tue, 17 Apr 2018 17:23:53 +0200 Subject: [PATCH 11/24] add stub in lib.rs --- exercises/palindrome-products/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index e69de29bb..5918f0092 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -0,0 +1,17 @@ +#[derive(Debug, PartialEq)] +pub enum Error{ + Empty, + RangeFailure, +} +#[derive(Debug, PartialEq)] +pub struct ReturnVals{ + pub result: i32, + pub factors: Vec<(i32, i32)>, +} + +pub fn get_smallest_palindrome_product(min: i32, max:i32)->Result{ + unimplemented!(); +} +pub fn get_largest_palindrome_product(min: i32, max: i32)->Result{ + unimplemented!(); +} \ No newline at end of file From 66f082a2f7c05af97a928a16546540e9fa8707d1 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Tue, 17 Apr 2018 18:40:53 +0200 Subject: [PATCH 12/24] fix warnings and add '_' to each argument --- exercises/palindrome-products/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 5918f0092..17b668111 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -9,9 +9,9 @@ pub struct ReturnVals{ pub factors: Vec<(i32, i32)>, } -pub fn get_smallest_palindrome_product(min: i32, max:i32)->Result{ +pub fn get_smallest_palindrome_product(_min: i32, _max:i32)->Result{ unimplemented!(); } -pub fn get_largest_palindrome_product(min: i32, max: i32)->Result{ +pub fn get_largest_palindrome_product(_min: i32, _max: i32)->Result{ unimplemented!(); } \ No newline at end of file From caccc36215b092aef2cdf6e726c480418ff0fe0d Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Tue, 17 Apr 2018 19:04:09 +0200 Subject: [PATCH 13/24] add valid difficulty --- config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.json b/config.json index cef318402..b5677c31d 100644 --- a/config.json +++ b/config.json @@ -772,7 +772,7 @@ "slug": "palindrome-products", "core": false, "unlocked_by": null, - "difficulty": 5, + "difficulty": 4, "topics": [ "string comparison", "calculation", From e0357d566bba4dcdb57d63a66400f9ae4e84c50a Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Tue, 17 Apr 2018 22:11:25 +0200 Subject: [PATCH 14/24] apply configlet fmt --- config.json | 954 ++++++++++++++++++++-------------------- config/maintainers.json | 46 +- 2 files changed, 500 insertions(+), 500 deletions(-) diff --git a/config.json b/config.json index b5677c31d..894d73d9c 100644 --- a/config.json +++ b/config.json @@ -1,968 +1,968 @@ { - "language": "Rust", - "blurb": "Rust is a compiled programming language designed for speed, concurrency, and memory safety. Rust programs can run almost anywhere, from low-power embedded devices to web servers.", "active": true, + "blurb": "Rust is a compiled programming language designed for speed, concurrency, and memory safety. Rust programs can run almost anywhere, from low-power embedded devices to web servers.", "exercises": [ { - "uuid": "13ec1ebe-d71b-436f-ab12-25305e814171", - "slug": "hello-world", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "hello-world", "topics": [ - "println!" - ] + "println" + ], + "unlocked_by": null, + "uuid": "13ec1ebe-d71b-436f-ab12-25305e814171" }, { - "uuid": "f880b1ef-8f66-41f3-bb89-f39a4ed592a2", - "slug": "gigasecond", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "gigasecond", "topics": [ "crates", "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "f880b1ef-8f66-41f3-bb89-f39a4ed592a2" }, { - "uuid": "ef52f576-9c33-4cc1-a018-803ace8897f6", - "slug": "leap", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "leap", "topics": [ - "mathematics", "booleans", - "conditionals" - ] + "conditionals", + "mathematics" + ], + "unlocked_by": null, + "uuid": "ef52f576-9c33-4cc1-a018-803ace8897f6" }, { - "uuid": "2c12be9b-3a02-4161-8eac-050642ad791f", - "slug": "raindrops", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "raindrops", "topics": [ - "case (or `format`)", - "Mutable string" - ] + "case_or_format", + "mutable_string" + ], + "unlocked_by": null, + "uuid": "2c12be9b-3a02-4161-8eac-050642ad791f" }, { - "uuid": "ecf8d1e3-9400-4d1a-8326-2e2820bce024", - "slug": "reverse-string", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "reverse-string", "topics": [ - "String", - "&str", - "Iterator" - ] + "iterator", + "str", + "string" + ], + "unlocked_by": null, + "uuid": "ecf8d1e3-9400-4d1a-8326-2e2820bce024" }, { - "uuid": "ee5048a7-c625-434d-a0a2-4fd54757ee02", - "slug": "nth-prime", "core": false, - "unlocked_by": null, "difficulty": 1, - "topics": [] + "slug": "nth-prime", + "topics": null, + "unlocked_by": null, + "uuid": "ee5048a7-c625-434d-a0a2-4fd54757ee02" }, { - "uuid": "38ef1802-2730-4f94-bafe-d2cd6b3e7f95", - "slug": "bob", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "bob", "topics": [ "chars", - "string functions" - ] + "string_functions" + ], + "unlocked_by": null, + "uuid": "38ef1802-2730-4f94-bafe-d2cd6b3e7f95" }, { - "uuid": "bb42bc3a-139d-4cab-8b3a-2eac2e1b77b6", - "slug": "beer-song", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "beer-song", "topics": [ "case", - "string concatenation", - "vector (optional)", - "loop" - ] + "loop", + "string_concatenation", + "vector_optional" + ], + "unlocked_by": null, + "uuid": "bb42bc3a-139d-4cab-8b3a-2eac2e1b77b6" }, { - "uuid": "504f9033-6433-4508-aebb-60ee77b800b9", - "slug": "proverb", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "proverb", "topics": [ "format" - ] + ], + "unlocked_by": null, + "uuid": "504f9033-6433-4508-aebb-60ee77b800b9" }, { - "uuid": "aee49878-f727-400b-8fb5-eaf83447cf87", - "slug": "difference-of-squares", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "difference-of-squares", "topics": [ "fold", "map" - ] + ], + "unlocked_by": null, + "uuid": "aee49878-f727-400b-8fb5-eaf83447cf87" }, { - "uuid": "be90fe16-9947-45ef-ab8e-eeca4ce3a8c8", - "slug": "sum-of-multiples", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "sum-of-multiples", "topics": [ "algorithm", "borrowing" - ] + ], + "unlocked_by": null, + "uuid": "be90fe16-9947-45ef-ab8e-eeca4ce3a8c8" }, { - "uuid": "9e69dd5d-472d-43d7-a8bb-60e4a7bed175", - "slug": "grains", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "grains", "topics": [ "mathematics", "panic" - ] + ], + "unlocked_by": null, + "uuid": "9e69dd5d-472d-43d7-a8bb-60e4a7bed175" }, { - "uuid": "6e7cac84-99d1-4f9f-b7d6-48ea43024bc0", - "slug": "pythagorean-triplet", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "pythagorean-triplet", "topics": [ "option" - ] + ], + "unlocked_by": null, + "uuid": "6e7cac84-99d1-4f9f-b7d6-48ea43024bc0" }, { - "uuid": "9f649818-0c82-4b79-b912-4d65b9f60e10", - "slug": "prime-factors", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "prime-factors", "topics": [ "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "9f649818-0c82-4b79-b912-4d65b9f60e10" }, { - "uuid": "9de405e1-3a05-43cb-8eb3-00b81a2968e9", - "slug": "series", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "series", "topics": [ - "vectors", - "strings" - ] + "strings", + "vectors" + ], + "unlocked_by": null, + "uuid": "9de405e1-3a05-43cb-8eb3-00b81a2968e9" }, { - "uuid": "e652139e-ff3f-4e03-9810-d21f8b0c9e60", - "slug": "armstrong-numbers", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "armstrong-numbers", "topics": [ "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "e652139e-ff3f-4e03-9810-d21f8b0c9e60" }, { - "uuid": "f9afd650-8103-4373-a284-fa4ecfee7207", - "slug": "collatz-conjecture", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "collatz-conjecture", "topics": [ - "Option" - ] + "option" + ], + "unlocked_by": null, + "uuid": "f9afd650-8103-4373-a284-fa4ecfee7207" }, { - "uuid": "23d82e48-d074-11e7-8fab-cec278b6b50a", - "slug": "diffie-hellman", "core": false, - "unlocked_by": null, "difficulty": 1, + "slug": "diffie-hellman", "topics": [ "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "23d82e48-d074-11e7-8fab-cec278b6b50a" }, { - "uuid": "ccebfa12-d224-11e7-8941-cec278b6b50a", - "slug": "saddle-points", "core": false, - "unlocked_by": null, "difficulty": 3, + "slug": "saddle-points", "topics": [ - "vectors", - "iterators" - ] + "iterators", + "vectors" + ], + "unlocked_by": null, + "uuid": "ccebfa12-d224-11e7-8941-cec278b6b50a" }, { - "uuid": "79613fd8-b7da-11e7-abc4-cec278b6b50a", - "slug": "isogram", "core": false, - "unlocked_by": null, "difficulty": 3, + "slug": "isogram", "topics": [ "chars", "iterators", "strings" - ] + ], + "unlocked_by": null, + "uuid": "79613fd8-b7da-11e7-abc4-cec278b6b50a" }, { - "uuid": "4ba35adb-230b-49a6-adc9-2d3cd9a4c538", - "slug": "say", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "say", "topics": [ - "string concatenation", - "modulus" - ] + "modulus", + "string_concatenation" + ], + "unlocked_by": null, + "uuid": "4ba35adb-230b-49a6-adc9-2d3cd9a4c538" }, { - "uuid": "4dc9b165-792a-4438-be80-df9aab6f6a9c", - "slug": "run-length-encoding", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "run-length-encoding", "topics": [ - "string concatenation", - "conversion between string and int", - "use of primitive char", - "loop" - ] + "conversion_between_string_and_int", + "loop", + "string_concatenation", + "use_of_primitive_char" + ], + "unlocked_by": null, + "uuid": "4dc9b165-792a-4438-be80-df9aab6f6a9c" }, { - "uuid": "c986c240-46de-419c-8ed6-700eb68f8db6", - "slug": "isbn-verifier", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "isbn-verifier", "topics": [ - "conversion between string and int", + "conversion_between_string_and_int", "loop", "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "c986c240-46de-419c-8ed6-700eb68f8db6" }, { - "uuid": "20e7d347-b80a-4656-ac34-0825126939ff", - "slug": "perfect-numbers", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "perfect-numbers", "topics": [ - "Mathematics" - ] + "mathematics" + ], + "unlocked_by": null, + "uuid": "20e7d347-b80a-4656-ac34-0825126939ff" }, { - "uuid": "543a3ca2-fb9b-4f20-a873-ff23595d41df", - "slug": "clock", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "clock", "topics": [ - "traits", "derive", - "struct" - ] + "struct", + "traits" + ], + "unlocked_by": null, + "uuid": "543a3ca2-fb9b-4f20-a873-ff23595d41df" }, { - "uuid": "2874216a-0822-4ec2-892e-d451fd89646a", - "slug": "hamming", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "hamming", "topics": [ - "Result" - ] + "result" + ], + "unlocked_by": null, + "uuid": "2874216a-0822-4ec2-892e-d451fd89646a" }, { - "uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237", - "slug": "simple-linked-list", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "simple-linked-list", "topics": [ "lists", - "type_conversion", - "struct" - ] + "struct", + "type_conversion" + ], + "unlocked_by": null, + "uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237" }, { - "uuid": "ddc0c1da-6b65-4ed1-8bdc-5e71cd05f720", - "slug": "pascals-triangle", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "pascals-triangle", "topics": [ - "Mathematics", - "Vec", - "Index (optional)" - ] + "index_optional", + "mathematics", + "vec" + ], + "unlocked_by": null, + "uuid": "ddc0c1da-6b65-4ed1-8bdc-5e71cd05f720" }, { - "uuid": "561cc4ff-5e74-4701-a7c2-c4edefa0d068", - "slug": "scrabble-score", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "scrabble-score", "topics": [ - "chaining higher-order functions", - "HashMap (optional)" - ] + "chaining_higher_order_functions", + "hashmap_optional" + ], + "unlocked_by": null, + "uuid": "561cc4ff-5e74-4701-a7c2-c4edefa0d068" }, { - "uuid": "a24cb7bf-3aac-4051-bcd1-952c2a806187", - "slug": "pangram", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "pangram", "topics": [ - "filter", - "ascii (optional)" - ] + "ascii_optional", + "filter" + ], + "unlocked_by": null, + "uuid": "a24cb7bf-3aac-4051-bcd1-952c2a806187" }, { - "uuid": "3f54853b-cc65-4282-ab25-8dc3fdf43c03", - "slug": "nucleotide-count", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "nucleotide-count", "topics": [ - "Result", + "entry_api", "filter", - "entry api", + "match", "mutablity", - "match" - ] + "result" + ], + "unlocked_by": null, + "uuid": "3f54853b-cc65-4282-ab25-8dc3fdf43c03" }, { - "uuid": "8d64bfc3-fc4b-45c4-85f0-e74dc2ea6812", - "slug": "luhn", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "luhn", "topics": [ - "str to digits", + "higher_order_functions", "iterators", - "higher-order functions" - ] + "str_to_digits" + ], + "unlocked_by": null, + "uuid": "8d64bfc3-fc4b-45c4-85f0-e74dc2ea6812" }, { - "uuid": "8679c221-d150-4230-b1cd-5ea78ae69db7", - "slug": "largest-series-product", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "largest-series-product", "topics": [ - "Result", - "windows", - "higher-order functions", - "char" - ] + "char", + "higher_order_functions", + "result", + "windows" + ], + "unlocked_by": null, + "uuid": "8679c221-d150-4230-b1cd-5ea78ae69db7" }, { - "uuid": "6c5c0dc3-4f5b-4f83-bf67-a45bf4ea6be4", - "slug": "word-count", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "word-count", "topics": [ - "hashmap", - "str vs string", "chars", - "entry api" - ] + "entry_api", + "hashmap", + "str_vs_string" + ], + "unlocked_by": null, + "uuid": "6c5c0dc3-4f5b-4f83-bf67-a45bf4ea6be4" }, { - "uuid": "53298a14-76a9-4bb9-943a-57c5e79d9cf7", - "slug": "atbash-cipher", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "atbash-cipher", "topics": [ - "str vs string", - "primitive types", - "iterators", + "ascii", "chars", - "ascii" - ] + "iterators", + "primitive_types", + "str_vs_string" + ], + "unlocked_by": null, + "uuid": "53298a14-76a9-4bb9-943a-57c5e79d9cf7" }, { - "uuid": "0cc485e9-43ba-4d97-a622-ee4cb8b9f1f7", - "slug": "crypto-square", "difficulty": 4, + "slug": "crypto-square", "topics": [ - "str vs string", - "primitive types", - "iterators", - "chars", "arrays", "ascii", + "chars", + "iterators", + "primitive_types", + "str_vs_string", "transforming" - ] + ], + "uuid": "0cc485e9-43ba-4d97-a622-ee4cb8b9f1f7" }, { - "uuid": "5dbecc83-2c8d-467d-be05-f28a08f7abcf", - "slug": "rotational-cipher", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "rotational-cipher", "topics": [ - "str vs string", - "primitive types", - "iterators", + "ascii", "chars", - "ascii" - ] + "iterators", + "primitive_types", + "str_vs_string" + ], + "unlocked_by": null, + "uuid": "5dbecc83-2c8d-467d-be05-f28a08f7abcf" }, { - "uuid": "0c8eeef7-4bab-4cf9-9047-c208b5618312", - "slug": "etl", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "etl", "topics": [ "btree" - ] + ], + "unlocked_by": null, + "uuid": "0c8eeef7-4bab-4cf9-9047-c208b5618312" }, { - "uuid": "ddc45979-8a92-4313-a4f8-878562d5a483", - "slug": "accumulate", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "accumulate", "topics": [ - "function pointer" - ] + "function_pointer" + ], + "unlocked_by": null, + "uuid": "ddc45979-8a92-4313-a4f8-878562d5a483" }, { - "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9", - "slug": "acronym", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "acronym", "topics": [ - "map", - "flat_map", "filter", + "flat_map", "loops", - "Vec" - ] + "map", + "vec" + ], + "unlocked_by": null, + "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9" }, { - "uuid": "da784b42-1cec-469e-8e48-0be232b17003", - "slug": "sieve", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "sieve", "topics": [ - "vector", "map", - "while let (optional)" - ] + "vector", + "while_let_optional" + ], + "unlocked_by": null, + "uuid": "da784b42-1cec-469e-8e48-0be232b17003" }, { - "uuid": "9a219d87-cd32-4e12-a879-bfb5747c2369", - "slug": "rna-transcription", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "rna-transcription", "topics": [ - "Result", "match", - "struct", - "str vs string" - ] + "result", + "str_vs_string", + "struct" + ], + "unlocked_by": null, + "uuid": "9a219d87-cd32-4e12-a879-bfb5747c2369" }, { - "uuid": "c0bc2af6-d7af-401f-9ed8-bbe31977666c", - "slug": "triangle", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "triangle", "topics": [ - "Mathematics", - "Struct" - ] + "mathematics", + "struct" + ], + "unlocked_by": null, + "uuid": "c0bc2af6-d7af-401f-9ed8-bbe31977666c" }, { - "uuid": "498be645-734a-49b7-aba7-aae1e051e1f0", - "slug": "roman-numerals", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "roman-numerals", "topics": [ + "loops", "mutable", "results", - "loops", "struct", "traits" - ] + ], + "unlocked_by": null, + "uuid": "498be645-734a-49b7-aba7-aae1e051e1f0" }, { - "uuid": "54c11dae-3878-4bec-b8d6-775b7d4f317b", - "slug": "all-your-base", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "all-your-base", "topics": [ - "Result", "enumerate", "fold", - "map" - ] + "map", + "result" + ], + "unlocked_by": null, + "uuid": "54c11dae-3878-4bec-b8d6-775b7d4f317b" }, { - "uuid": "5ca03812-c229-48db-b7fd-0889b22f8d1d", - "slug": "grade-school", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "grade-school", "topics": [ + "entry_api", + "option", "struct", - "entry api", - "Vec", - "Option" - ] + "vec" + ], + "unlocked_by": null, + "uuid": "5ca03812-c229-48db-b7fd-0889b22f8d1d" }, { - "uuid": "dd74b65c-0d26-4821-9add-064e32e3a5bd", - "slug": "binary-search", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "binary-search", "topics": [ + "option", "slices", - "trait (optional)", - "Option" - ] + "trait_optional" + ], + "unlocked_by": null, + "uuid": "dd74b65c-0d26-4821-9add-064e32e3a5bd" }, { - "uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66", - "slug": "robot-simulator", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "robot-simulator", "topics": [ - "Immutability", - "enum" - ] + "enum", + "immutability" + ], + "unlocked_by": null, + "uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66" }, { - "uuid": "40729822-4265-4c14-b03f-a00bff5f24bb", - "slug": "bracket-push", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "bracket-push", "topics": [ - "From trait", - "stack or recursion" - ] + "from_trait", + "stack_or_recursion" + ], + "unlocked_by": null, + "uuid": "40729822-4265-4c14-b03f-a00bff5f24bb" }, { - "uuid": "f9131b5d-91dd-4514-983d-4abc22bb5d5c", - "slug": "luhn-from", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "luhn-from", "topics": [ - "from trait", - "str to digits", + "from_trait", + "higher_order_functions", "iterators", - "higher-order functions" - ] + "str_to_digits" + ], + "unlocked_by": null, + "uuid": "f9131b5d-91dd-4514-983d-4abc22bb5d5c" }, { - "uuid": "30c33e3d-8034-4618-8346-2ae906961579", - "slug": "queen-attack", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "queen-attack", "topics": [ + "result", "struct", - "trait (optional)", - "Result" - ] + "trait_optional" + ], + "unlocked_by": null, + "uuid": "30c33e3d-8034-4618-8346-2ae906961579" }, { - "uuid": "fec447a5-cf11-4ddd-b0fd-63bcc4e245cd", - "slug": "bowling", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "bowling", "topics": [ - "struct", - "Result", - "goofy bowling logic" - ] + "goofy_bowling_logic", + "result", + "struct" + ], + "unlocked_by": null, + "uuid": "fec447a5-cf11-4ddd-b0fd-63bcc4e245cd" }, { - "uuid": "644ffd17-548e-4405-bfd5-a58df74cc19d", - "slug": "sublist", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "sublist", "topics": [ "enum", - "generic over type" - ] + "generic_over_type" + ], + "unlocked_by": null, + "uuid": "644ffd17-548e-4405-bfd5-a58df74cc19d" }, { - "uuid": "fa94645d-14e1-422d-a832-d24efbb493d8", - "slug": "space-age", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "space-age", "topics": [ - "Custom Trait", - "From Trait", - "Default Trait implementation" - ] + "custom_trait", + "default_trait_implementation", + "from_trait" + ], + "unlocked_by": null, + "uuid": "fa94645d-14e1-422d-a832-d24efbb493d8" }, { - "uuid": "c32c0124-873d-45f4-9287-402aea29f129", - "slug": "luhn-trait", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "luhn-trait", "topics": [ - "Custom Trait", - "str to digits", + "custom_trait", + "higher_order_functions", "iterators", - "higher-order functions" - ] + "str_to_digits" + ], + "unlocked_by": null, + "uuid": "c32c0124-873d-45f4-9287-402aea29f129" }, { - "uuid": "29583cc6-d56d-4bee-847d-93d74e5a30e7", - "slug": "macros", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "macros", "topics": [ + "hashmap", "macros", - "macros-by-example", - "hashmap" - ] + "macros_by_example" + ], + "unlocked_by": null, + "uuid": "29583cc6-d56d-4bee-847d-93d74e5a30e7" }, { - "uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d", - "slug": "allergies", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "allergies", "topics": [ - "struct", + "bitwise_probably", "enum", - "bitwise (probably)", - "vectors", - "filter" - ] + "filter", + "struct", + "vectors" + ], + "unlocked_by": null, + "uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d" }, { - "uuid": "f1371a9c-c2a4-4fc6-a5fd-3a57c4af16fa", - "slug": "variable-length-quantity", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "variable-length-quantity", "topics": [ - "Encodings", - "slices", "bitwise", - "Result" - ] + "encodings", + "result", + "slices" + ], + "unlocked_by": null, + "uuid": "f1371a9c-c2a4-4fc6-a5fd-3a57c4af16fa" }, { - "uuid": "6abac1d1-0d85-4b51-8001-97a07990630d", - "slug": "phone-number", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "phone-number", "topics": [ - "option", "format", - "unwrap_or", "iters", - "match" - ] + "match", + "option", + "unwrap_or" + ], + "unlocked_by": null, + "uuid": "6abac1d1-0d85-4b51-8001-97a07990630d" }, { - "uuid": "620b55bb-058e-4c6f-a966-ced3b41736db", - "slug": "wordy", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "wordy", "topics": [ - "Result", - "string parsing", - "operators (optional)" - ] + "operators_optional", + "result", + "string_parsing" + ], + "unlocked_by": null, + "uuid": "620b55bb-058e-4c6f-a966-ced3b41736db" }, { - "uuid": "9a2406cc-5037-4761-b820-bb25b1d397c8", - "slug": "tournament", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "tournament", "topics": [ "enum", - "sorting", "hashmap", + "sorting", "structs" - ] + ], + "unlocked_by": null, + "uuid": "9a2406cc-5037-4761-b820-bb25b1d397c8" }, { - "uuid": "9d652e63-6654-4dec-a99f-97e6bc8cf772", - "slug": "custom-set", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "custom-set", "topics": [ - "generic over type", - "vector", "equality", - "struct" - ] + "generic_over_type", + "struct", + "vector" + ], + "unlocked_by": null, + "uuid": "9d652e63-6654-4dec-a99f-97e6bc8cf772" }, { - "uuid": "7450bd80-2388-42ac-a61f-097e82581475", - "slug": "alphametics", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "alphametics", "topics": [ - "string parsing", "combinations", + "external_crates_optional", "mathematics", - "external crates (optional)" - ] + "string_parsing" + ], + "unlocked_by": null, + "uuid": "7450bd80-2388-42ac-a61f-097e82581475" }, { - "uuid": "1850fb3f-9dad-449a-90b6-9d90038cf34d", - "slug": "two-bucket", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "two-bucket", "topics": [ "algorithm", "loops", "mathematics" - ] + ], + "unlocked_by": null, + "uuid": "1850fb3f-9dad-449a-90b6-9d90038cf34d" }, { - "uuid": "c21c379b-fb23-449b-809a-3c6ef1c31221", - "slug": "pig-latin", "core": false, - "unlocked_by": null, "difficulty": 4, - "topics": [] + "slug": "pig-latin", + "topics": null, + "unlocked_by": null, + "uuid": "c21c379b-fb23-449b-809a-3c6ef1c31221" }, { - "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", - "slug": "palindrome-products", "core": false, - "unlocked_by": null, "difficulty": 4, + "slug": "palindrome-products", "topics": [ - "string comparison", "calculation", + "string_comparison", "structs" - ] + ], + "unlocked_by": null, + "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55" }, { - "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977", - "slug": "poker", "core": false, - "unlocked_by": null, "difficulty": 6, + "slug": "poker", "topics": [ + "enum", "lifetimes", + "string_parsing", "struct", - "string parsing", - "enum", "traits" - ] + ], + "unlocked_by": null, + "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977" }, { - "uuid": "7cefed7c-37f4-46c5-9a45-68fe4d0fb326", - "slug": "decimal", "core": false, - "unlocked_by": null, "difficulty": 6, + "slug": "decimal", "topics": [ - "struct", - "traits", - "string parsing", "bigint", - "external crates (optional)" - ] + "external_crates_optional", + "string_parsing", + "struct", + "traits" + ], + "unlocked_by": null, + "uuid": "7cefed7c-37f4-46c5-9a45-68fe4d0fb326" }, { - "uuid": "f3172997-91f5-4941-a76e-91c4b8eed401", - "slug": "anagram", "core": false, - "unlocked_by": null, "difficulty": 7, + "slug": "anagram", "topics": [ + "iter", "lifetimes", - "str vs string", "loops", - "iter", + "str_vs_string", "vector" - ] + ], + "unlocked_by": null, + "uuid": "f3172997-91f5-4941-a76e-91c4b8eed401" }, { - "uuid": "4e01efbc-51ce-4d20-b093-b3d44c4be5e8", - "slug": "protein-translation", "core": false, - "unlocked_by": null, "difficulty": 7, + "slug": "protein-translation", "topics": [ - "struct", - "hash map", + "hash_map", "lifetimes", - "Result" - ] + "result", + "struct" + ], + "unlocked_by": null, + "uuid": "4e01efbc-51ce-4d20-b093-b3d44c4be5e8" }, { - "uuid": "ec7f66c2-749e-4d00-9c11-fa9d106632e4", - "slug": "robot-name", "core": false, - "unlocked_by": null, "difficulty": 7, + "slug": "robot-name", "topics": [ - "struct", - "slices", - "randomness", "lifetimes", - "self mut" - ] + "randomness", + "self_mut", + "slices", + "struct" + ], + "unlocked_by": null, + "uuid": "ec7f66c2-749e-4d00-9c11-fa9d106632e4" }, { - "uuid": "a78ed17a-b2c0-485c-814b-e13ccd1f4153", - "slug": "book-store", "core": false, - "unlocked_by": null, "difficulty": 7, + "slug": "book-store", "topics": [ "algorithms", "groups", - "set theory" - ] + "set_theory" + ], + "unlocked_by": null, + "uuid": "a78ed17a-b2c0-485c-814b-e13ccd1f4153" }, { - "uuid": "704aab91-b83a-4e64-8c21-fb0be5076289", - "slug": "ocr-numbers", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "ocr-numbers", "topics": [ - "Lines", - "Chunks", + "chunks", + "lines", "slices" - ] + ], + "unlocked_by": null, + "uuid": "704aab91-b83a-4e64-8c21-fb0be5076289" }, { - "uuid": "e0037ac4-ae5f-4622-b3ad-915648263495", - "slug": "minesweeper", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "minesweeper", "topics": [ - "Board state" - ] + "board_state" + ], + "unlocked_by": null, + "uuid": "e0037ac4-ae5f-4622-b3ad-915648263495" }, { - "uuid": "5e6f6986-5011-427b-a992-d6d0c81f5101", - "slug": "dominoes", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "dominoes", "topics": [ - "Graph theory", + "graph_theory", "searching" - ] + ], + "unlocked_by": null, + "uuid": "5e6f6986-5011-427b-a992-d6d0c81f5101" }, { - "uuid": "e114b19f-9a9a-402d-a5cb-1cad8de5088e", - "slug": "parallel-letter-frequency", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "parallel-letter-frequency", "topics": [ - "multi-threading" - ] + "multi_threading" + ], + "unlocked_by": null, + "uuid": "e114b19f-9a9a-402d-a5cb-1cad8de5088e" }, { - "uuid": "cc4ccd99-1c97-4ee7-890c-d629b4e1e46d", - "slug": "rectangles", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "rectangles", "topics": [ - "Enum", + "algorithm", + "enum", "structs", - "traits", - "algorithm" - ] + "traits" + ], + "unlocked_by": null, + "uuid": "cc4ccd99-1c97-4ee7-890c-d629b4e1e46d" }, { - "uuid": "55976c49-1be5-4170-8aa3-056c2223abbb", - "slug": "forth", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "forth", "topics": [ - "Parser reimplementation" - ] + "parser_reimplementation" + ], + "unlocked_by": null, + "uuid": "55976c49-1be5-4170-8aa3-056c2223abbb" }, { - "uuid": "6ff1a539-251b-49d4-81b5-a6b1e9ba66a4", - "slug": "circular-buffer", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "circular-buffer", "topics": [ - "Buffer reimplementation", - "Generics" - ] + "buffer_reimplementation", + "generics" + ], + "unlocked_by": null, + "uuid": "6ff1a539-251b-49d4-81b5-a6b1e9ba66a4" }, { - "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c", - "slug": "react", "core": false, - "unlocked_by": null, "difficulty": 10, + "slug": "react", "topics": [ - "Lifetimes", + "closures", "generics", - "closures" - ] + "lifetimes" + ], + "unlocked_by": null, + "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c" }, { - "uuid": "8dae8f4d-368d-477d-907e-bf746921bfbf", + "deprecated": true, "slug": "nucleotide-codons", - "deprecated": true + "uuid": "8dae8f4d-368d-477d-907e-bf746921bfbf" }, { - "uuid": "496fd79f-1678-4aa2-8110-c32c6aaf545e", + "deprecated": true, "slug": "hexadecimal", - "deprecated": true + "uuid": "496fd79f-1678-4aa2-8110-c32c6aaf545e" } ], "foregone": [ "binary", "octal", "trinary" - ] -} + ], + "language": "Rust" +} \ No newline at end of file diff --git a/config/maintainers.json b/config/maintainers.json index ee1ef7ffb..7a62da5cd 100644 --- a/config/maintainers.json +++ b/config/maintainers.json @@ -1,59 +1,59 @@ { "maintainers": [ { - "github_username": "IanWhitney", - "show_on_website": false, "alumnus": false, - "name": null, + "avatar_url": null, "bio": null, + "github_username": "IanWhitney", "link_text": null, "link_url": null, - "avatar_url": null + "name": null, + "show_on_website": false }, { + "alumnus": true, "github_username": "etrepum", - "show_on_website": false, - "alumnus": true + "show_on_website": false }, { - "github_username": "ijanos", - "show_on_website": false, "alumnus": false, - "name": null, + "avatar_url": null, "bio": null, + "github_username": "ijanos", "link_text": null, "link_url": null, - "avatar_url": null + "name": null, + "show_on_website": false }, { - "github_username": "petertseng", - "show_on_website": false, "alumnus": false, - "name": null, + "avatar_url": null, "bio": null, + "github_username": "petertseng", "link_text": null, "link_url": null, - "avatar_url": null + "name": null, + "show_on_website": false }, { - "github_username": "EduardoBautista", - "show_on_website": false, "alumnus": false, - "name": null, + "avatar_url": null, "bio": null, + "github_username": "EduardoBautista", "link_text": null, "link_url": null, - "avatar_url": null + "name": null, + "show_on_website": false }, { - "github_username": "coriolinus", - "show_on_website": false, "alumnus": false, - "name": null, + "avatar_url": null, "bio": null, + "github_username": "coriolinus", "link_text": null, "link_url": null, - "avatar_url": null + "name": null, + "show_on_website": false } ] -} +} \ No newline at end of file From 6d6cd51402f0597f55acc596a18b2bfe0bcfdef0 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Tue, 17 Apr 2018 22:11:42 +0200 Subject: [PATCH 15/24] add generated readme --- exercises/palindrome-products/README.md | 138 ++++++++++++------------ 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/exercises/palindrome-products/README.md b/exercises/palindrome-products/README.md index 2898b8660..0b8520188 100644 --- a/exercises/palindrome-products/README.md +++ b/exercises/palindrome-products/README.md @@ -1,66 +1,72 @@ -# Palindrome Products -Detect palindrome products in a given range. - -A palindromic number is a number that remains the same when its digits are -reversed. For example, `121` is a palindromic number but `112` is not. - -Given a range of numbers, find the largest and smallest palindromes which -are products of numbers within that range. - -Your solution should return the largest and smallest palindromes, along with the -factors of each within the range. If the largest or smallest palindrome has more -than one pair of factors within the range, then return all the pairs. - -## Example 1 - -Given the range `[1, 9]` (both inclusive)... - -And given the list of all possible products within this range: -`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]` - -The palindrome products are all single digit numbers (in this case): -`[1, 2, 3, 4, 5, 6, 7, 8, 9]` - -The smallest palindrome product is `1`. Its factors are `(1, 1)`. -The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`. - -## Example 2 - -Given the range `[10, 99]` (both inclusive)... - -The smallest palindrome product is `121`. Its factors are `(11, 11)`. -The largest palindrome product is `9009`. Its factors are `(91, 99)`. - -## Rust Installation -Refer to the [exercism help page][help-page] for Rust installation and learning -resources. - -## Writing the Code - -Execute the tests with: - -```bash -$ cargo test -``` - -All but the first test have been ignored. After you get the first test to -pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests -to pass again. The test file is located in the `tests` directory. You can -also remove the ignore flag from all the tests to get them to run all at once -if you wish. - -Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you -haven't already, it will help you with organizing your files. - -## Feedback, Issues, Pull Requests - -The [exercism/rust](https://github.com/exercism/rust) repository on 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](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md). - -[help-page]: http://exercism.io/languages/rust -[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html -[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. \ No newline at end of file +# Palindrome Products + +Detect palindrome products in a given range. + +A palindromic number is a number that remains the same when its digits are +reversed. For example, `121` is a palindromic number but `112` is not. + +Given a range of numbers, find the largest and smallest palindromes which +are products of numbers within that range. + +Your solution should return the largest and smallest palindromes, along with the +factors of each within the range. If the largest or smallest palindrome has more +than one pair of factors within the range, then return all the pairs. + +## Example 1 + +Given the range `[1, 9]` (both inclusive)... + +And given the list of all possible products within this range: +`[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81]` + +The palindrome products are all single digit numbers (in this case): +`[1, 2, 3, 4, 5, 6, 7, 8, 9]` + +The smallest palindrome product is `1`. Its factors are `(1, 1)`. +The largest palindrome product is `9`. Its factors are `(1, 9)` and `(3, 3)`. + +## Example 2 + +Given the range `[10, 99]` (both inclusive)... + +The smallest palindrome product is `121`. Its factors are `(11, 11)`. +The largest palindrome product is `9009`. Its factors are `(91, 99)`. + +## Rust Installation + +Refer to the [exercism help page][help-page] for Rust installation and learning +resources. + +## Writing the Code + +Execute the tests with: + +```bash +$ cargo test +``` + +All but the first test have been ignored. After you get the first test to +pass, remove the ignore flag (`#[ignore]`) from the next test and get the tests +to pass again. The test file is located in the `tests` directory. You can +also remove the ignore flag from all the tests to get them to run all at once +if you wish. + +Make sure to read the [Modules](https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html) chapter if you +haven't already, it will help you with organizing your files. + +## Feedback, Issues, Pull Requests + +The [exercism/rust](https://github.com/exercism/rust) repository on 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](https://github.com/exercism/docs/blob/master/contributing-to-language-tracks/README.md). + +[help-page]: http://exercism.io/languages/rust +[modules]: https://doc.rust-lang.org/book/second-edition/ch07-00-modules.html +[cargo]: https://doc.rust-lang.org/book/second-edition/ch14-00-more-about-cargo.html + +## Source + +Problem 4 at Project Euler [http://projecteuler.net/problem=4](http://projecteuler.net/problem=4) + +## Submitting Incomplete Solutions +It's possible to submit an incomplete solution so you can see how others have completed the exercise. From 9ffc8f68e082a4ebb9ec6b6fbcbfabc58b8b7959 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Wed, 18 Apr 2018 22:44:59 +0200 Subject: [PATCH 16/24] set cooresponding version from canonical --- exercises/palindrome-products/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/palindrome-products/Cargo.toml b/exercises/palindrome-products/Cargo.toml index 9fec34052..0fc8ac2a9 100644 --- a/exercises/palindrome-products/Cargo.toml +++ b/exercises/palindrome-products/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "palindrome-products" -version = "0.1.0" +version = "1.1.0" authors = ["Kirill Meng "] [dependencies] From 766f91d297c41af5cc131ca93343be5fa61aae9d Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Thu, 19 Apr 2018 10:21:07 +0200 Subject: [PATCH 17/24] apply new api on example.rs - change correspondongin tests - apply api in lib.rs and reference method arugments to avoid '_' --- exercises/palindrome-products/example.rs | 100 ++++-------------- exercises/palindrome-products/src/lib.rs | 21 ++-- .../tests/palindrome-products.rs | 64 +++++------ 3 files changed, 53 insertions(+), 132 deletions(-) diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs index 83100e0de..22fd32833 100644 --- a/exercises/palindrome-products/example.rs +++ b/exercises/palindrome-products/example.rs @@ -1,93 +1,31 @@ -#[derive(Debug, PartialEq)] -pub enum Error{ - Empty, - RangeFailure, -} - -#[allow(dead_code)] -#[derive(Debug, PartialEq)] -pub struct ReturnVals{ - pub result: i32, - pub factors: Vec<(i32, i32)>, -} - -pub fn get_smallest_palindrome_product(min: i32, max: i32) -> Result{ - if min > max{ - return Err(Error::RangeFailure); - } - - let palindrome: Result = get_smallest_palindrome(min, max); - if palindrome.is_err(){ - return Err(palindrome.unwrap_err()); +pub type Palindrome = u64; +pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ + let mut palindromes:Vec = Vec::new(); + for i in min..max+1{ + for j in min..max+1{ + if is_palindrome(i*j){ + palindromes.push(i*j); + } + } } - let p = palindrome.unwrap(); - Ok(ReturnVals{ - result: p, - factors: get_factors(p, min, max), - }) + palindromes } -pub fn get_largest_palindrome_product(min: i32, max: i32) -> Result{ - if min > max{ - return Err(Error::RangeFailure); - } - - let palindrome: Result = get_largest_palindrome(min, max); - if palindrome.is_err(){ - return Err(palindrome.unwrap_err()); +pub fn min(palindromes: Vec)->Option{ + if palindromes.is_empty(){ + return None; } - let p = palindrome.unwrap(); - Ok(ReturnVals{ - result: p, - factors: get_factors(p, min, max), - }) + palindromes.iter().cloned().min() } -fn get_factors(n: i32, min: i32, max:i32)-> Vec<(i32, i32)>{ - let mut factors = Vec::new(); - - for number in min .. max{ - let div = n/number; - if n % number == 0 && div <= max && div >= min && !factors.contains(&(div, number)){ - factors.push((number, n/number)); - } +pub fn max(palindromes: Vec)->Option{ + if palindromes.is_empty(){ + return None; } - factors -} - -fn get_smallest_palindrome(min: i32, max:i32)-> Result{ - let l:Vec = (min*min .. max*max).collect(); - let filtered: Vec = l.iter() - .cloned() - .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) - .collect::>(); - if filtered.is_empty(){ - return Err(Error::Empty); - } else{ - Ok(*filtered.iter().min().unwrap()) - } -} - -fn get_largest_palindrome(min: i32, max:i32)-> Result{ - let l:Vec = (min*min .. max*max).collect(); - let filtered: Vec = l.iter() - .cloned() - .filter(|n| is_palindrome(*n) && has_factors(*n, min, max)) - .collect::>(); - if filtered.is_empty(){ - return Err(Error::Empty); - } else{ - Ok(*filtered.iter().max().unwrap()) - } - -} - -fn has_factors(n: i32, min:i32, max:i32)->bool{ - let fac = get_factors(n, min, max); - !fac.is_empty() + palindromes.iter().cloned().max() } -fn is_palindrome(s: i32)->bool{ +fn is_palindrome(s: u64)->bool{ let s1 = s.to_string(); let s2 = s1.chars().rev().collect::(); diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 17b668111..d9760c3a3 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -1,17 +1,12 @@ -#[derive(Debug, PartialEq)] -pub enum Error{ - Empty, - RangeFailure, -} -#[derive(Debug, PartialEq)] -pub struct ReturnVals{ - pub result: i32, - pub factors: Vec<(i32, i32)>, +pub type Palindrome = u64; +pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ + unimplemented!("Find all palindromic numbers which are products of numbers in the inclusive range ({}..{})", min, max) } -pub fn get_smallest_palindrome_product(_min: i32, _max:i32)->Result{ - unimplemented!(); +pub fn min(palindromes: Vec)->Option{ + unimplemented!("Return the palindrome of minimal value from the supplied list: {:?}", palindromes) } -pub fn get_largest_palindrome_product(_min: i32, _max: i32)->Result{ - unimplemented!(); + +pub fn max(palindromes: Vec)->Option{ + unimplemented!("Return the palindrome of maximal value from the supplied list: {:?}", palindromes) } \ No newline at end of file diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 576a09f16..00dc3cfaf 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -1,84 +1,72 @@ extern crate palindrome_products; use palindrome_products::*; -enum GET{ - Smallest, - Largest, -} - -fn test(e: GET, (min, max): (i32, i32))->Result{ - match e{ - GET::Smallest => return get_smallest_palindrome_product(min, max), - GET::Largest => return get_largest_palindrome_product(min, max), - } -} #[test] -fn smallest_palindrome_single_digits(){ - assert_eq!(test(GET::Smallest, (1,9)), Ok(ReturnVals{result: 1, factors: vec!((1,1))})); +#[ignore] +fn empty_result_for_smallest_palindrome(){ + assert_eq!(min(get_palindrome_products(1002, 1003)), None); } #[test] #[ignore] -fn largest_palindrome_single_digits(){ - assert_eq!(test(GET::Largest, (1,9)), Ok(ReturnVals{result: 9, factors: vec!((1,9), (3,3))})); +fn empty_result_for_largest_palindrome(){ + assert_eq!(max(get_palindrome_products(15, 15)), None); } #[test] #[ignore] -fn smallest_palindrome_double_digits(){ - assert_eq!(test(GET::Smallest, (10,99)), Ok(ReturnVals{result: 121, factors: vec!((11,11))})) +fn error_smallest_palindrome_when_min_gt_max(){ + assert_eq!(min(get_palindrome_products(1000, 1)), None); } #[test] #[ignore] -fn largest_palindrome_double_digits(){ - assert_eq!(test(GET::Largest, (10,99)), Ok(ReturnVals{result: 9009, factors: vec!((91,99))})) +fn error_largest_palindrome_when_min_st_max(){ + assert_eq!(max(get_palindrome_products(2, 1)), None); } #[test] -#[ignore] -fn smallest_palindrome_triple_digits(){ - assert_eq!(test(GET::Smallest, (100,999)), Ok(ReturnVals{result: 10201, factors: vec!((101,101))})) +fn smallest_palindrome_single_digits(){ + assert_eq!(min(get_palindrome_products(1, 9)), Some(1)); } #[test] #[ignore] -fn largest_palindrome_triple_digits(){ - assert_eq!(test(GET::Largest, (100,999)), Ok(ReturnVals{result: 906609, factors: vec!((913,993))})) +fn largest_palindrome_single_digits(){ + assert_eq!(max(get_palindrome_products(1, 9)), Some(9)); } - #[test] #[ignore] -fn smallest_palindrome_four_digits(){ - assert_eq!(test(GET::Smallest, (1000,9999)), Ok(ReturnVals{result: 1002001, factors: vec!((1001,1001))})) +fn smallest_palindrome_double_digits(){ + assert_eq!(min(get_palindrome_products(10, 99)), Some(121)); } #[test] #[ignore] -fn largest_palindrome_four_digits(){ - assert_eq!(test(GET::Largest, (1000,9999)), Ok(ReturnVals{result: 99000099, factors: vec!((9901,9999))})) +fn largest_palindrome_double_digits(){ + assert_eq!(max(get_palindrome_products(10, 99)), Some(9009)); } #[test] #[ignore] -fn empty_result_for_smallest_palindrome(){ - assert_eq!(test(GET::Smallest, (1002,1003)), Err(Error::Empty)); +fn smallest_palindrome_triple_digits(){ + assert_eq!(min(get_palindrome_products(100, 999)), Some(10201)); } #[test] #[ignore] -fn empty_result_for_largest_palindrome(){ - assert_eq!(test(GET::Largest, (15,15)), Err(Error::Empty)); +fn largest_palindrome_triple_digits(){ + assert_eq!(max(get_palindrome_products(100, 999)), Some(906609)); } #[test] #[ignore] -fn error_smallest_palindrome_when_min_bt_max(){ - assert_eq!(test(GET::Smallest, (1000,1)), Err(Error::RangeFailure)); +fn smallest_palindrome_four_digits(){ + assert_eq!(min(get_palindrome_products(1000, 9999)), Some(1002001)); } #[test] #[ignore] -fn error_largest_palindrome_when_min_bt_max(){ - assert_eq!(test(GET::Largest, (2,1)), Err(Error::RangeFailure)); -} +fn largest_palindrome_four_digits(){ + assert_eq!(max(get_palindrome_products(1000, 9999)), Some(99000099)); +} \ No newline at end of file From aed28295714d0f1eaf8b0868f4539bb923ccb711 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 10:24:35 +0200 Subject: [PATCH 18/24] Revert "apply configlet fmt" This reverts commit e0357d566bba4dcdb57d63a66400f9ae4e84c50a. --- config.json | 954 ++++++++++++++++++++-------------------- config/maintainers.json | 46 +- 2 files changed, 500 insertions(+), 500 deletions(-) diff --git a/config.json b/config.json index 894d73d9c..b5677c31d 100644 --- a/config.json +++ b/config.json @@ -1,968 +1,968 @@ { - "active": true, + "language": "Rust", "blurb": "Rust is a compiled programming language designed for speed, concurrency, and memory safety. Rust programs can run almost anywhere, from low-power embedded devices to web servers.", + "active": true, "exercises": [ { + "uuid": "13ec1ebe-d71b-436f-ab12-25305e814171", + "slug": "hello-world", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "hello-world", "topics": [ - "println" - ], - "unlocked_by": null, - "uuid": "13ec1ebe-d71b-436f-ab12-25305e814171" + "println!" + ] }, { + "uuid": "f880b1ef-8f66-41f3-bb89-f39a4ed592a2", + "slug": "gigasecond", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "gigasecond", "topics": [ "crates", "mathematics" - ], - "unlocked_by": null, - "uuid": "f880b1ef-8f66-41f3-bb89-f39a4ed592a2" + ] }, { + "uuid": "ef52f576-9c33-4cc1-a018-803ace8897f6", + "slug": "leap", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "leap", "topics": [ + "mathematics", "booleans", - "conditionals", - "mathematics" - ], - "unlocked_by": null, - "uuid": "ef52f576-9c33-4cc1-a018-803ace8897f6" + "conditionals" + ] }, { + "uuid": "2c12be9b-3a02-4161-8eac-050642ad791f", + "slug": "raindrops", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "raindrops", "topics": [ - "case_or_format", - "mutable_string" - ], - "unlocked_by": null, - "uuid": "2c12be9b-3a02-4161-8eac-050642ad791f" + "case (or `format`)", + "Mutable string" + ] }, { + "uuid": "ecf8d1e3-9400-4d1a-8326-2e2820bce024", + "slug": "reverse-string", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "reverse-string", "topics": [ - "iterator", - "str", - "string" - ], - "unlocked_by": null, - "uuid": "ecf8d1e3-9400-4d1a-8326-2e2820bce024" + "String", + "&str", + "Iterator" + ] }, { - "core": false, - "difficulty": 1, + "uuid": "ee5048a7-c625-434d-a0a2-4fd54757ee02", "slug": "nth-prime", - "topics": null, + "core": false, "unlocked_by": null, - "uuid": "ee5048a7-c625-434d-a0a2-4fd54757ee02" + "difficulty": 1, + "topics": [] }, { + "uuid": "38ef1802-2730-4f94-bafe-d2cd6b3e7f95", + "slug": "bob", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "bob", "topics": [ "chars", - "string_functions" - ], - "unlocked_by": null, - "uuid": "38ef1802-2730-4f94-bafe-d2cd6b3e7f95" + "string functions" + ] }, { + "uuid": "bb42bc3a-139d-4cab-8b3a-2eac2e1b77b6", + "slug": "beer-song", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "beer-song", "topics": [ "case", - "loop", - "string_concatenation", - "vector_optional" - ], - "unlocked_by": null, - "uuid": "bb42bc3a-139d-4cab-8b3a-2eac2e1b77b6" + "string concatenation", + "vector (optional)", + "loop" + ] }, { + "uuid": "504f9033-6433-4508-aebb-60ee77b800b9", + "slug": "proverb", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "proverb", "topics": [ "format" - ], - "unlocked_by": null, - "uuid": "504f9033-6433-4508-aebb-60ee77b800b9" + ] }, { + "uuid": "aee49878-f727-400b-8fb5-eaf83447cf87", + "slug": "difference-of-squares", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "difference-of-squares", "topics": [ "fold", "map" - ], - "unlocked_by": null, - "uuid": "aee49878-f727-400b-8fb5-eaf83447cf87" + ] }, { + "uuid": "be90fe16-9947-45ef-ab8e-eeca4ce3a8c8", + "slug": "sum-of-multiples", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "sum-of-multiples", "topics": [ "algorithm", "borrowing" - ], - "unlocked_by": null, - "uuid": "be90fe16-9947-45ef-ab8e-eeca4ce3a8c8" + ] }, { + "uuid": "9e69dd5d-472d-43d7-a8bb-60e4a7bed175", + "slug": "grains", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "grains", "topics": [ "mathematics", "panic" - ], - "unlocked_by": null, - "uuid": "9e69dd5d-472d-43d7-a8bb-60e4a7bed175" + ] }, { + "uuid": "6e7cac84-99d1-4f9f-b7d6-48ea43024bc0", + "slug": "pythagorean-triplet", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "pythagorean-triplet", "topics": [ "option" - ], - "unlocked_by": null, - "uuid": "6e7cac84-99d1-4f9f-b7d6-48ea43024bc0" + ] }, { + "uuid": "9f649818-0c82-4b79-b912-4d65b9f60e10", + "slug": "prime-factors", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "prime-factors", "topics": [ "mathematics" - ], - "unlocked_by": null, - "uuid": "9f649818-0c82-4b79-b912-4d65b9f60e10" + ] }, { + "uuid": "9de405e1-3a05-43cb-8eb3-00b81a2968e9", + "slug": "series", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "series", "topics": [ - "strings", - "vectors" - ], - "unlocked_by": null, - "uuid": "9de405e1-3a05-43cb-8eb3-00b81a2968e9" + "vectors", + "strings" + ] }, { + "uuid": "e652139e-ff3f-4e03-9810-d21f8b0c9e60", + "slug": "armstrong-numbers", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "armstrong-numbers", "topics": [ "mathematics" - ], - "unlocked_by": null, - "uuid": "e652139e-ff3f-4e03-9810-d21f8b0c9e60" + ] }, { + "uuid": "f9afd650-8103-4373-a284-fa4ecfee7207", + "slug": "collatz-conjecture", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "collatz-conjecture", "topics": [ - "option" - ], - "unlocked_by": null, - "uuid": "f9afd650-8103-4373-a284-fa4ecfee7207" + "Option" + ] }, { + "uuid": "23d82e48-d074-11e7-8fab-cec278b6b50a", + "slug": "diffie-hellman", "core": false, + "unlocked_by": null, "difficulty": 1, - "slug": "diffie-hellman", "topics": [ "mathematics" - ], - "unlocked_by": null, - "uuid": "23d82e48-d074-11e7-8fab-cec278b6b50a" + ] }, { + "uuid": "ccebfa12-d224-11e7-8941-cec278b6b50a", + "slug": "saddle-points", "core": false, + "unlocked_by": null, "difficulty": 3, - "slug": "saddle-points", "topics": [ - "iterators", - "vectors" - ], - "unlocked_by": null, - "uuid": "ccebfa12-d224-11e7-8941-cec278b6b50a" + "vectors", + "iterators" + ] }, { + "uuid": "79613fd8-b7da-11e7-abc4-cec278b6b50a", + "slug": "isogram", "core": false, + "unlocked_by": null, "difficulty": 3, - "slug": "isogram", "topics": [ "chars", "iterators", "strings" - ], - "unlocked_by": null, - "uuid": "79613fd8-b7da-11e7-abc4-cec278b6b50a" + ] }, { + "uuid": "4ba35adb-230b-49a6-adc9-2d3cd9a4c538", + "slug": "say", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "say", "topics": [ - "modulus", - "string_concatenation" - ], - "unlocked_by": null, - "uuid": "4ba35adb-230b-49a6-adc9-2d3cd9a4c538" + "string concatenation", + "modulus" + ] }, { + "uuid": "4dc9b165-792a-4438-be80-df9aab6f6a9c", + "slug": "run-length-encoding", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "run-length-encoding", "topics": [ - "conversion_between_string_and_int", - "loop", - "string_concatenation", - "use_of_primitive_char" - ], - "unlocked_by": null, - "uuid": "4dc9b165-792a-4438-be80-df9aab6f6a9c" + "string concatenation", + "conversion between string and int", + "use of primitive char", + "loop" + ] }, { + "uuid": "c986c240-46de-419c-8ed6-700eb68f8db6", + "slug": "isbn-verifier", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "isbn-verifier", "topics": [ - "conversion_between_string_and_int", + "conversion between string and int", "loop", "mathematics" - ], - "unlocked_by": null, - "uuid": "c986c240-46de-419c-8ed6-700eb68f8db6" + ] }, { + "uuid": "20e7d347-b80a-4656-ac34-0825126939ff", + "slug": "perfect-numbers", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "perfect-numbers", "topics": [ - "mathematics" - ], - "unlocked_by": null, - "uuid": "20e7d347-b80a-4656-ac34-0825126939ff" + "Mathematics" + ] }, { + "uuid": "543a3ca2-fb9b-4f20-a873-ff23595d41df", + "slug": "clock", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "clock", "topics": [ + "traits", "derive", - "struct", - "traits" - ], - "unlocked_by": null, - "uuid": "543a3ca2-fb9b-4f20-a873-ff23595d41df" + "struct" + ] }, { + "uuid": "2874216a-0822-4ec2-892e-d451fd89646a", + "slug": "hamming", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "hamming", "topics": [ - "result" - ], - "unlocked_by": null, - "uuid": "2874216a-0822-4ec2-892e-d451fd89646a" + "Result" + ] }, { + "uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237", + "slug": "simple-linked-list", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "simple-linked-list", "topics": [ "lists", - "struct", - "type_conversion" - ], - "unlocked_by": null, - "uuid": "10923b0b-c726-44a7-9e02-b775e7b8b237" + "type_conversion", + "struct" + ] }, { + "uuid": "ddc0c1da-6b65-4ed1-8bdc-5e71cd05f720", + "slug": "pascals-triangle", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "pascals-triangle", "topics": [ - "index_optional", - "mathematics", - "vec" - ], - "unlocked_by": null, - "uuid": "ddc0c1da-6b65-4ed1-8bdc-5e71cd05f720" + "Mathematics", + "Vec", + "Index (optional)" + ] }, { + "uuid": "561cc4ff-5e74-4701-a7c2-c4edefa0d068", + "slug": "scrabble-score", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "scrabble-score", "topics": [ - "chaining_higher_order_functions", - "hashmap_optional" - ], - "unlocked_by": null, - "uuid": "561cc4ff-5e74-4701-a7c2-c4edefa0d068" + "chaining higher-order functions", + "HashMap (optional)" + ] }, { + "uuid": "a24cb7bf-3aac-4051-bcd1-952c2a806187", + "slug": "pangram", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "pangram", "topics": [ - "ascii_optional", - "filter" - ], - "unlocked_by": null, - "uuid": "a24cb7bf-3aac-4051-bcd1-952c2a806187" + "filter", + "ascii (optional)" + ] }, { + "uuid": "3f54853b-cc65-4282-ab25-8dc3fdf43c03", + "slug": "nucleotide-count", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "nucleotide-count", "topics": [ - "entry_api", + "Result", "filter", - "match", + "entry api", "mutablity", - "result" - ], - "unlocked_by": null, - "uuid": "3f54853b-cc65-4282-ab25-8dc3fdf43c03" + "match" + ] }, { + "uuid": "8d64bfc3-fc4b-45c4-85f0-e74dc2ea6812", + "slug": "luhn", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "luhn", "topics": [ - "higher_order_functions", + "str to digits", "iterators", - "str_to_digits" - ], - "unlocked_by": null, - "uuid": "8d64bfc3-fc4b-45c4-85f0-e74dc2ea6812" + "higher-order functions" + ] }, { + "uuid": "8679c221-d150-4230-b1cd-5ea78ae69db7", + "slug": "largest-series-product", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "largest-series-product", "topics": [ - "char", - "higher_order_functions", - "result", - "windows" - ], - "unlocked_by": null, - "uuid": "8679c221-d150-4230-b1cd-5ea78ae69db7" + "Result", + "windows", + "higher-order functions", + "char" + ] }, { + "uuid": "6c5c0dc3-4f5b-4f83-bf67-a45bf4ea6be4", + "slug": "word-count", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "word-count", "topics": [ - "chars", - "entry_api", "hashmap", - "str_vs_string" - ], - "unlocked_by": null, - "uuid": "6c5c0dc3-4f5b-4f83-bf67-a45bf4ea6be4" + "str vs string", + "chars", + "entry api" + ] }, { + "uuid": "53298a14-76a9-4bb9-943a-57c5e79d9cf7", + "slug": "atbash-cipher", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "atbash-cipher", "topics": [ - "ascii", - "chars", + "str vs string", + "primitive types", "iterators", - "primitive_types", - "str_vs_string" - ], - "unlocked_by": null, - "uuid": "53298a14-76a9-4bb9-943a-57c5e79d9cf7" + "chars", + "ascii" + ] }, { - "difficulty": 4, + "uuid": "0cc485e9-43ba-4d97-a622-ee4cb8b9f1f7", "slug": "crypto-square", + "difficulty": 4, "topics": [ + "str vs string", + "primitive types", + "iterators", + "chars", "arrays", "ascii", - "chars", - "iterators", - "primitive_types", - "str_vs_string", "transforming" - ], - "uuid": "0cc485e9-43ba-4d97-a622-ee4cb8b9f1f7" + ] }, { + "uuid": "5dbecc83-2c8d-467d-be05-f28a08f7abcf", + "slug": "rotational-cipher", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "rotational-cipher", "topics": [ - "ascii", - "chars", + "str vs string", + "primitive types", "iterators", - "primitive_types", - "str_vs_string" - ], - "unlocked_by": null, - "uuid": "5dbecc83-2c8d-467d-be05-f28a08f7abcf" + "chars", + "ascii" + ] }, { + "uuid": "0c8eeef7-4bab-4cf9-9047-c208b5618312", + "slug": "etl", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "etl", "topics": [ "btree" - ], - "unlocked_by": null, - "uuid": "0c8eeef7-4bab-4cf9-9047-c208b5618312" + ] }, { + "uuid": "ddc45979-8a92-4313-a4f8-878562d5a483", + "slug": "accumulate", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "accumulate", "topics": [ - "function_pointer" - ], - "unlocked_by": null, - "uuid": "ddc45979-8a92-4313-a4f8-878562d5a483" + "function pointer" + ] }, { + "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9", + "slug": "acronym", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "acronym", "topics": [ - "filter", + "map", "flat_map", + "filter", "loops", - "map", - "vec" - ], - "unlocked_by": null, - "uuid": "26a9102f-26f6-4238-858e-ba20db66f1a9" + "Vec" + ] }, { + "uuid": "da784b42-1cec-469e-8e48-0be232b17003", + "slug": "sieve", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "sieve", "topics": [ - "map", "vector", - "while_let_optional" - ], - "unlocked_by": null, - "uuid": "da784b42-1cec-469e-8e48-0be232b17003" + "map", + "while let (optional)" + ] }, { + "uuid": "9a219d87-cd32-4e12-a879-bfb5747c2369", + "slug": "rna-transcription", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "rna-transcription", "topics": [ + "Result", "match", - "result", - "str_vs_string", - "struct" - ], - "unlocked_by": null, - "uuid": "9a219d87-cd32-4e12-a879-bfb5747c2369" + "struct", + "str vs string" + ] }, { + "uuid": "c0bc2af6-d7af-401f-9ed8-bbe31977666c", + "slug": "triangle", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "triangle", "topics": [ - "mathematics", - "struct" - ], - "unlocked_by": null, - "uuid": "c0bc2af6-d7af-401f-9ed8-bbe31977666c" + "Mathematics", + "Struct" + ] }, { + "uuid": "498be645-734a-49b7-aba7-aae1e051e1f0", + "slug": "roman-numerals", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "roman-numerals", "topics": [ - "loops", "mutable", "results", + "loops", "struct", "traits" - ], - "unlocked_by": null, - "uuid": "498be645-734a-49b7-aba7-aae1e051e1f0" + ] }, { + "uuid": "54c11dae-3878-4bec-b8d6-775b7d4f317b", + "slug": "all-your-base", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "all-your-base", "topics": [ + "Result", "enumerate", "fold", - "map", - "result" - ], - "unlocked_by": null, - "uuid": "54c11dae-3878-4bec-b8d6-775b7d4f317b" + "map" + ] }, { + "uuid": "5ca03812-c229-48db-b7fd-0889b22f8d1d", + "slug": "grade-school", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "grade-school", "topics": [ - "entry_api", - "option", "struct", - "vec" - ], - "unlocked_by": null, - "uuid": "5ca03812-c229-48db-b7fd-0889b22f8d1d" + "entry api", + "Vec", + "Option" + ] }, { + "uuid": "dd74b65c-0d26-4821-9add-064e32e3a5bd", + "slug": "binary-search", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "binary-search", "topics": [ - "option", "slices", - "trait_optional" - ], - "unlocked_by": null, - "uuid": "dd74b65c-0d26-4821-9add-064e32e3a5bd" + "trait (optional)", + "Option" + ] }, { + "uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66", + "slug": "robot-simulator", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "robot-simulator", "topics": [ - "enum", - "immutability" - ], - "unlocked_by": null, - "uuid": "1beb8b0c-d06d-4569-80e5-866ed01a7a66" + "Immutability", + "enum" + ] }, { + "uuid": "40729822-4265-4c14-b03f-a00bff5f24bb", + "slug": "bracket-push", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "bracket-push", "topics": [ - "from_trait", - "stack_or_recursion" - ], - "unlocked_by": null, - "uuid": "40729822-4265-4c14-b03f-a00bff5f24bb" + "From trait", + "stack or recursion" + ] }, { + "uuid": "f9131b5d-91dd-4514-983d-4abc22bb5d5c", + "slug": "luhn-from", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "luhn-from", "topics": [ - "from_trait", - "higher_order_functions", + "from trait", + "str to digits", "iterators", - "str_to_digits" - ], - "unlocked_by": null, - "uuid": "f9131b5d-91dd-4514-983d-4abc22bb5d5c" + "higher-order functions" + ] }, { + "uuid": "30c33e3d-8034-4618-8346-2ae906961579", + "slug": "queen-attack", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "queen-attack", "topics": [ - "result", "struct", - "trait_optional" - ], - "unlocked_by": null, - "uuid": "30c33e3d-8034-4618-8346-2ae906961579" + "trait (optional)", + "Result" + ] }, { + "uuid": "fec447a5-cf11-4ddd-b0fd-63bcc4e245cd", + "slug": "bowling", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "bowling", "topics": [ - "goofy_bowling_logic", - "result", - "struct" - ], - "unlocked_by": null, - "uuid": "fec447a5-cf11-4ddd-b0fd-63bcc4e245cd" + "struct", + "Result", + "goofy bowling logic" + ] }, { + "uuid": "644ffd17-548e-4405-bfd5-a58df74cc19d", + "slug": "sublist", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "sublist", "topics": [ "enum", - "generic_over_type" - ], - "unlocked_by": null, - "uuid": "644ffd17-548e-4405-bfd5-a58df74cc19d" + "generic over type" + ] }, { + "uuid": "fa94645d-14e1-422d-a832-d24efbb493d8", + "slug": "space-age", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "space-age", "topics": [ - "custom_trait", - "default_trait_implementation", - "from_trait" - ], - "unlocked_by": null, - "uuid": "fa94645d-14e1-422d-a832-d24efbb493d8" + "Custom Trait", + "From Trait", + "Default Trait implementation" + ] }, { + "uuid": "c32c0124-873d-45f4-9287-402aea29f129", + "slug": "luhn-trait", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "luhn-trait", "topics": [ - "custom_trait", - "higher_order_functions", + "Custom Trait", + "str to digits", "iterators", - "str_to_digits" - ], - "unlocked_by": null, - "uuid": "c32c0124-873d-45f4-9287-402aea29f129" + "higher-order functions" + ] }, { + "uuid": "29583cc6-d56d-4bee-847d-93d74e5a30e7", + "slug": "macros", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "macros", "topics": [ - "hashmap", "macros", - "macros_by_example" - ], - "unlocked_by": null, - "uuid": "29583cc6-d56d-4bee-847d-93d74e5a30e7" + "macros-by-example", + "hashmap" + ] }, { + "uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d", + "slug": "allergies", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "allergies", "topics": [ - "bitwise_probably", - "enum", - "filter", "struct", - "vectors" - ], - "unlocked_by": null, - "uuid": "94f040d6-3f41-4950-8fe6-acf0945ac83d" + "enum", + "bitwise (probably)", + "vectors", + "filter" + ] }, { + "uuid": "f1371a9c-c2a4-4fc6-a5fd-3a57c4af16fa", + "slug": "variable-length-quantity", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "variable-length-quantity", "topics": [ + "Encodings", + "slices", "bitwise", - "encodings", - "result", - "slices" - ], - "unlocked_by": null, - "uuid": "f1371a9c-c2a4-4fc6-a5fd-3a57c4af16fa" + "Result" + ] }, { + "uuid": "6abac1d1-0d85-4b51-8001-97a07990630d", + "slug": "phone-number", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "phone-number", "topics": [ + "option", "format", + "unwrap_or", "iters", - "match", - "option", - "unwrap_or" - ], - "unlocked_by": null, - "uuid": "6abac1d1-0d85-4b51-8001-97a07990630d" + "match" + ] }, { + "uuid": "620b55bb-058e-4c6f-a966-ced3b41736db", + "slug": "wordy", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "wordy", "topics": [ - "operators_optional", - "result", - "string_parsing" - ], - "unlocked_by": null, - "uuid": "620b55bb-058e-4c6f-a966-ced3b41736db" + "Result", + "string parsing", + "operators (optional)" + ] }, { + "uuid": "9a2406cc-5037-4761-b820-bb25b1d397c8", + "slug": "tournament", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "tournament", "topics": [ "enum", - "hashmap", "sorting", + "hashmap", "structs" - ], - "unlocked_by": null, - "uuid": "9a2406cc-5037-4761-b820-bb25b1d397c8" + ] }, { + "uuid": "9d652e63-6654-4dec-a99f-97e6bc8cf772", + "slug": "custom-set", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "custom-set", "topics": [ + "generic over type", + "vector", "equality", - "generic_over_type", - "struct", - "vector" - ], - "unlocked_by": null, - "uuid": "9d652e63-6654-4dec-a99f-97e6bc8cf772" + "struct" + ] }, { + "uuid": "7450bd80-2388-42ac-a61f-097e82581475", + "slug": "alphametics", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "alphametics", "topics": [ + "string parsing", "combinations", - "external_crates_optional", "mathematics", - "string_parsing" - ], - "unlocked_by": null, - "uuid": "7450bd80-2388-42ac-a61f-097e82581475" + "external crates (optional)" + ] }, { + "uuid": "1850fb3f-9dad-449a-90b6-9d90038cf34d", + "slug": "two-bucket", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "two-bucket", "topics": [ "algorithm", "loops", "mathematics" - ], - "unlocked_by": null, - "uuid": "1850fb3f-9dad-449a-90b6-9d90038cf34d" + ] }, { - "core": false, - "difficulty": 4, + "uuid": "c21c379b-fb23-449b-809a-3c6ef1c31221", "slug": "pig-latin", - "topics": null, + "core": false, "unlocked_by": null, - "uuid": "c21c379b-fb23-449b-809a-3c6ef1c31221" + "difficulty": 4, + "topics": [] }, { + "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55", + "slug": "palindrome-products", "core": false, + "unlocked_by": null, "difficulty": 4, - "slug": "palindrome-products", "topics": [ + "string comparison", "calculation", - "string_comparison", "structs" - ], - "unlocked_by": null, - "uuid": "8cdc3424-51da-4cae-a065-9982859d5b55" + ] }, { + "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977", + "slug": "poker", "core": false, + "unlocked_by": null, "difficulty": 6, - "slug": "poker", "topics": [ - "enum", "lifetimes", - "string_parsing", "struct", + "string parsing", + "enum", "traits" - ], - "unlocked_by": null, - "uuid": "0a33f3ac-cedd-4a40-a132-9d044b0e9977" + ] }, { + "uuid": "7cefed7c-37f4-46c5-9a45-68fe4d0fb326", + "slug": "decimal", "core": false, + "unlocked_by": null, "difficulty": 6, - "slug": "decimal", "topics": [ - "bigint", - "external_crates_optional", - "string_parsing", "struct", - "traits" - ], - "unlocked_by": null, - "uuid": "7cefed7c-37f4-46c5-9a45-68fe4d0fb326" + "traits", + "string parsing", + "bigint", + "external crates (optional)" + ] }, { + "uuid": "f3172997-91f5-4941-a76e-91c4b8eed401", + "slug": "anagram", "core": false, + "unlocked_by": null, "difficulty": 7, - "slug": "anagram", "topics": [ - "iter", "lifetimes", + "str vs string", "loops", - "str_vs_string", + "iter", "vector" - ], - "unlocked_by": null, - "uuid": "f3172997-91f5-4941-a76e-91c4b8eed401" + ] }, { + "uuid": "4e01efbc-51ce-4d20-b093-b3d44c4be5e8", + "slug": "protein-translation", "core": false, + "unlocked_by": null, "difficulty": 7, - "slug": "protein-translation", "topics": [ - "hash_map", + "struct", + "hash map", "lifetimes", - "result", - "struct" - ], - "unlocked_by": null, - "uuid": "4e01efbc-51ce-4d20-b093-b3d44c4be5e8" + "Result" + ] }, { + "uuid": "ec7f66c2-749e-4d00-9c11-fa9d106632e4", + "slug": "robot-name", "core": false, + "unlocked_by": null, "difficulty": 7, - "slug": "robot-name", "topics": [ - "lifetimes", - "randomness", - "self_mut", + "struct", "slices", - "struct" - ], - "unlocked_by": null, - "uuid": "ec7f66c2-749e-4d00-9c11-fa9d106632e4" + "randomness", + "lifetimes", + "self mut" + ] }, { + "uuid": "a78ed17a-b2c0-485c-814b-e13ccd1f4153", + "slug": "book-store", "core": false, + "unlocked_by": null, "difficulty": 7, - "slug": "book-store", "topics": [ "algorithms", "groups", - "set_theory" - ], - "unlocked_by": null, - "uuid": "a78ed17a-b2c0-485c-814b-e13ccd1f4153" + "set theory" + ] }, { + "uuid": "704aab91-b83a-4e64-8c21-fb0be5076289", + "slug": "ocr-numbers", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "ocr-numbers", "topics": [ - "chunks", - "lines", + "Lines", + "Chunks", "slices" - ], - "unlocked_by": null, - "uuid": "704aab91-b83a-4e64-8c21-fb0be5076289" + ] }, { + "uuid": "e0037ac4-ae5f-4622-b3ad-915648263495", + "slug": "minesweeper", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "minesweeper", "topics": [ - "board_state" - ], - "unlocked_by": null, - "uuid": "e0037ac4-ae5f-4622-b3ad-915648263495" + "Board state" + ] }, { + "uuid": "5e6f6986-5011-427b-a992-d6d0c81f5101", + "slug": "dominoes", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "dominoes", "topics": [ - "graph_theory", + "Graph theory", "searching" - ], - "unlocked_by": null, - "uuid": "5e6f6986-5011-427b-a992-d6d0c81f5101" + ] }, { + "uuid": "e114b19f-9a9a-402d-a5cb-1cad8de5088e", + "slug": "parallel-letter-frequency", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "parallel-letter-frequency", "topics": [ - "multi_threading" - ], - "unlocked_by": null, - "uuid": "e114b19f-9a9a-402d-a5cb-1cad8de5088e" + "multi-threading" + ] }, { + "uuid": "cc4ccd99-1c97-4ee7-890c-d629b4e1e46d", + "slug": "rectangles", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "rectangles", "topics": [ - "algorithm", - "enum", + "Enum", "structs", - "traits" - ], - "unlocked_by": null, - "uuid": "cc4ccd99-1c97-4ee7-890c-d629b4e1e46d" + "traits", + "algorithm" + ] }, { + "uuid": "55976c49-1be5-4170-8aa3-056c2223abbb", + "slug": "forth", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "forth", "topics": [ - "parser_reimplementation" - ], - "unlocked_by": null, - "uuid": "55976c49-1be5-4170-8aa3-056c2223abbb" + "Parser reimplementation" + ] }, { + "uuid": "6ff1a539-251b-49d4-81b5-a6b1e9ba66a4", + "slug": "circular-buffer", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "circular-buffer", "topics": [ - "buffer_reimplementation", - "generics" - ], - "unlocked_by": null, - "uuid": "6ff1a539-251b-49d4-81b5-a6b1e9ba66a4" + "Buffer reimplementation", + "Generics" + ] }, { + "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c", + "slug": "react", "core": false, + "unlocked_by": null, "difficulty": 10, - "slug": "react", "topics": [ - "closures", + "Lifetimes", "generics", - "lifetimes" - ], - "unlocked_by": null, - "uuid": "8708ccc7-711a-4862-b5a4-ff59fde2241c" + "closures" + ] }, { - "deprecated": true, + "uuid": "8dae8f4d-368d-477d-907e-bf746921bfbf", "slug": "nucleotide-codons", - "uuid": "8dae8f4d-368d-477d-907e-bf746921bfbf" + "deprecated": true }, { - "deprecated": true, + "uuid": "496fd79f-1678-4aa2-8110-c32c6aaf545e", "slug": "hexadecimal", - "uuid": "496fd79f-1678-4aa2-8110-c32c6aaf545e" + "deprecated": true } ], "foregone": [ "binary", "octal", "trinary" - ], - "language": "Rust" -} \ No newline at end of file + ] +} diff --git a/config/maintainers.json b/config/maintainers.json index 7a62da5cd..ee1ef7ffb 100644 --- a/config/maintainers.json +++ b/config/maintainers.json @@ -1,59 +1,59 @@ { "maintainers": [ { + "github_username": "IanWhitney", + "show_on_website": false, "alumnus": false, - "avatar_url": null, + "name": null, "bio": null, - "github_username": "IanWhitney", "link_text": null, "link_url": null, - "name": null, - "show_on_website": false + "avatar_url": null }, { - "alumnus": true, "github_username": "etrepum", - "show_on_website": false + "show_on_website": false, + "alumnus": true }, { + "github_username": "ijanos", + "show_on_website": false, "alumnus": false, - "avatar_url": null, + "name": null, "bio": null, - "github_username": "ijanos", "link_text": null, "link_url": null, - "name": null, - "show_on_website": false + "avatar_url": null }, { + "github_username": "petertseng", + "show_on_website": false, "alumnus": false, - "avatar_url": null, + "name": null, "bio": null, - "github_username": "petertseng", "link_text": null, "link_url": null, - "name": null, - "show_on_website": false + "avatar_url": null }, { + "github_username": "EduardoBautista", + "show_on_website": false, "alumnus": false, - "avatar_url": null, + "name": null, "bio": null, - "github_username": "EduardoBautista", "link_text": null, "link_url": null, - "name": null, - "show_on_website": false + "avatar_url": null }, { + "github_username": "coriolinus", + "show_on_website": false, "alumnus": false, - "avatar_url": null, + "name": null, "bio": null, - "github_username": "coriolinus", "link_text": null, "link_url": null, - "name": null, - "show_on_website": false + "avatar_url": null } ] -} \ No newline at end of file +} From 7144282b257621dfa5e829bfbbf29380b7f6e473 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 11:00:28 +0200 Subject: [PATCH 19/24] use vector slice as argument in min and max functios to improve performance - restructure tests, persist the list of palindromes instead of computing it twice --- exercises/palindrome-products/example.rs | 14 ++--- exercises/palindrome-products/src/lib.rs | 4 +- .../tests/palindrome-products.rs | 56 +++++++------------ 3 files changed, 27 insertions(+), 47 deletions(-) diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs index 22fd32833..1c173dc30 100644 --- a/exercises/palindrome-products/example.rs +++ b/exercises/palindrome-products/example.rs @@ -11,18 +11,12 @@ pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ palindromes } -pub fn min(palindromes: Vec)->Option{ - if palindromes.is_empty(){ - return None; - } - palindromes.iter().cloned().min() +pub fn min(palindromes: &[Palindrome])->Option{ + palindromes.iter().min().map(|n| n.clone()) } -pub fn max(palindromes: Vec)->Option{ - if palindromes.is_empty(){ - return None; - } - palindromes.iter().cloned().max() +pub fn max(palindromes: &[Palindrome])->Option{ + palindromes.iter().max().map(|n| n.clone()) } fn is_palindrome(s: u64)->bool{ diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index d9760c3a3..331392f35 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -3,10 +3,10 @@ pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ unimplemented!("Find all palindromic numbers which are products of numbers in the inclusive range ({}..{})", min, max) } -pub fn min(palindromes: Vec)->Option{ +pub fn min(palindromes: &[Palindrome])->Option{ unimplemented!("Return the palindrome of minimal value from the supplied list: {:?}", palindromes) } -pub fn max(palindromes: Vec)->Option{ +pub fn max(palindromes: &[Palindrome])->Option{ unimplemented!("Return the palindrome of maximal value from the supplied list: {:?}", palindromes) } \ No newline at end of file diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 00dc3cfaf..9effb1f64 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -4,69 +4,55 @@ use palindrome_products::*; #[test] #[ignore] fn empty_result_for_smallest_palindrome(){ - assert_eq!(min(get_palindrome_products(1002, 1003)), None); + assert_eq!(min(&get_palindrome_products(1002, 1003)), None); } #[test] -#[ignore] + fn empty_result_for_largest_palindrome(){ - assert_eq!(max(get_palindrome_products(15, 15)), None); + assert_eq!(max(&get_palindrome_products(15, 15)), None); } #[test] #[ignore] fn error_smallest_palindrome_when_min_gt_max(){ - assert_eq!(min(get_palindrome_products(1000, 1)), None); + assert_eq!(min(&get_palindrome_products(1000, 1)), None); } #[test] #[ignore] fn error_largest_palindrome_when_min_st_max(){ - assert_eq!(max(get_palindrome_products(2, 1)), None); -} - -#[test] -fn smallest_palindrome_single_digits(){ - assert_eq!(min(get_palindrome_products(1, 9)), Some(1)); -} - -#[test] -#[ignore] -fn largest_palindrome_single_digits(){ - assert_eq!(max(get_palindrome_products(1, 9)), Some(9)); -} -#[test] -#[ignore] -fn smallest_palindrome_double_digits(){ - assert_eq!(min(get_palindrome_products(10, 99)), Some(121)); + assert_eq!(max(&get_palindrome_products(2, 1)), None); } -#[test] -#[ignore] -fn largest_palindrome_double_digits(){ - assert_eq!(max(get_palindrome_products(10, 99)), Some(9009)); -} #[test] -#[ignore] -fn smallest_palindrome_triple_digits(){ - assert_eq!(min(get_palindrome_products(100, 999)), Some(10201)); +fn single_digits(){ + let palindromes = get_palindrome_products(1, 9); + assert_eq!(min(&palindromes), Some(1)); + assert_eq!(max(&palindromes), Some(9)); } #[test] #[ignore] -fn largest_palindrome_triple_digits(){ - assert_eq!(max(get_palindrome_products(100, 999)), Some(906609)); +fn double_digits(){ + let palindromes = get_palindrome_products(10, 99); + assert_eq!(min(&palindromes), Some(121)); + assert_eq!(max(&palindromes), Some(9009)); } #[test] #[ignore] -fn smallest_palindrome_four_digits(){ - assert_eq!(min(get_palindrome_products(1000, 9999)), Some(1002001)); +fn triple_digits(){ + let palindromes = get_palindrome_products(100, 999); + assert_eq!(min(&palindromes), Some(10201)); + assert_eq!(max(&palindromes), Some(906609)); } #[test] #[ignore] -fn largest_palindrome_four_digits(){ - assert_eq!(max(get_palindrome_products(1000, 9999)), Some(99000099)); +fn four_digits(){ + let palindromes = get_palindrome_products(1000, 9999); + assert_eq!(min(&palindromes), Some(1002001)); + assert_eq!(max(&palindromes), Some(99000099)); } \ No newline at end of file From ce2a7ac61546fbf141f1523c08e602ddaede1617 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 12:14:54 +0200 Subject: [PATCH 20/24] iterate over bytes for improved performance --- exercises/palindrome-products/example.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs index 1c173dc30..a9f031ef3 100644 --- a/exercises/palindrome-products/example.rs +++ b/exercises/palindrome-products/example.rs @@ -19,9 +19,7 @@ pub fn max(palindromes: &[Palindrome])->Option{ palindromes.iter().max().map(|n| n.clone()) } -fn is_palindrome(s: u64)->bool{ - let s1 = s.to_string(); - let s2 = s1.chars().rev().collect::(); - - s1 == s2 +fn is_palindrome(n: u64)->bool{ + let s = n.to_string().into_bytes(); + s.iter().zip(s.iter().rev()).all(|(c1, c2)| c1 == c2) } \ No newline at end of file From 4ee81648e8e586d96ba60b63577e43fde5826763 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 13:37:12 +0200 Subject: [PATCH 21/24] ignore another test --- exercises/palindrome-products/tests/palindrome-products.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 9effb1f64..962e15e99 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -8,7 +8,7 @@ fn empty_result_for_smallest_palindrome(){ } #[test] - +#[ignore] fn empty_result_for_largest_palindrome(){ assert_eq!(max(&get_palindrome_products(15, 15)), None); } From d536ad7d2fc60490af78c03c5ef053b720906f3e Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 13:59:40 +0200 Subject: [PATCH 22/24] add test-in-release-mode file to improve the timing --- exercises/palindrome-products/.meta/test-in-release-mode | 1 + 1 file changed, 1 insertion(+) create mode 100644 exercises/palindrome-products/.meta/test-in-release-mode diff --git a/exercises/palindrome-products/.meta/test-in-release-mode b/exercises/palindrome-products/.meta/test-in-release-mode new file mode 100644 index 000000000..1371d9d0a --- /dev/null +++ b/exercises/palindrome-products/.meta/test-in-release-mode @@ -0,0 +1 @@ +Takes very long time in debug mode because of the nested loops which compute the palindrome products. From b21b3101589058c615eb2853f8cc8b558c7c5d7c Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Fri, 20 Apr 2018 22:03:43 +0200 Subject: [PATCH 23/24] apply rustfmt - put the first running test on the top --- exercises/palindrome-products/example.rs | 20 +-- exercises/palindrome-products/src/lib.rs | 25 ++-- .../tests/palindrome-products.rs | 115 +++++++++--------- 3 files changed, 85 insertions(+), 75 deletions(-) diff --git a/exercises/palindrome-products/example.rs b/exercises/palindrome-products/example.rs index a9f031ef3..067c3305e 100644 --- a/exercises/palindrome-products/example.rs +++ b/exercises/palindrome-products/example.rs @@ -1,25 +1,25 @@ pub type Palindrome = u64; -pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ - let mut palindromes:Vec = Vec::new(); - for i in min..max+1{ - for j in min..max+1{ - if is_palindrome(i*j){ - palindromes.push(i*j); +pub fn get_palindrome_products(min: u64, max: u64) -> Vec { + let mut palindromes: Vec = Vec::new(); + for i in min..max + 1 { + for j in min..max + 1 { + if is_palindrome(i * j) { + palindromes.push(i * j); } } } palindromes } -pub fn min(palindromes: &[Palindrome])->Option{ +pub fn min(palindromes: &[Palindrome]) -> Option { palindromes.iter().min().map(|n| n.clone()) } -pub fn max(palindromes: &[Palindrome])->Option{ +pub fn max(palindromes: &[Palindrome]) -> Option { palindromes.iter().max().map(|n| n.clone()) } -fn is_palindrome(n: u64)->bool{ +fn is_palindrome(n: u64) -> bool { let s = n.to_string().into_bytes(); s.iter().zip(s.iter().rev()).all(|(c1, c2)| c1 == c2) -} \ No newline at end of file +} diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 331392f35..0cadf0407 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -1,12 +1,23 @@ pub type Palindrome = u64; -pub fn get_palindrome_products(min: u64, max: u64) -> Vec{ - unimplemented!("Find all palindromic numbers which are products of numbers in the inclusive range ({}..{})", min, max) +pub fn get_palindrome_products(min: u64, max: u64) -> Vec { + unimplemented!( + "Find all palindromic numbers which are products of numbers in the " + "inclusive range ({}..{})", + min, + max + ) } -pub fn min(palindromes: &[Palindrome])->Option{ - unimplemented!("Return the palindrome of minimal value from the supplied list: {:?}", palindromes) +pub fn min(palindromes: &[Palindrome]) -> Option { + unimplemented!( + "Return the palindrome of minimal value from the supplied list: {:?}", + palindromes + ) } -pub fn max(palindromes: &[Palindrome])->Option{ - unimplemented!("Return the palindrome of maximal value from the supplied list: {:?}", palindromes) -} \ No newline at end of file +pub fn max(palindromes: &[Palindrome]) -> Option { + unimplemented!( + "Return the palindrome of maximal value from the supplied list: {:?}", + palindromes + ) +} diff --git a/exercises/palindrome-products/tests/palindrome-products.rs b/exercises/palindrome-products/tests/palindrome-products.rs index 962e15e99..87975aef9 100644 --- a/exercises/palindrome-products/tests/palindrome-products.rs +++ b/exercises/palindrome-products/tests/palindrome-products.rs @@ -1,58 +1,57 @@ -extern crate palindrome_products; -use palindrome_products::*; - -#[test] -#[ignore] -fn empty_result_for_smallest_palindrome(){ - assert_eq!(min(&get_palindrome_products(1002, 1003)), None); -} - -#[test] -#[ignore] -fn empty_result_for_largest_palindrome(){ - assert_eq!(max(&get_palindrome_products(15, 15)), None); -} - -#[test] -#[ignore] -fn error_smallest_palindrome_when_min_gt_max(){ - assert_eq!(min(&get_palindrome_products(1000, 1)), None); -} - -#[test] -#[ignore] -fn error_largest_palindrome_when_min_st_max(){ - assert_eq!(max(&get_palindrome_products(2, 1)), None); -} - - -#[test] -fn single_digits(){ - let palindromes = get_palindrome_products(1, 9); - assert_eq!(min(&palindromes), Some(1)); - assert_eq!(max(&palindromes), Some(9)); -} - -#[test] -#[ignore] -fn double_digits(){ - let palindromes = get_palindrome_products(10, 99); - assert_eq!(min(&palindromes), Some(121)); - assert_eq!(max(&palindromes), Some(9009)); -} - -#[test] -#[ignore] -fn triple_digits(){ - let palindromes = get_palindrome_products(100, 999); - assert_eq!(min(&palindromes), Some(10201)); - assert_eq!(max(&palindromes), Some(906609)); -} - -#[test] -#[ignore] -fn four_digits(){ - let palindromes = get_palindrome_products(1000, 9999); - assert_eq!(min(&palindromes), Some(1002001)); - assert_eq!(max(&palindromes), Some(99000099)); -} \ No newline at end of file +extern crate palindrome_products; +use palindrome_products::*; + +#[test] +fn single_digits() { + let palindromes = get_palindrome_products(1, 9); + assert_eq!(min(&palindromes), Some(1)); + assert_eq!(max(&palindromes), Some(9)); +} + +#[test] +#[ignore] +fn double_digits() { + let palindromes = get_palindrome_products(10, 99); + assert_eq!(min(&palindromes), Some(121)); + assert_eq!(max(&palindromes), Some(9009)); +} + +#[test] +#[ignore] +fn triple_digits() { + let palindromes = get_palindrome_products(100, 999); + assert_eq!(min(&palindromes), Some(10201)); + assert_eq!(max(&palindromes), Some(906609)); +} + +#[test] +#[ignore] +fn four_digits() { + let palindromes = get_palindrome_products(1000, 9999); + assert_eq!(min(&palindromes), Some(1002001)); + assert_eq!(max(&palindromes), Some(99000099)); +} + +#[test] +#[ignore] +fn empty_result_for_smallest_palindrome() { + assert_eq!(min(&get_palindrome_products(1002, 1003)), None); +} + +#[test] +#[ignore] +fn empty_result_for_largest_palindrome() { + assert_eq!(max(&get_palindrome_products(15, 15)), None); +} + +#[test] +#[ignore] +fn error_smallest_palindrome_when_min_gt_max() { + assert_eq!(min(&get_palindrome_products(1000, 1)), None); +} + +#[test] +#[ignore] +fn error_largest_palindrome_when_min_st_max() { + assert_eq!(max(&get_palindrome_products(2, 1)), None); +} From 2c0f32512135d8ca8432e37446dfd7f7d764e910 Mon Sep 17 00:00:00 2001 From: Kirill Meng Date: Sat, 21 Apr 2018 09:57:59 +0200 Subject: [PATCH 24/24] revert divided string --- exercises/palindrome-products/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/exercises/palindrome-products/src/lib.rs b/exercises/palindrome-products/src/lib.rs index 0cadf0407..a18110222 100644 --- a/exercises/palindrome-products/src/lib.rs +++ b/exercises/palindrome-products/src/lib.rs @@ -1,8 +1,7 @@ pub type Palindrome = u64; pub fn get_palindrome_products(min: u64, max: u64) -> Vec { unimplemented!( - "Find all palindromic numbers which are products of numbers in the " - "inclusive range ({}..{})", + "Find all palindromic numbers which are products of numbers in the inclusive range ({}..{})", min, max )