From beaf4c8753c813a0951cf1c797eb97a2012757d0 Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 16 Mar 2021 01:56:54 +0000 Subject: [PATCH] first pass --- subjects/diamond_creation/README.md | 16 +++++++++------- subjects/logic_number/README.md | 20 ++++++++++---------- subjects/ordinal/README.md | 6 ++++-- subjects/pangram/README.md | 14 ++++++++------ subjects/pig_latin/README.md | 14 ++++++++------ subjects/rgb_match/README.md | 24 +++++++++++++----------- subjects/rot/README.md | 17 +++++++++-------- subjects/scores/README.md | 10 ++++++---- subjects/searching/README.md | 13 ++++++++----- subjects/spelling/README.md | 14 +++++++++----- subjects/stars/README.md | 6 ++++-- subjects/talking/README.md | 14 ++++++++------ 12 files changed, 96 insertions(+), 72 deletions(-) diff --git a/subjects/diamond_creation/README.md b/subjects/diamond_creation/README.md index 256848404..9cead7012 100644 --- a/subjects/diamond_creation/README.md +++ b/subjects/diamond_creation/README.md @@ -2,7 +2,7 @@ ### Instructions -Complete the function "make_diamond" that takes a letter as input, and outputs it in a diamond shape. +Build the **function** `make_diamond` which takes a letter as input, and outputs it in a diamond shape. Rules: @@ -17,12 +17,14 @@ Rules: ### Notions -- https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html +- [pattern syntax](https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html) ### Expected functions ```rust -pub fn get_diamond(c: char) -> Vec {} +pub fn get_diamond(c: char) -> Vec { + +} ``` ### Usage @@ -30,15 +32,15 @@ pub fn get_diamond(c: char) -> Vec {} Here is a program to test your function. ```rust -use diamond_creation::diamond_creation; +use diamond_creation::*; fn main() { - println!("{:?}", make_diamond('A')); - println!("{:?}", make_diamond('C')); + println!("{:?}", get_diamond('A')); + println!("{:?}", get_diamond('C')); } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/logic_number/README.md b/subjects/logic_number/README.md index 20ab1f5fe..f4cfda402 100644 --- a/subjects/logic_number/README.md +++ b/subjects/logic_number/README.md @@ -2,12 +2,10 @@ ### Instructions -In this exercise it will be given an example of a sequence of numbers. +In this exercise the logic of sequence of numbers will be tested. +For this you have to create a function `number_logic` which will take a number `u32` and return `true` if the number is the sum of its own digits, each raised to the power of the number of digits, and `false` otherwise. -Your purpose is to determinate if the sequence returns true or false. -For this you have to create a function `number_logic` that will take a number `u32` and return true if the number is the sum of its own digits, each raised to the power of the number of digits, and false otherwise. - -Example: +Examples: - 9 returns true, because 9 = 9^1 = 9 - 10 returns false, because 10 != 1^2 + 0^2 = 1 @@ -16,12 +14,14 @@ Example: ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) -### Expected functions +### Expected function ```rust -pub fn number_logic(num: u32) -> bool {} +pub fn number_logic(num: u32) -> bool { + +} ``` ### Usage @@ -29,7 +29,7 @@ pub fn number_logic(num: u32) -> bool {} Here is a program to test your function. ```rust -use logic_number::logic_number; +use logic_number::*; fn main() { let array = [9, 10, 153, 154]; @@ -48,7 +48,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/ordinal/README.md b/subjects/ordinal/README.md index 40cedd788..4e6e1bcd5 100644 --- a/subjects/ordinal/README.md +++ b/subjects/ordinal/README.md @@ -7,7 +7,9 @@ Complete the function "num_to_ordinal" that receives a cardinal number and retur ### Expected functions ```rust -pub fn num_to_ordinal(x: u32) -> String {} +pub fn num_to_ordinal(x: u32) -> String { + +} ``` ### Usage @@ -15,7 +17,7 @@ pub fn num_to_ordinal(x: u32) -> String {} Here is a program to test your function. ```rust -use ordinal::ordinal; +use ordinal::*; fn main() { println!("{}", num_to_ordinal(1)); diff --git a/subjects/pangram/README.md b/subjects/pangram/README.md index dbe6005de..f59687d0e 100644 --- a/subjects/pangram/README.md +++ b/subjects/pangram/README.md @@ -2,9 +2,9 @@ ### Instructions -Determine if the string is a pangram. +Create a `function` is_pangram which will determine whether or not a string is a pangram. -A pangram is a sentence using every letter of the alphabet at least once. +A pangram is a sentence which uses every letter of the alphabet at least once. Example: @@ -12,12 +12,14 @@ Example: ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn is_pangram(s: &str) -> bool {} +pub fn is_pangram(s: &str) -> bool { + +} ``` ### Usage @@ -25,7 +27,7 @@ pub fn is_pangram(s: &str) -> bool {} Here is a program to test your function. ```rust -use pangram::pangram; +use pangram::*; fn main() { println!( @@ -36,7 +38,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/pig_latin/README.md b/subjects/pig_latin/README.md index dae634582..9b032b500 100644 --- a/subjects/pig_latin/README.md +++ b/subjects/pig_latin/README.md @@ -2,22 +2,24 @@ ### Instructions -Write a function that transforms a string passed as argument in its `Pig Latin` version. +Write a **function** that transforms a string passed as argument in its `Pig Latin` version. The rules used by Pig Latin are the following: - If a word begins with a vowel, just add "ay" to the end. -- If it begins with a consonant, then we take all consonants before the first vowel and we put them on the end of the word and add "ay" at the end. +- If it begins with a consonant, then we take all consonants before the first vowel and we put them at the end of the word and add "ay" at the end. - If a word starts with a consonant followed by "qu", move it to the end of the word, and then add an "ay" at the end. ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn pig_latin(text: &str) -> String {} +pub fn pig_latin(text: &str) -> String { + +} ``` ### Usage @@ -25,7 +27,7 @@ pub fn pig_latin(text: &str) -> String {} Here is a program to test your function. ```rust -use pig_latin::pig_latin; +use pig_latin::*; fn main() { println!("{}", pig_latin(&String::from("igloo"))); @@ -37,7 +39,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/rgb_match/README.md b/subjects/rgb_match/README.md index 74f2035d5..621a429df 100644 --- a/subjects/rgb_match/README.md +++ b/subjects/rgb_match/README.md @@ -7,14 +7,23 @@ This function must allow you to swap the values of the struct. ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust +pub struct Color { + pub r: u8, + pub g: u8, + pub b: u8, + pub a: u8, +} + impl Color { - pub fn swap(mut self, first: u8, second: u8) -> Color {} + pub fn swap(mut self, first: u8, second: u8) -> Color { + } +} ``` ### Usage @@ -22,14 +31,7 @@ impl Color { Here is a program to test your function. ```rust -use rgb_match::rgb_match; - -struct Color { - r: u8, - g: u8, - b: u8, - a: u8, -} +use rgb_match::*; fn main() { let c = Color { @@ -57,7 +59,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/rot/README.md b/subjects/rot/README.md index 01c8b075a..17b718c88 100644 --- a/subjects/rot/README.md +++ b/subjects/rot/README.md @@ -2,7 +2,7 @@ ### Instructions -By now you will have the knowledge of the so called rotational cipher "ROT13". +In this exercise, if you do not know about it already, you will learn about the rotational cipher "ROT13". A ROT13 on the Latin alphabet would be as follows: @@ -12,19 +12,21 @@ A ROT13 on the Latin alphabet would be as follows: Your purpose in this exercise is to create a similar `rotate` function that is a better version of the ROT13 cipher. -Your function will receive a string and a number and it will rotate each letter of that string the number of times settled by the second argument to the right, or to the left if the number are negative. +Your function will receive a `string` and a `number` and it will rotate each letter of that `string` by the `number` of times settled by the second argument towards the right, or towards the left if the number is negative. -Your function should only change letters. If the string includes punctuation and numbers +Your `function` should only rotate letters. If the string includes punctuation and numbers they will remain the same. ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn rotate(input: &str, key: i8) -> String {} +pub fn rotate(input: &str, key: i8) -> String { + +} ``` ### Usage @@ -32,7 +34,7 @@ pub fn rotate(input: &str, key: i8) -> String {} Here is a program to test your function. ```rust -use rot::rot; +use rot::*; fn main() { @@ -58,7 +60,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run @@ -72,6 +74,5 @@ The decoded message is: Ryg aesmuvi nkpd tewzsxq jolbkc foh Your cypher wil be: Xiwxmrk amxl ryqfivw 1 2 3 Your cypher wil be: Fqefuzs The letter "a" becomes: z - student@ubuntu:~/[[ROOT]]/test$ ``` diff --git a/subjects/scores/README.md b/subjects/scores/README.md index e12654c1c..6c5a64be5 100644 --- a/subjects/scores/README.md +++ b/subjects/scores/README.md @@ -8,7 +8,7 @@ Create a function `score` that given a string, computes the score for that given Each letter has their value, you just have to sum the values of the letters in the given string. -You'll need these: +You will need these: | Letter | Value | | ---------------------------- | :---: | @@ -22,12 +22,14 @@ You'll need these: ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn score(word: &str) -> u64 {} +pub fn score(word: &str) -> u64 { + +} ``` ### Usage @@ -35,7 +37,7 @@ pub fn score(word: &str) -> u64 {} Here is a program to test your function. ```rust -use scores::scores; +use scores::*; fn main() { println!("{}", score("a")); diff --git a/subjects/searching/README.md b/subjects/searching/README.md index 40a15b7c1..ea3ca241a 100644 --- a/subjects/searching/README.md +++ b/subjects/searching/README.md @@ -3,17 +3,20 @@ ### Instructions In this exercise you will have to complete the function `search`. -this function receives an array and a key of `i32`, then it will return the position +This **function** receives an array and a key of `i32`, then it will return the position of the given key in the array. +Only arrays with uniques keys will be tested. ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn search(array: &[i32], key: i32) -> Option {} +pub fn search(array: &[i32], key: i32) -> Option { + +} ``` ### Usage @@ -21,7 +24,7 @@ pub fn search(array: &[i32], key: i32) -> Option {} Here is a program to test your function. ```rust -use searching::searching; +use searching::*; fn main() { let ar = [1, 3, 4, 6, 8, 9, 11]; @@ -33,7 +36,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/spelling/README.md b/subjects/spelling/README.md index d5992d49c..20e9fb471 100644 --- a/subjects/spelling/README.md +++ b/subjects/spelling/README.md @@ -16,14 +16,18 @@ So, if the program generates the number: - 1002 your function will return the string "one thousand two". - 1000000 your function will return the string "one million" +Only positive numbers will be tested. (Up to a million). + ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) -### Expected functions +### Expected function ```rust -pub fn spell(n: u64) -> String {} +pub fn spell(n: u64) -> String { + +} ``` ### Usage @@ -31,7 +35,7 @@ pub fn spell(n: u64) -> String {} Here is a program to test your function. ```rust -use spelling::spelling; +use spelling::*; fn main() { println!("{}", spell(348)); @@ -39,7 +43,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/stars/README.md b/subjects/stars/README.md index 86ae66d57..7ec062635 100644 --- a/subjects/stars/README.md +++ b/subjects/stars/README.md @@ -8,7 +8,9 @@ parameter and returns a string of stars (asterisks) 2^n long (2 to the nth power ### Expected functions ```rust -pub fn stars(n: u32) -> String {} +pub fn stars(n: u32) -> String { + +} ``` ### Usage @@ -25,7 +27,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run diff --git a/subjects/talking/README.md b/subjects/talking/README.md index 129c64824..81488dd0c 100644 --- a/subjects/talking/README.md +++ b/subjects/talking/README.md @@ -2,12 +2,12 @@ ### Instructions -Build the function `talking` that will allow you to talk with your computer. +Build the function `talking` which will allow you to talk with your computer. His answers will be created by you following the rules below. - He answers "There is no need to yell, calm down!" if you yell at him, for example "LEAVE ME ALONE!" -(it is consider yelling when the sentence is all written in capital letters). +(it is considered yelling when the sentence is all written in capital letters). - He answers "Sure" if you ask him something without yelling, for example "Is everything ok with you?" - He answers "Quiet, I am thinking!" if you yell a question at him. "HOW ARE YOU?" - He says "Just say something!" if you address him without actually saying anything. @@ -15,12 +15,14 @@ His answers will be created by you following the rules below. ### Notions -- https://doc.rust-lang.org/book/ch18-00-patterns.html +- [patterns](https://doc.rust-lang.org/book/ch18-00-patterns.html) ### Expected functions ```rust -pub fn talking(text: &str) -> &str {} +pub fn talking(text: &str) -> &str { + +} ``` ### Usage @@ -28,7 +30,7 @@ pub fn talking(text: &str) -> &str {} Here is a program to test your function. ```rust -use talking::talking; +use talking::*; fn main() { println!("{:?}", talking("JUST DO IT!")); @@ -39,7 +41,7 @@ fn main() { } ``` -And its output +And its output: ```console student@ubuntu:~/[[ROOT]]/test$ cargo run