Browse Source

safeguarding

content-update
Chris 3 years ago
parent
commit
f943014e25
  1. 12
      subjects/capitalizing/README.md
  2. 24
      subjects/hashing/README.md
  3. 13
      subjects/string_permutation/README.md
  4. 4
      subjects/to_url/README.md

12
subjects/capitalizing/README.md

@ -2,11 +2,11 @@
### Instructions ### Instructions
Complete the `capitalize_first` function that turns the first letter of a string uppercase. Complete the `capitalize_first` **function** which turns the first letter of a string to uppercase.
Complete the `title_case` function that turns the first letter of each word in a string uppercase. Complete the `title_case` **function** which turns the first letter of each word in a string to uppercase.
Complete the `change_case` function that turns the uppercase letters of a string into lowercase and the lowercase letters into uppercase. Complete the `change_case` **function** which turns the uppercase letters of a string into lowercase and the lowercase letters into uppercase.
### Expected Functions ### Expected Functions
@ -23,10 +23,10 @@ pub fn change_case(input: &str) -> String {
### Usage ### Usage
Here is a program to test your function. Here is a program to test your functions.
```rust ```rust
use capitalizing::capitalizing; use capitalizing::*capitalizing*;
fn main() { fn main() {
println!("{}", capitalize_first("joe is missing")); println!("{}", capitalize_first("joe is missing"));
@ -37,7 +37,7 @@ fn main() {
And its output And its output
```console ```consoole
student@ubuntu:~/[[ROOT]]/test$ cargo run student@ubuntu:~/[[ROOT]]/test$ cargo run
Joe is missing Joe is missing
Jill Is Leaving A Jill Is Leaving A

24
subjects/hashing/README.md

@ -2,25 +2,29 @@
### Instructions ### Instructions
Given a list of integers (Vec<i32>) write three functions Given a list of integers (Vec<i32>) write three **functions**.
Write a function called `mean` that calculates the `mean` (the average value) of all the values in the list Write a **function** called `mean` that calculates the `mean` (the average value) of all the values in the list.
Write a function called `median` that calculates the `median` (for a sorted list is the value in the middle) Write a **function** called `median` that calculates the `median` (for a sorted list, it is the value in the middle).
Write a function called `mode` that calculates the mode (the value Write a **function** called `mode` that calculates the mode (the value
that appears more often) that appears more often).
### Notions
[hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)
### Expected Functions ### Expected Functions
```rust ```rust
fn mean(list: &Vec<i32>) -> f64 { pub fn mean(list: &Vec<i32>) -> f64 {
} }
fn median(list: &Vec<i32>) -> i32 { pub fn median(list: &Vec<i32>) -> i32 {
} }
fn mode(list: &Vec<i32>) -> i32 { pub fn mode(list: &Vec<i32>) -> i32 {
} }
``` ```
@ -29,7 +33,7 @@ fn mode(list: &Vec<i32>) -> i32 {
Here is a program to test your function. Here is a program to test your function.
```rust ```rust
use hashing; use hashing::*;
fn main() { fn main() {
println!("Hello, world!"); println!("Hello, world!");
@ -40,7 +44,7 @@ fn main() {
} }
``` ```
And its output And its output;
```console ```console
student@ubuntu:~/[[ROOT]]/test$ cargo run student@ubuntu:~/[[ROOT]]/test$ cargo run

13
subjects/string_permutation/README.md

@ -2,12 +2,19 @@
### Instructions ### Instructions
Define the function `is_permutation` that returns true if the string `s1` is a permutation of `s2`, otherwise it returns false `s1` is a permutation of `s2` if all the elements in `s1` appear the same number of times in `s2` and all the characters in `s1` appear in `s2` even if in different order) Define the **function** `is_permutation` that returns true if:
- the string `s1` is a permutation of `s2`, otherwise it returns false.
- `s1` is a permutation of `s2` if all the elements in `s1` appear the same number of times in `s2` and all the characters in `s1` appear in `s2` even if they are in different order.
### Notions
[hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)
### Expected Function ### Expected Function
```rust ```rust
fn is_permutation(s1: &str, s2: &str) -> bool { pub fn is_permutation(s1: &str, s2: &str) -> bool {
} }
``` ```
@ -16,6 +23,8 @@ fn is_permutation(s1: &str, s2: &str) -> bool {
Here is a program to test your function. Here is a program to test your function.
```rust ```rust
use string_permutation::*;
fn main() { fn main() {
let word = "thought"; let word = "thought";
let word1 = "thougth"; let word1 = "thougth";

4
subjects/to_url/README.md

@ -2,7 +2,7 @@
### Instructions ### Instructions
Define a function called `to_url` that takes a string and substitutes every white-space with '%20' Define a **function** called `to_url` that takes a string and substitutes every white-space with '%20'.
### Expected Function ### Expected Function
@ -16,6 +16,8 @@ pub fn to_url(s: &str) -> String {
Here is a program to test your function. Here is a program to test your function.
```rust ```rust
use to_url::*;
fn main() { fn main() {
let s = "Hello, world!"; let s = "Hello, world!";
println!("{} to be use as an url is {}", s, to_url(s)); println!("{} to be use as an url is {}", s, to_url(s));

Loading…
Cancel
Save