idk what im doing lol
This commit is contained in:
parent
251fb1aa20
commit
1bfaf3b07a
88 changed files with 0 additions and 254 deletions
11
guessing_game/.gitignore
vendored
11
guessing_game/.gitignore
vendored
|
|
@ -1,11 +0,0 @@
|
|||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
84
guessing_game/Cargo.lock
generated
84
guessing_game/Cargo.lock
generated
|
|
@ -1,84 +0,0 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.1.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"rand",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.72"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701"
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "237a5ed80e274dbc66f86bd59c1e25edc039660be53194b5fe0a482e0f2612ea"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.7.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
"rand_hc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c"
|
||||
dependencies = [
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.9.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519"
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
[package]
|
||||
name = "guessing_game"
|
||||
version = "0.1.0"
|
||||
authors = ["Emily J. <me@emily.im>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
rand = "0.7.3"
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* Simple number guessing game I made using the tutorial at
|
||||
* https://doc.rust-lang.org/stable/book/ch02-00-guessing-game-tutorial.html
|
||||
*/
|
||||
|
||||
use std::io;
|
||||
use std::cmp::Ordering;
|
||||
use rand::Rng;
|
||||
|
||||
fn main() {
|
||||
// Generates random number between 0 and 100, thread_rng is the generator we're using
|
||||
let number = rand::thread_rng().gen_range(0, 101);
|
||||
let mut tries = 1;
|
||||
|
||||
println!("Choose a number between 0 and 100: ");
|
||||
|
||||
loop {
|
||||
// Defines a mutable variable that returns a string, don't know why constants exist yet
|
||||
let mut guess = String::new();
|
||||
|
||||
// the & symbol in front of mut means its a reference, whatever that means lol
|
||||
io::stdin()
|
||||
.read_line(&mut guess)
|
||||
.expect("Failed to read line.");
|
||||
|
||||
// Remove whitespace and convert the input into an unsigned 32 bit integer, using match statement to handle err
|
||||
let guess: u32 = match guess.trim().parse() {
|
||||
Ok(num) => num,
|
||||
Err(_) => {
|
||||
println!("Invalid input, please type a number!");
|
||||
continue;
|
||||
}
|
||||
};
|
||||
|
||||
// Checks whether the guess is higher, lower or equal to the random number
|
||||
// I added a tries thing myself, that tells you how many turns it took for you to guess the number
|
||||
match guess.cmp(&number) {
|
||||
Ordering::Less => {
|
||||
println!("Higher!");
|
||||
tries += 1;
|
||||
}
|
||||
Ordering::Greater => {
|
||||
println!("Lower!");
|
||||
tries += 1;
|
||||
}
|
||||
Ordering::Equal => {
|
||||
println!("You win! You took {} tries to guess the number.", tries);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"rustc_fingerprint":7448185015360785229,"outputs":{"1164083562126845933":["rustc 1.44.1 (c7087fe00 2020-06-17)\nbinary: rustc\ncommit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7\ncommit-date: 2020-06-17\nhost: x86_64-unknown-linux-gnu\nrelease: 1.44.1\nLLVM version: 9.0\n",""],"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/emily/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""]},"successes":{}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"rustc_fingerprint":7448185015360785229,"outputs":{"4476964694761187371":["___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/emily/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\ndebug_assertions\nproc_macro\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n",""],"1164083562126845933":["rustc 1.44.1 (c7087fe00 2020-06-17)\nbinary: rustc\ncommit-hash: c7087fe00d2ba919df1d813c040a5d47e43b0fe7\ncommit-date: 2020-06-17\nhost: x86_64-unknown-linux-gnu\nrelease: 1.44.1\nLLVM version: 9.0\n",""]},"successes":{}}
|
||||
|
|
@ -1 +0,0 @@
|
|||
a0edadd60b929f4a
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"rustc":11295616921483704964,"features":"[]","target":1796177550603792182,"profile":14891217944882224483,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/guessing_game-26c3e7d98df99986/dep-bin-guessing_game-26c3e7d98df99986"}}],"rustflags":[],"metadata":6881552442942698694}
|
||||
Binary file not shown.
|
|
@ -1 +0,0 @@
|
|||
This file has an mtime of when this was started.
|
||||
Binary file not shown.
|
|
@ -1 +0,0 @@
|
|||
This file has an mtime of when this was started.
|
||||
|
|
@ -1 +0,0 @@
|
|||
2ade81678509a6e8
|
||||
|
|
@ -1 +0,0 @@
|
|||
{"rustc":11295616921483704964,"features":"[]","target":1796177550603792182,"profile":1647870076477133176,"path":1036222786711178230,"deps":[],"local":[{"CheckDepInfo":{"dep_info":"debug/.fingerprint/guessing_game-a7f4c8c042c37a73/dep-test-bin-guessing_game-a7f4c8c042c37a73"}}],"rustflags":[],"metadata":6881552442942698694}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/home/emily/Documents/Projects/rust-practice/guessing_game/target/rls/debug/deps/guessing_game-26c3e7d98df99986.rmeta: src/main.rs
|
||||
|
||||
/home/emily/Documents/Projects/rust-practice/guessing_game/target/rls/debug/deps/guessing_game-26c3e7d98df99986.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/home/emily/Documents/Projects/rust-practice/guessing_game/target/rls/debug/deps/guessing_game-a7f4c8c042c37a73.rmeta: src/main.rs
|
||||
|
||||
/home/emily/Documents/Projects/rust-practice/guessing_game/target/rls/debug/deps/guessing_game-a7f4c8c042c37a73.d: src/main.rs
|
||||
|
||||
src/main.rs:
|
||||
Loading…
Add table
Add a link
Reference in a new issue