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
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
@ -23,10 +23,10 @@ pub fn change_case(input: &str) -> String {
### Usage
Here is a program to test your function.
Here is a program to test your functions.
```rust
use capitalizing::capitalizing;
use capitalizing::*capitalizing*;
fn main() {
println!("{}", capitalize_first("joe is missing"));
@ -37,7 +37,7 @@ fn main() {
And its output
```console
```consoole
student@ubuntu:~/[[ROOT]]/test$ cargo run
Joe is missing
Jill Is Leaving A

24
subjects/hashing/README.md

@ -2,25 +2,29 @@
### 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
that appears more often)
Write a **function** called `mode` that calculates the mode (the value
that appears more often).
### Notions
[hash maps](https://doc.rust-lang.org/book/ch08-03-hash-maps.html)
### Expected Functions
```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.
```rust
use hashing;
use hashing::*;
fn main() {
println!("Hello, world!");
@ -40,7 +44,7 @@ fn main() {
}
```
And its output
And its output;
```console
student@ubuntu:~/[[ROOT]]/test$ cargo run

13
subjects/string_permutation/README.md

@ -2,12 +2,19 @@
### 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
```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.
```rust
use string_permutation::*;
fn main() {
let word = "thought";
let word1 = "thougth";

4
subjects/to_url/README.md

@ -2,7 +2,7 @@
### 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
@ -16,6 +16,8 @@ pub fn to_url(s: &str) -> String {
Here is a program to test your function.
```rust
use to_url::*;
fn main() {
let s = "Hello, world!";
println!("{} to be use as an url is {}", s, to_url(s));

Loading…
Cancel
Save