From 0cef40fc952323bb9aae3d2c3fdb1747df812462 Mon Sep 17 00:00:00 2001 From: ZapAnton Date: Mon, 10 Dec 2018 13:05:49 +0300 Subject: [PATCH] two-fer, hexadecimal, nucleotide-codons: Removed the deprecated exercises --- exercises/hexadecimal/.gitignore | 8 -- exercises/hexadecimal/Cargo.toml | 3 - exercises/hexadecimal/README.md | 68 ------------ exercises/hexadecimal/example.rs | 33 ------ exercises/hexadecimal/src/lib.rs | 1 - exercises/hexadecimal/tests/hexadecimal.rs | 60 ---------- exercises/nucleotide-codons/.gitignore | 8 -- exercises/nucleotide-codons/Cargo.toml | 3 - exercises/nucleotide-codons/README.md | 75 ------------- exercises/nucleotide-codons/example.rs | 46 -------- exercises/nucleotide-codons/src/lib.rs | 1 - exercises/nucleotide-codons/tests/codons.rs | 117 -------------------- exercises/two-fer/.gitignore | 8 -- exercises/two-fer/Cargo.toml | 5 - exercises/two-fer/README.md | 86 -------------- exercises/two-fer/example.rs | 6 - exercises/two-fer/src/lib.rs | 3 - exercises/two-fer/tests/two-fer.rs | 19 ---- 18 files changed, 550 deletions(-) delete mode 100644 exercises/hexadecimal/.gitignore delete mode 100644 exercises/hexadecimal/Cargo.toml delete mode 100644 exercises/hexadecimal/README.md delete mode 100644 exercises/hexadecimal/example.rs delete mode 100644 exercises/hexadecimal/src/lib.rs delete mode 100644 exercises/hexadecimal/tests/hexadecimal.rs delete mode 100644 exercises/nucleotide-codons/.gitignore delete mode 100644 exercises/nucleotide-codons/Cargo.toml delete mode 100644 exercises/nucleotide-codons/README.md delete mode 100644 exercises/nucleotide-codons/example.rs delete mode 100644 exercises/nucleotide-codons/src/lib.rs delete mode 100644 exercises/nucleotide-codons/tests/codons.rs delete mode 100644 exercises/two-fer/.gitignore delete mode 100644 exercises/two-fer/Cargo.toml delete mode 100644 exercises/two-fer/README.md delete mode 100644 exercises/two-fer/example.rs delete mode 100644 exercises/two-fer/src/lib.rs delete mode 100644 exercises/two-fer/tests/two-fer.rs 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 313084bc0..000000000 --- a/exercises/hexadecimal/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -name = "hexadecimal" -version = "0.0.0" diff --git a/exercises/hexadecimal/README.md b/exercises/hexadecimal/README.md deleted file mode 100644 index 69ef4cd9d..000000000 --- a/exercises/hexadecimal/README.md +++ /dev/null @@ -1,68 +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/2018-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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/2018-edition/ch07-00-modules.html -[cargo]: https://doc.rust-lang.org/book/2018-edition/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/2018-edition/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 8b1378917..000000000 --- a/exercises/hexadecimal/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - 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 ff77d8534..000000000 --- a/exercises/nucleotide-codons/Cargo.toml +++ /dev/null @@ -1,3 +0,0 @@ -[package] -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 1c8e6b1e4..000000000 --- a/exercises/nucleotide-codons/README.md +++ /dev/null @@ -1,75 +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/2018-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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/2018-edition/ch07-00-modules.html -[cargo]: https://doc.rust-lang.org/book/2018-edition/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/2018-edition/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 8b1378917..000000000 --- a/exercises/nucleotide-codons/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/exercises/nucleotide-codons/tests/codons.rs b/exercises/nucleotide-codons/tests/codons.rs deleted file mode 100644 index acd310f1c..000000000 --- a/exercises/nucleotide-codons/tests/codons.rs +++ /dev/null @@ -1,117 +0,0 @@ -extern crate 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 c80ccc6a8..000000000 --- a/exercises/two-fer/Cargo.toml +++ /dev/null @@ -1,5 +0,0 @@ -[package] -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 ff76e3197..000000000 --- a/exercises/two-fer/README.md +++ /dev/null @@ -1,86 +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/2018-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]: https://exercism.io/tracks/rust/learning -[modules]: https://doc.rust-lang.org/book/2018-edition/ch07-00-modules.html -[cargo]: https://doc.rust-lang.org/book/2018-edition/ch14-00-more-about-cargo.html -[rust-tests]: https://doc.rust-lang.org/book/2018-edition/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 3946d7c11..000000000 --- a/exercises/two-fer/tests/two-fer.rs +++ /dev/null @@ -1,19 +0,0 @@ -extern crate twofer; -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."); -}