Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions subjects/diamond_creation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,24 @@

Build the **function** `make_diamond` which takes a letter as an input, and returns a diamond.

> Assume the input is always a valid uppercase letter.

Rules:

- The first and last row contain one 'A'.
- The given letter has to be at the widest point.
- All rows, except the first and last, have exactly two identical letters.
- All rows have as many trailing spaces as leading spaces. This may be 0.
- The diamond is vertically symmetrical, and horizontally symmetrical.
- The width of the diamond equals its height.
- The diamond is both vertically and horizontally symmetrical.
- The width and height of the diamond are equal.
- The top half has letters in ascending order (abcd).
- The bottom half has letters in descending order (dcba).

### Expected functions

```rust
pub fn get_diamond(c: char) -> Vec<String> {

todo!()
}
```

Expand All @@ -45,11 +47,11 @@ And its output:
$ cargo run
["A"]
[" A ", " B B ", "C C", " B B ", " A "]
A
B B
A
B B
C C
B B
A
B B
A
$
```

Expand Down
3 changes: 3 additions & 0 deletions subjects/luhn_algorithm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ So we will get:

```rust
pub fn is_luhn_formula(code: &str) -> bool {
todo!()
}
```

Expand All @@ -41,6 +42,8 @@ pub fn is_luhn_formula(code: &str) -> bool {
Here is a possible program to test your function,

```rust
use luhn_algorithm::is_luhn_formula;

fn main() {
println!("{}", is_luhn_formula(""));
println!("{}", is_luhn_formula("1"));
Expand Down
2 changes: 1 addition & 1 deletion subjects/pangram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Example: "The quick brown fox jumps over the lazy dog."

```rust
pub fn is_pangram(s: &str) -> bool {

todo!()
}
```

Expand Down
18 changes: 9 additions & 9 deletions subjects/pig_latin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Create a **function** which transforms the string passed as an argument into Pig

- 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, move them to the end of the word, and then 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.
- If a word starts with a consonant followed by "qu", move these three characters to the end of the word, and then add an "ay" at the end.
- Only the latin vowels will be considered as vowels (aeiou).

### Expected functions

```rust
pub fn pig_latin(text: &str) -> String {

todo!()
}
```

Expand All @@ -25,13 +25,13 @@ Here is a program to test your function.
use pig_latin::*;

fn main() {
println!("{}", pig_latin(&String::from("igloo")));
println!("{}", pig_latin(&String::from("apple")));
println!("{}", pig_latin(&String::from("hello")));
println!("{}", pig_latin(&String::from("square")));
println!("{}", pig_latin(&String::from("xenon")));
println!("{}", pig_latin(&String::from("chair")));
println!("{}", pig_latin(&String::from("queen")));
println!("{}", pig_latin("igloo"));
println!("{}", pig_latin("apple"));
println!("{}", pig_latin("hello"));
println!("{}", pig_latin("square"));
println!("{}", pig_latin("xenon"));
println!("{}", pig_latin("chair"));
println!("{}", pig_latin("queen"));
}
```

Expand Down
2 changes: 1 addition & 1 deletion subjects/rgb_match/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Color {

impl Color {
pub fn swap(mut self, first: u8, second: u8) -> Color {

todo!()
}
}
```
Expand Down
3 changes: 2 additions & 1 deletion subjects/rot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
In this exercise, if you do not know about it already, you will learn about the rotational cipher "ROT13".

A ROT13 applied the Latin alphabet:

```
- Plain: abcdefghijklmnopqrstuvwxyz
||||||||||||||||||||||||||
Expand All @@ -21,7 +22,7 @@ Only letters should be rotated. Numbers and punctuation should be left unchanged

```rust
pub fn rotate(input: &str, key: i8) -> String {

todo!()
}
```

Expand Down
4 changes: 2 additions & 2 deletions subjects/scores/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Let's play a little.

Create a function named `score` that given a `&str`, computes the score for that given string as a `u64`.

Each letter has a value, you just have to sum the values of the letters in the given string.
Each letter has a value, you just have to sum the values of the letters in the given string. Each letter has its own assigned value, independently of being uppercase or lowercase.

You will need these:
This table showcases the assigned value for each letter:

| Letter | Value |
| ---------------------------- | :---: |
Expand Down
12 changes: 6 additions & 6 deletions subjects/scytale_cipher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

Create a **function** which creates a scytale cipher (also known as spartan cipher).

In practice, it is represented by a strip wrapped around a cylinder. The message is written across the loops of the strip (not along the strip). The message becomes *coded* if the radius of the cylinder changes, or the strip is removed from the cylinder.
In practice, it is represented by a strip wrapped around a cylinder. The message is written across the loops of the strip (not along the strip). The message becomes _coded_ if the radius of the cylinder changes, or the strip is removed from the cylinder.

Your function should recreate the scytale cipher, so that the `String` represents the message, and the `u32` represents the number of times the strip is wrapped around the cylinder.
Your function should recreate the scytale cipher, so that the `&str` represents the message, and the `usize` represents the number of times the strip is wrapped around the cylinder.

### Example

Expand All @@ -21,7 +21,6 @@ Your function should recreate the scytale cipher, so that the `String` represent

**size 8:** `"scytale Code"` -> `"sCcoydtea l e"`


```console
------------------------------------------
|s| |c| |y| |t| |a| |l| |e| | |
Expand All @@ -32,7 +31,8 @@ Your function should recreate the scytale cipher, so that the `String` represent
### Expected Functions

```rust
fn scytale_cipher(message: String, i: u32) -> String {
fn scytale_cipher(message: &str, i: usize) -> String {
todo!()
}
```

Expand All @@ -42,8 +42,8 @@ Here is a program to test your function

```rust
fn main() {
println!("\"scytale Code\" size=6 -> {:?}", scytale_cipher(String::from("scytale Code"), 6)));
println!("\"scytale Code\" size=8 -> {:?}", scytale_cipher(String::from("scytale Code"), 8)));
println!("\"scytale Code\" size=6 -> {:?}", scytale_cipher("scytale Code", 6)));
println!("\"scytale Code\" size=8 -> {:?}", scytale_cipher("scytale Code", 8)));
}
```

Expand Down
13 changes: 6 additions & 7 deletions subjects/searching/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

### Instructions

Complete the function `search`. It should return the index of the element which matches `key` in the array.
> Only arrays with unique elements will be tested.
Complete the function `search`. It should return the index of the **last** element which matches `key` in the array.

### Expected functions

```rust
pub fn search(array: &[i32], key: i32) -> Option<usize> {

todo!()
}
```

Expand All @@ -21,10 +20,10 @@ Here is a program to test your function.
use searching::*;

fn main() {
let ar = [1, 3, 4, 6, 8, 9, 11];
let f = search(&ar, 6);
let ar = [1, 3, 4, 6, 8, 9, 11, 8];
let f = search(&ar, 8);
println!(
"the element 6 is in the position {:?} in the array {:?}",
"the element 8 is last in the position {:?} in the array {:?}",
f, ar
);
}
Expand All @@ -34,7 +33,7 @@ And its output:

```console
$ cargo run
the element 6 is in the position Some(3) in the array [1, 3, 4, 6, 8, 9, 11]
the element 8 is in the position Some(7) in the array [1, 3, 4, 6, 8, 9, 11, 8]
$
```

Expand Down
12 changes: 6 additions & 6 deletions subjects/spelling/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

### Instructions

In this exercise, you'll create the function `spell` that will spell a generated number.
In this exercise, you'll create the function `spell` that will spell out a generated number.

Here are some examples of what your function should return:

- `1` -> `"one"`
- `14` -> `"fourteen".`
- `14` -> `"fourteen"`
- `96` -> `"ninety-six"`
- `100` -> `"one hundred".`
- `100` -> `"one hundred"`
- `101` -> `"one hundred one"`
- `348` -> `"three hundred forty-eight"`
- `1002` -> `"one thousand two".`
- `1002` -> `"one thousand two"`
- `1000000` -> `"one million"`

> Only positive numbers will be tested, up to `"one million"`.
> Only positive numbers will be tested, up to `1_000_000` (one million).

### Expected function

```rust
pub fn spell(n: u64) -> String {

todo!()
}
```

Expand Down
2 changes: 1 addition & 1 deletion subjects/stars/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

### Instructions

Create a function named `stars` that takes a `u32` as an argument and returns a `String` of stars (asterisks). The number of stars returned is 2^n (2 to the nth power).
Create a function named `stars` that takes a `u32` as an argument and returns a `String` of stars (asterisks). The number of stars returned is 2^n (2 to the `n`th power).

### Expected functions

Expand Down
8 changes: 4 additions & 4 deletions subjects/talking/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ Build the function `talking` which will allow you to talk with your computer.

Its answers will be created by you following the rules below.

- It answers `"There is no need to yell, calm down!"` if you yell at it. For example `"LEAVE ME ALONE!"`. Yelling is when all the letters are capital letters.
- It answers `"There is no need to yell, calm down!"` if you yell at it. For example `"LEAVE ME ALONE!"`. It considers yelling when all the letters are uppercase.
- It answers `"Sure."` if you ask it something without yelling. For example `"Is everything ok with you?"`.
- It answers `"Quiet, I am thinking!"` if you yell a question at it. FOr example: `"HOW ARE YOU?"`.
- It says `"Just say something!"` if you address it without actually saying anything.
- It answers `"Quiet, I am thinking!"` if you yell a question at it. For example: `"HOW ARE YOU?"`.
- It says `"Just say something!"` if you don't say anything.
- It answers `"Interesting"` to anything else.

### Expected functions

```rust
pub fn talking(text: &str) -> &str {

todo!()
}
```

Expand Down
Loading