diff --git a/exercises/hexadecimal/.gitignore b/exercises/hexadecimal/.gitignore deleted file mode 100644 index db7f315c0..000000000 --- a/exercises/hexadecimal/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercises/hexadecimal/Cargo.toml b/exercises/hexadecimal/Cargo.toml deleted file mode 100644 index 062e6a9a0..000000000 --- a/exercises/hexadecimal/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -edition = "2018" -name = "hexadecimal" -version = "0.0.0" diff --git a/exercises/hexadecimal/README.md b/exercises/hexadecimal/README.md deleted file mode 100644 index 1651fe77a..000000000 --- a/exercises/hexadecimal/README.md +++ /dev/null @@ -1,88 +0,0 @@ -# Hexadecimal - -Convert a hexadecimal number, represented as a string (e.g. "10af8c"), to its decimal equivalent using first principles (i.e. no, you may not use built-in or external libraries to accomplish the conversion). - -On the web we use hexadecimal to represent colors, e.g. green: 008000, -teal: 008080, navy: 000080). - -The program should handle invalid hexadecimal strings. - -## 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, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run all tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the [online test documentation][rust-tests] - -Make sure to read the [Modules](https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html) chapter if you -haven't already, it will help you with organizing your files. - -## Further improvements - -After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution. - -To format your solution, inside the solution directory use - -```bash -cargo fmt -``` - -To see, if your solution contains some common ineffective use cases, inside the solution directory use - -```bash -cargo clippy --all-targets -``` - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The [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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html -[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Source - -All of Computer Science [http://www.wolframalpha.com/examples/NumberBases.html](http://www.wolframalpha.com/examples/NumberBases.html) - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/hexadecimal/example.rs b/exercises/hexadecimal/example.rs deleted file mode 100644 index f539b3c9c..000000000 --- a/exercises/hexadecimal/example.rs +++ /dev/null @@ -1,33 +0,0 @@ -fn parse_hex_digit(c: char) -> Option { - match c { - '0' => Some(0), - '1' => Some(1), - '2' => Some(2), - '3' => Some(3), - '4' => Some(4), - '5' => Some(5), - '6' => Some(6), - '7' => Some(7), - '8' => Some(8), - '9' => Some(9), - 'a' => Some(10), - 'b' => Some(11), - 'c' => Some(12), - 'd' => Some(13), - 'e' => Some(14), - 'f' => Some(15), - _ => None, - } -} - -pub fn hex_to_int(string: &str) -> Option { - let base: i64 = 16; - - string - .chars() - .rev() - .enumerate() - .fold(Some(0), |acc, (pos, c)| { - parse_hex_digit(c).and_then(|n| acc.map(|acc| acc + n * base.pow(pos as u32))) - }) -} diff --git a/exercises/hexadecimal/src/lib.rs b/exercises/hexadecimal/src/lib.rs deleted file mode 100644 index 5692e8518..000000000 --- a/exercises/hexadecimal/src/lib.rs +++ /dev/null @@ -1,6 +0,0 @@ -// This exercise is deprecated. -// Consider working on all-your-base instead. - -pub fn hex_to_int(string: &str) -> Option { - unimplemented!("what integer is represented by the base-16 digits {}?", string); -} diff --git a/exercises/hexadecimal/tests/hexadecimal.rs b/exercises/hexadecimal/tests/hexadecimal.rs deleted file mode 100644 index 757b6887f..000000000 --- a/exercises/hexadecimal/tests/hexadecimal.rs +++ /dev/null @@ -1,60 +0,0 @@ -extern crate hexadecimal; - -#[test] -fn test_hex_1_is_decimal_1() { - assert_eq!(Some(1), hexadecimal::hex_to_int("1")); -} - -#[test] -#[ignore] -fn test_hex_c_is_decimal_12() { - assert_eq!(Some(12), hexadecimal::hex_to_int("c")); -} - -#[test] -#[ignore] -fn test_hex_10_is_decimal_16() { - assert_eq!(Some(16), hexadecimal::hex_to_int("10")); -} - -#[test] -#[ignore] -fn test_hex_af_is_decimal_175() { - assert_eq!(Some(175), hexadecimal::hex_to_int("af")); -} - -#[test] -#[ignore] -fn test_hex_100_is_decimal_256() { - assert_eq!(Some(256), hexadecimal::hex_to_int("100")); -} - -#[test] -#[ignore] -fn test_hex_19ace_is_decimal_105166() { - assert_eq!(Some(105166), hexadecimal::hex_to_int("19ace")); -} - -#[test] -#[ignore] -fn test_invalid_hex_is_none() { - assert_eq!(None, hexadecimal::hex_to_int("carrot")); -} - -#[test] -#[ignore] -fn test_black() { - assert_eq!(Some(0), hexadecimal::hex_to_int("0000000")); -} - -#[test] -#[ignore] -fn test_white() { - assert_eq!(Some(16777215), hexadecimal::hex_to_int("ffffff")); -} - -#[test] -#[ignore] -fn test_yellow() { - assert_eq!(Some(16776960), hexadecimal::hex_to_int("ffff00")); -} diff --git a/exercises/nucleotide-codons/.gitignore b/exercises/nucleotide-codons/.gitignore deleted file mode 100644 index db7f315c0..000000000 --- a/exercises/nucleotide-codons/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercises/nucleotide-codons/Cargo.toml b/exercises/nucleotide-codons/Cargo.toml deleted file mode 100644 index 1619ea0cf..000000000 --- a/exercises/nucleotide-codons/Cargo.toml +++ /dev/null @@ -1,4 +0,0 @@ -[package] -edition = "2018" -name = "nucleotide_codons" -version = "0.1.0" diff --git a/exercises/nucleotide-codons/README.md b/exercises/nucleotide-codons/README.md deleted file mode 100644 index 10b5b4d6c..000000000 --- a/exercises/nucleotide-codons/README.md +++ /dev/null @@ -1,95 +0,0 @@ -# Nucleotide Codons - -Write a function that returns the name of an amino acid a particular codon, -possibly using shorthand, encodes for. - -In DNA sequences of 3 nucleotides, called codons, encode for amino acids. Often -several codons encode for the same amino acid. The International Union of Pure -and Applied Chemistry developed a shorthand system for designating groups of -codons that encode for the same amino acid. - -Simply put they've expanded the four letters A, C, G and T with a bunch of -letters that stand for different possibilities. For example R means A and G. -So TAR stands for TAA and TAG (think of "TAR" as "TA[AG]" in regex notation). - -Write some code that given a codon, which may use shorthand, returns the -name of the amino acid that that codon encodes for. You will be given -a list of non-shorthand-codon/name pairs to base your computation on. - -See: [wikipedia](https://en.wikipedia.org/wiki/DNA_codon_table). - -## 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, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run all tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the [online test documentation][rust-tests] - -Make sure to read the [Modules](https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html) chapter if you -haven't already, it will help you with organizing your files. - -## Further improvements - -After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution. - -To format your solution, inside the solution directory use - -```bash -cargo fmt -``` - -To see, if your solution contains some common ineffective use cases, inside the solution directory use - -```bash -cargo clippy --all-targets -``` - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The [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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html -[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/nucleotide-codons/example.rs b/exercises/nucleotide-codons/example.rs deleted file mode 100644 index 0577d8166..000000000 --- a/exercises/nucleotide-codons/example.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::collections::HashMap; - -pub struct CodonInfo<'a> { - actual_codons: HashMap<&'a str, &'a str>, -} - -pub fn parse<'a>(pairs: Vec<(&'a str, &'a str)>) -> CodonInfo<'a> { - CodonInfo { - actual_codons: pairs.into_iter().collect(), - } -} - -impl<'a> CodonInfo<'a> { - pub fn name_for(&self, codon: &str) -> Result<&'a str, &'static str> { - if codon.len() != 3 { - return Err("invalid length"); - } - - let mut valid = true; - let lookup: String = codon - .chars() - .map(|l| { - // Get an example of a "letter" represented by the possibly encoded letter. - // Since every codon represented by the compressed notation has to be of - // the desired amino acid just picking one at random will do. - match l { - 'A' | 'W' | 'M' | 'R' | 'D' | 'H' | 'V' | 'N' => 'A', - 'C' | 'S' | 'Y' | 'B' => 'C', - 'G' | 'K' => 'G', - 'T' => 'T', - _ => { - valid = false; - ' ' - } - } - }) - .collect(); - if !valid { - return Err("invalid char"); - } - - // If the input table is correct (which it is) every valid codon is in it - // so unwrap() shouldn't panic. - Ok(self.actual_codons.get(&lookup.as_ref()).unwrap()) - } -} diff --git a/exercises/nucleotide-codons/src/lib.rs b/exercises/nucleotide-codons/src/lib.rs deleted file mode 100644 index e64f2c0b8..000000000 --- a/exercises/nucleotide-codons/src/lib.rs +++ /dev/null @@ -1,32 +0,0 @@ -// This exercise is deprecated. -// Consider working on protein-translation instead. - -use std::marker::PhantomData; - -pub struct CodonsInfo<'a> { - // This field is here to make the template compile and not to - // complain about unused type lifetime parameter "'a". Once you start - // solving the exercise, delete this field and the 'std::marker::PhantomData' - // import. - phantom: PhantomData<&'a ()>, -} - -impl<'a> CodonsInfo<'a> { - pub fn name_for(&self, codon: &str) -> Result<&'a str, ()> { - unimplemented!( - "Return the protein name for a '{}' codon or Err, if codon string is invalid", - codon - ); - } - - pub fn of_rna(&self, rna: &str) -> Result, ()> { - unimplemented!("Return a list of protein names that correspond to the '{}' RNA string or Err if the RNA string is invalid", rna); - } -} - -pub fn parse<'a>(pairs: Vec<(&'a str, &'a str)>) -> CodonsInfo<'a> { - unimplemented!( - "Construct a new CodonsInfo struct from given pairs: {:?}", - pairs - ); -} diff --git a/exercises/nucleotide-codons/tests/codons.rs b/exercises/nucleotide-codons/tests/codons.rs deleted file mode 100644 index 2c784ce55..000000000 --- a/exercises/nucleotide-codons/tests/codons.rs +++ /dev/null @@ -1,117 +0,0 @@ -use nucleotide_codons as codons; - -#[test] -fn test_methionine() { - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("ATG"), Ok("methionine")); -} - -#[test] -#[ignore] -fn test_cysteine_tgt() { - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("TGT"), Ok("cysteine")); -} - -#[test] -#[ignore] -fn test_cysteine_tgy() { - // "compressed" name for TGT and TGC - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("TGT"), info.name_for("TGY")); - assert_eq!(info.name_for("TGC"), info.name_for("TGY")); -} - -#[test] -#[ignore] -fn test_stop() { - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("TAA"), Ok("stop codon")); -} - -#[test] -#[ignore] -fn test_valine() { - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("GTN"), Ok("valine")); -} - -#[test] -#[ignore] -fn test_isoleucine() { - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("ATH"), Ok("isoleucine")); -} - -#[test] -#[ignore] -fn test_arginine_name() { - // In arginine CGA can be "compressed" both as CGN and as MGR - let info = codons::parse(make_pairs()); - assert_eq!(info.name_for("CGA"), Ok("arginine")); - assert_eq!(info.name_for("CGN"), Ok("arginine")); - assert_eq!(info.name_for("MGR"), Ok("arginine")); -} - -#[test] -#[ignore] -fn empty_is_invalid() { - let info = codons::parse(make_pairs()); - assert!(info.name_for("").is_err()); -} - -#[test] -#[ignore] -fn x_is_not_shorthand_so_is_invalid() { - let info = codons::parse(make_pairs()); - assert!(info.name_for("VWX").is_err()); -} - -#[test] -#[ignore] -fn too_short_is_invalid() { - let info = codons::parse(make_pairs()); - assert!(info.name_for("AT").is_err()); -} - -#[test] -#[ignore] -fn too_long_is_invalid() { - let info = codons::parse(make_pairs()); - assert!(info.name_for("ATTA").is_err()); -} - -// The input data constructor. Returns a list of codon, name pairs. -fn make_pairs() -> Vec<(&'static str, &'static str)> { - let grouped = vec![ - ("isoleucine", vec!["ATT", "ATC", "ATA"]), - ("leucine", vec!["CTT", "CTC", "CTA", "CTG", "TTA", "TTG"]), - ("valine", vec!["GTT", "GTC", "GTA", "GTG"]), - ("phenylalanine", vec!["TTT", "TTC"]), - ("methionine", vec!["ATG"]), - ("cysteine", vec!["TGT", "TGC"]), - ("alanine", vec!["GCT", "GCC", "GCA", "GCG"]), - ("glycine", vec!["GGT", "GGC", "GGA", "GGG"]), - ("proline", vec!["CCT", "CCC", "CCA", "CCG"]), - ("threonine", vec!["ACT", "ACC", "ACA", "ACG"]), - ("serine", vec!["TCT", "TCC", "TCA", "TCG", "AGT", "AGC"]), - ("tyrosine", vec!["TAT", "TAC"]), - ("tryptophan", vec!["TGG"]), - ("glutamine", vec!["CAA", "CAG"]), - ("asparagine", vec!["AAT", "AAC"]), - ("histidine", vec!["CAT", "CAC"]), - ("glutamic acid", vec!["GAA", "GAG"]), - ("aspartic acid", vec!["GAT", "GAC"]), - ("lysine", vec!["AAA", "AAG"]), - ("arginine", vec!["CGT", "CGC", "CGA", "CGG", "AGA", "AGG"]), - ("stop codon", vec!["TAA", "TAG", "TGA"]), - ]; - let mut pairs = Vec::<(&'static str, &'static str)>::new(); - for (name, codons) in grouped.into_iter() { - for codon in codons { - pairs.push((codon, name)); - } - } - pairs.sort_by(|&(_, a), &(_, b)| a.cmp(b)); - return pairs; -} diff --git a/exercises/two-fer/.gitignore b/exercises/two-fer/.gitignore deleted file mode 100644 index db7f315c0..000000000 --- a/exercises/two-fer/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Generated by Cargo -# will have compiled files and executables -/target/ -**/*.rs.bk - -# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries -# More information here http://doc.crates.io/guide.html#cargotoml-vs-cargolock -Cargo.lock diff --git a/exercises/two-fer/Cargo.toml b/exercises/two-fer/Cargo.toml deleted file mode 100644 index 4f5f029ea..000000000 --- a/exercises/two-fer/Cargo.toml +++ /dev/null @@ -1,6 +0,0 @@ -[package] -edition = "2018" -name = "twofer" -version = "1.2.0" - -[dependencies] diff --git a/exercises/two-fer/README.md b/exercises/two-fer/README.md deleted file mode 100644 index 17c3335ec..000000000 --- a/exercises/two-fer/README.md +++ /dev/null @@ -1,106 +0,0 @@ -# Two Fer - -`Two-fer` or `2-fer` is short for two for one. One for you and one for me. - -Given a name, return a string with the message: - -```text -One for X, one for me. -``` - -Where X is the given name. - -However, if the name is missing, return the string: - -```text -One for you, one for me. -``` - -Here are some examples: - -|Name | String to return -|:------:|:-----------------: -|Alice | One for Alice, one for me. -|Bob | One for Bob, one for me. -| | One for you, one for me. -|Zaphod | One for Zaphod, one for me. - -## 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, open the tests source file which is located in the `tests` directory -and remove the `#[ignore]` flag from the next test and get the tests to pass -again. Each separate test is a function with `#[test]` flag above it. -Continue, until you pass every test. - -If you wish to run all tests without editing the tests source file, use: - -```bash -$ cargo test -- --ignored -``` - -To run a specific test, for example `some_test`, you can use: - -```bash -$ cargo test some_test -``` - -If the specific test is ignored use: - -```bash -$ cargo test some_test -- --ignored -``` - -To learn more about Rust tests refer to the [online test documentation][rust-tests] - -Make sure to read the [Modules](https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html) chapter if you -haven't already, it will help you with organizing your files. - -## Further improvements - -After you have solved the exercise, please consider using the additional utilities, described in the [installation guide](https://exercism.io/tracks/rust/installation), to further refine your final solution. - -To format your solution, inside the solution directory use - -```bash -cargo fmt -``` - -To see, if your solution contains some common ineffective use cases, inside the solution directory use - -```bash -cargo clippy --all-targets -``` - -## Submitting the solution - -Generally you should submit all files in which you implemented your solution (`src/lib.rs` in most cases). If you are using any external crates, please consider submitting the `Cargo.toml` file. This will make the review process faster and clearer. - -## Feedback, Issues, Pull Requests - -The [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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/ch07-02-modules-and-use-to-control-scope-and-privacy.html -[cargo]: https://doc.rust-lang.org/book/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/ch11-02-running-tests.html - -## Source - -[https://github.com/exercism/problem-specifications/issues/757](https://github.com/exercism/problem-specifications/issues/757) - -## Submitting Incomplete Solutions -It's possible to submit an incomplete solution so you can see how others have completed the exercise. diff --git a/exercises/two-fer/example.rs b/exercises/two-fer/example.rs deleted file mode 100644 index 7b4221dd6..000000000 --- a/exercises/two-fer/example.rs +++ /dev/null @@ -1,6 +0,0 @@ -pub fn twofer(name: &str) -> String { - match name { - "" => "One for you, one for me.".to_string(), - _ => format!("One for {}, one for me.", name), - } -} diff --git a/exercises/two-fer/src/lib.rs b/exercises/two-fer/src/lib.rs deleted file mode 100644 index 62086679a..000000000 --- a/exercises/two-fer/src/lib.rs +++ /dev/null @@ -1,3 +0,0 @@ -pub fn twofer(name: &str) -> String { - unimplemented!("One for {}, one for me.", name); -} diff --git a/exercises/two-fer/tests/two-fer.rs b/exercises/two-fer/tests/two-fer.rs deleted file mode 100644 index 29196cfb0..000000000 --- a/exercises/two-fer/tests/two-fer.rs +++ /dev/null @@ -1,18 +0,0 @@ -use twofer::twofer; - -#[test] -fn empty_string() { - assert_eq!(twofer(""), "One for you, one for me."); -} - -#[test] -#[ignore] -fn alice() { - assert_eq!(twofer("Alice"), "One for Alice, one for me."); -} - -#[test] -#[ignore] -fn bob() { - assert_eq!(twofer("Bob"), "One for Bob, one for me."); -}