vault backup: 2025-03-24 11:45:54
This commit is contained in:
parent
b2cef75a0b
commit
dd2182d529
@ -15,7 +15,7 @@ else
|
|||||||
endif
|
endif
|
||||||
badd +38 ~/Documents/Dane\'s\ Vault/3-99\ Research/Rust/Chapter\ 2\ -\ Guessing\ Game.md
|
badd +38 ~/Documents/Dane\'s\ Vault/3-99\ Research/Rust/Chapter\ 2\ -\ Guessing\ Game.md
|
||||||
badd +7 Cargo.toml
|
badd +7 Cargo.toml
|
||||||
badd +17 src/main.rs
|
badd +21 src/main.rs
|
||||||
argglobal
|
argglobal
|
||||||
%argdel
|
%argdel
|
||||||
edit src/main.rs
|
edit src/main.rs
|
||||||
@ -49,12 +49,12 @@ setlocal fdn=20
|
|||||||
setlocal fen
|
setlocal fen
|
||||||
silent! normal! zE
|
silent! normal! zE
|
||||||
let &fdl = &fdl
|
let &fdl = &fdl
|
||||||
let s:l = 17 - ((16 * winheight(0) + 31) / 62)
|
let s:l = 21 - ((20 * winheight(0) + 31) / 62)
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
keepjumps exe s:l
|
keepjumps exe s:l
|
||||||
normal! zt
|
normal! zt
|
||||||
keepjumps 17
|
keepjumps 21
|
||||||
normal! 030|
|
normal! 051|
|
||||||
wincmd w
|
wincmd w
|
||||||
argglobal
|
argglobal
|
||||||
if bufexists(fnamemodify("Cargo.toml", ":p")) | buffer Cargo.toml | else | edit Cargo.toml | endif
|
if bufexists(fnamemodify("Cargo.toml", ":p")) | buffer Cargo.toml | else | edit Cargo.toml | endif
|
||||||
@ -77,8 +77,9 @@ if s:l < 1 | let s:l = 1 | endif
|
|||||||
keepjumps exe s:l
|
keepjumps exe s:l
|
||||||
normal! zt
|
normal! zt
|
||||||
keepjumps 7
|
keepjumps 7
|
||||||
normal! 013|
|
normal! 014|
|
||||||
wincmd w
|
wincmd w
|
||||||
|
2wincmd w
|
||||||
exe 'vert 1resize ' . ((&columns * 95 + 95) / 190)
|
exe 'vert 1resize ' . ((&columns * 95 + 95) / 190)
|
||||||
exe 'vert 2resize ' . ((&columns * 94 + 95) / 190)
|
exe 'vert 2resize ' . ((&columns * 94 + 95) / 190)
|
||||||
tabnext 1
|
tabnext 1
|
||||||
|
|||||||
@ -14,12 +14,12 @@ else
|
|||||||
set shortmess=aoO
|
set shortmess=aoO
|
||||||
endif
|
endif
|
||||||
badd +7 custom/mappings.lua
|
badd +7 custom/mappings.lua
|
||||||
badd +60 custom/language_specific_commands/rust.lua
|
badd +34 custom/language_specific_commands/rust.lua
|
||||||
argglobal
|
argglobal
|
||||||
%argdel
|
%argdel
|
||||||
edit custom/language_specific_commands/rust.lua
|
edit custom/mappings.lua
|
||||||
argglobal
|
argglobal
|
||||||
balt custom/mappings.lua
|
balt custom/language_specific_commands/rust.lua
|
||||||
setlocal fdm=manual
|
setlocal fdm=manual
|
||||||
setlocal fde=0
|
setlocal fde=0
|
||||||
setlocal fmr={{{,}}}
|
setlocal fmr={{{,}}}
|
||||||
@ -30,12 +30,12 @@ setlocal fdn=20
|
|||||||
setlocal fen
|
setlocal fen
|
||||||
silent! normal! zE
|
silent! normal! zE
|
||||||
let &fdl = &fdl
|
let &fdl = &fdl
|
||||||
let s:l = 60 - ((57 * winheight(0) + 31) / 62)
|
let s:l = 7 - ((6 * winheight(0) + 31) / 62)
|
||||||
if s:l < 1 | let s:l = 1 | endif
|
if s:l < 1 | let s:l = 1 | endif
|
||||||
keepjumps exe s:l
|
keepjumps exe s:l
|
||||||
normal! zt
|
normal! zt
|
||||||
keepjumps 60
|
keepjumps 7
|
||||||
normal! 031|
|
normal! 0
|
||||||
tabnext 1
|
tabnext 1
|
||||||
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
if exists('s:wipebuf') && len(win_findbuf(s:wipebuf)) == 0 && getbufvar(s:wipebuf, '&buftype') isnot# 'terminal'
|
||||||
silent exe 'bwipe ' . s:wipebuf
|
silent exe 'bwipe ' . s:wipebuf
|
||||||
|
|||||||
@ -1,21 +1,64 @@
|
|||||||
use std::io;
|
|
||||||
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
use std::io;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Guess the number!");
|
println!("Guess the number!");
|
||||||
|
|
||||||
let secret_number = rand::rng().random_range(1..=100);
|
let secret_number = rand::rng().random_range(1..=100);
|
||||||
|
|
||||||
println!("The secret number is: {secret_number}");
|
// println!("The secret number is: {secret_number}");
|
||||||
|
|
||||||
println!("Please input your guess.");
|
let mut p_next_correct: f32;
|
||||||
|
let mut min_window: u32 = 0;
|
||||||
|
let mut max_window: u32 = 100;
|
||||||
|
|
||||||
let mut guess = String::new();
|
loop {
|
||||||
|
println!("Please input your guess.");
|
||||||
|
|
||||||
io::stdin()
|
let mut guess = String::new();
|
||||||
.read_line(&mut guess)
|
|
||||||
.expect("Failed to read line");
|
|
||||||
|
|
||||||
println!("You guessed: {}", guess);
|
io::stdin()
|
||||||
|
.read_line(&mut guess)
|
||||||
|
.expect("Failed to read line");
|
||||||
|
|
||||||
|
// Turn the guess into a u32 type, excpecting errors.
|
||||||
|
let guess: u32 = match guess.trim().parse() {
|
||||||
|
Ok(num) => num,
|
||||||
|
Err(_) => {
|
||||||
|
if guess == "exit" {
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
println!("DO IT!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("You guessed: {}", guess);
|
||||||
|
|
||||||
|
match guess.cmp(&secret_number) {
|
||||||
|
Ordering::Less => {
|
||||||
|
if guess > min_window {
|
||||||
|
min_window = guess;
|
||||||
|
}
|
||||||
|
println!("Too small!");
|
||||||
|
}
|
||||||
|
Ordering::Greater => {
|
||||||
|
if guess < max_window {
|
||||||
|
max_window = guess;
|
||||||
|
}
|
||||||
|
println!("Too large!");
|
||||||
|
}
|
||||||
|
Ordering::Equal => {
|
||||||
|
println!("You win!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("Max: {max_window}, Min: {min_window}");
|
||||||
|
p_next_correct = 1.0 / ((max_window - min_window - 1) as f32);
|
||||||
|
println!("Probability of next guess: {}", (p_next_correct * 100.0));
|
||||||
|
println!("\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
{"rustc_fingerprint":12638688072366774600,"outputs":{"4614504638168534921":{"success":true,"status":"","code":0,"stdout":"rustc 1.84.1 (e71f9a9a9 2025-01-27)\nbinary: rustc\ncommit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58\ncommit-date: 2025-01-27\nhost: x86_64-unknown-linux-gnu\nrelease: 1.84.1\nLLVM version: 19.1.5\n","stderr":""},"15729799797837862367":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/danesabo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
|
{"rustc_fingerprint":416372215023924338,"outputs":{"15611795083382425170":{"success":true,"status":"","code":0,"stdout":"rustc 1.84.1 (e71f9a9a9 2025-01-27)\nbinary: rustc\ncommit-hash: e71f9a9a98b0faf423844bf0ba7438f29dc27d58\ncommit-date: 2025-01-27\nhost: x86_64-unknown-linux-gnu\nrelease: 1.84.1\nLLVM version: 19.1.5\n","stderr":""},"1185988223601034215":{"success":true,"status":"","code":0,"stdout":"___\nlib___.rlib\nlib___.so\nlib___.so\nlib___.a\nlib___.so\n/home/danesabo/.rustup/toolchains/stable-x86_64-unknown-linux-gnu\noff\npacked\nunpacked\n___\ndebug_assertions\npanic=\"unwind\"\nproc_macro\ntarget_abi=\"\"\ntarget_arch=\"x86_64\"\ntarget_endian=\"little\"\ntarget_env=\"gnu\"\ntarget_family=\"unix\"\ntarget_feature=\"fxsr\"\ntarget_feature=\"sse\"\ntarget_feature=\"sse2\"\ntarget_has_atomic=\"16\"\ntarget_has_atomic=\"32\"\ntarget_has_atomic=\"64\"\ntarget_has_atomic=\"8\"\ntarget_has_atomic=\"ptr\"\ntarget_os=\"linux\"\ntarget_pointer_width=\"64\"\ntarget_vendor=\"unknown\"\nunix\n","stderr":""}},"successes":{}}
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user