Skip to content

Commit

Permalink
adds table of chairs and fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
YOUR_GITHUB_USERNAME authored and YOUR_GITHUB_USERNAME committed Apr 5, 2023
1 parent 1af51d3 commit fd5d3a2
Show file tree
Hide file tree
Showing 88 changed files with 198 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 05_table_of_chairs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "table_of_chairs"
version = "0.1.0"
edition = "2021"

[dependencies]

[dev-dependencies]

1 change: 1 addition & 0 deletions 05_table_of_chairs/Hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Try using the [cli-table](https://crates.io/crates/clii-talbe) crate!
46 changes: 46 additions & 0 deletions 05_table_of_chairs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Table of Chairs
Create a cli tool that prints data in a nice tabular format!

<br/>

## Backstory
Imagine you are the officer manager for, and have a to buy lots of chairs. You would like to view the data in a nice spreadsheet-like table rather than just a blob of json.

This code can serve as a proof-of-concept for any cli-tool that needs to output a lot of data in a visually appealing format with nice rows, columns, and column headers.

<br/>

## The Exercise
The exercise is to visually display chair data in a nice table so that it looks something like this:

```
+--------------------------------+---------+-----------+----------+
| Name | Price | Color | Quantity |
+--------------------------------+---------+-----------+----------+
| Ergonomic Office Chair | $199.99 | Black | 20 |
+--------------------------------+---------+-----------+----------+
| Bucket Seat Gaming Chair | $249.99 | Turquoise | 3 |
+--------------------------------+---------+-----------+----------+
| Curl Swivel Accent Chair | $407.96 | Orange | 2 |
+--------------------------------+---------+-----------+----------+
| Velvet High Back Rocking Chair | $113.99 | Blue | 1 |
+--------------------------------+---------+-----------+----------+
| Velvet High Back Rocking Chair | $27.99 | Grey | 5 |
+--------------------------------+---------+-----------+----------+"
```

Feel free to hardcode the chair data as structs, arrays, or vectors.

<br/>

## Tests
It's up to you to decide how you would unit test this code.

Write some integration tests that verify that the console output contains the correct data, nicely displayed in a tabular format.
<br/>

## Skills Practiced

- Displaying data in the terminal console as a table

<br/>
3 changes: 3 additions & 0 deletions 05_table_of_chairs/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
todo!("replace this line with your code!")
}
5 changes: 5 additions & 0 deletions 05_table_of_chairs/tests/table_of_chairs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[test]
fn prints_data_in_a_table() -> Result<(), Box<dyn std::error::Error>> {
todo!("put your integration test code here!");
Ok(())
}
9 changes: 9 additions & 0 deletions 06_fibonacci/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "fibonacci"
version = "0.1.0"
edition = "2021"

[dependencies]

[dev-dependencies]

1 change: 1 addition & 0 deletions 06_fibonacci/Hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Try using the [cli-table](https://crates.io/crates/clii-talbe) crate!
28 changes: 28 additions & 0 deletions 06_fibonacci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Fibonacci
Create a cli tool that prints a number from the fibonacci sequence!

<br/>

## Backstory
Imagine you want to know what the 100th element in the fibonacci sequence. What about the 1000th? You decide to craete a cli tool that will print this information.

_This project can serve as a proof-of-concept for any Rust code that needs to recursively call a function!_

<br/>

## The Exercise
The exercise is to write a cli tool that accepts a positive integer as an argument and returns the number at that index of the [fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_sequence).

<br/>

## Tests
It's up to you to decide how you would unit test this code.

Write some integration tests that verify that the console output contains the correct number from the fibonacci sequence based on the input integer.
<br/>

## Skills Practiced

- Recursive function calls

<br/>
3 changes: 3 additions & 0 deletions 06_fibonacci/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
todo!("replace this line with your code!")
}
5 changes: 5 additions & 0 deletions 06_fibonacci/tests/table_of_chairs.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#[test]
fn prints_data_in_a_table() -> Result<(), Box<dyn std::error::Error>> {
todo!("put your integration test code here!");
Ok(())
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions 10_yes_or_no/Hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Try using a `Confirm` prompt from the [inquire](https://crates.io/crates/inquire) crate!
40 changes: 40 additions & 0 deletions 10_yes_or_no/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Yes or No
Create a cli tool that asks the user a yes or no question!

<br/>

## Backstory
Imagine you want to make a cli tool that can ask the user questions and stop, waiting for the user to enter some input.

Sometimes the user doesn't always want to pass in _everything_ as args when running the cli tool. Prompting the user for input is a key skill to have in your toolbag for creating polished cli tools with a nice user experience!

<br/>

## The Exercise
Create a cli tool that simply asks the user the question, "yes or no".

After the question is printed the console should hang and wait for a user input.

The question should end by displaying [y/N] with the N capitalized to signify that it is the default input if the user simply presses the enter key without typing any text.

The cli tool should read these inputs as a "yes": y, Y, yes, Yes, YES...

The cli tool should read these inputs as a "no": n, N, no, No, NO...

After the user submits a choice either "You said yes!" or "You say no..." should be printed to the console.

<br/>

## Tests
It's up to you to decide how to unit test this code.

Write an integration test that simulates sending various inputs as a response to the yes or no question and verifies that the correct output is printed to the console.
<br/>

## Skills Practiced

- Prompting the user for input

- Simulating keystroke events in integration tests

<br/>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions 13_random_number_gen/Hint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Try using the [rand](https://crates.io/crates/rand) crate to generate random numbers!
46 changes: 46 additions & 0 deletions 13_random_number_gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Random Number Generator
Create a cli tool that generates random numbers!

<br/>

## Backstory
Imagine you want to make a cli tool is not totally deterministic but rather incoporates some element of randomness to spice things up!

The idea is that this code can serve as a proof-of-concept any Rust project where want to generate some random integer or floating point number.

<br/>

## The Exercise
The exercise is to create two functions, one that makes random integer numbers and one that makes random float numbers.

The integer function should take a lower bound and an upper bound, and the generated number should be between these bounds.

The float function should generate a random floating point number between zero and one.

BOTH functions should take a parameter that controls whether the lower and higher bounds are _inclusive_ or _exclusive_ bounds.

There are four options:

- include both: both the lower and upper bound are valid values for the generated number

- exlude both: neither the lower nor upper bound can be chosen as the generated random number

- include left: exclude right - only the lower bound can be chosen as the generated number

- exclude left: include right - only the higher bound can be chosen as the generated number

Print the generated random numbers to the console.

<br/>

## Tests
It's up to you to decide how you would unit test this code.

Write some integration tests that generate a few random numbers and verify that they are within the proper bounds.
<br/>

## Skills Practiced

- Generating random integer and float numbers

<br/>

0 comments on commit fd5d3a2

Please sign in to comment.