From d0c46689e118a6f4592fee87c3498a9dbd582a79 Mon Sep 17 00:00:00 2001 From: jay-0331 Date: Wed, 13 Apr 2022 14:21:35 +0530 Subject: [PATCH] Removed All HTML in Rust Folder --- 82_Stars/rust/Cargo.toml | 2834 +------------------------------- 82_Stars/rust/README.md | 2693 +------------------------------ 82_Stars/rust/src/main.rs | 3223 +------------------------------------ 3 files changed, 94 insertions(+), 8656 deletions(-) diff --git a/82_Stars/rust/Cargo.toml b/82_Stars/rust/Cargo.toml index 439dcb0e..8d4e044f 100644 --- a/82_Stars/rust/Cargo.toml +++ b/82_Stars/rust/Cargo.toml @@ -1,2829 +1,9 @@ +[package] +name = "stars" +version = "0.1.0" +edition = "2021" +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - basic-computer-games/Cargo.toml at main · coding-horror/basic-computer-games - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - - - - - - -
- -
- - - - - - - -
- - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - coding-horror  /   - basic-computer-games  /   - -
-
- - - -
- - -
- - -
- - - -
-
- Tip: - Type # to search pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search discussions -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type ! to search projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search teams -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search people and organizations -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type > to activate command mode -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Go to your accessibility settings to change your keyboard shortcuts -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type author:@me to search your content -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:pr to filter to pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:issue to filter to issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:project to filter to projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:open to filter to open content -
-
- Type ? for help and tips -
-
-
- -
- -
-
- We’ve encountered an error and some results aren't available at this time. Type a new search or try again later. -
-
- - No results matched your search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - Search for issues and pull requests - - # - - - - Search for issues, pull requests, discussions, and projects - - # - - - - Search for organizations, repositories, and users - - @ - - - - Search for projects - - ! - - - - Search for files - - / - - - - Activate command mode - - > - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Filter to pull requests - - # is:pr - - - - Filter to issues - - # is:issue - - - - Filter to discussions - - # is:discussion - - - - Filter to projects - - # is:project - - - - Filter to open issues, pull requests, and discussions - - # is:open - - - - - - - - - - - - - - - - -
-
-
- -
- - - - - - - - - - -
- - - - -
-
-
- - - - - - - - - -
- -
- -
-

- - - / - - basic-computer-games - - - Public -

- -
- -
    - - - -
  • - -
    - - - - - - - Watch - - - 126 - - - - -
    -
    -

    Notifications

    - -
    - -
    -
    - - - - - - - - -
    - - -
    - - - - - Get push notifications on iOS or Android. - -
    -
    -
    -
    - - - - -
    -
    -
    - - - -
  • - -
  • -
    -
    - Fork - 1k - - - -
    - -

    Fork basic-computer-games

    -
    - -
    - - - - - -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - -
  • - -
  • - - -
    -
    - - -
    -
    - -
    -
    - - - - -
    - -
    -
    - - - - - - - -
    - -
    -
    -
    -
    -
    -
  • - - - -
- -
- -
-
- - - - -
- - - -
- Open in github.dev - Open in a new github.dev tab - - - - - - -
- - -
- - - - - - -Permalink - -
- -
-
- - - main - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - Go to file - - -
- - - - - -
-
-
- - - - - - - - - -
- -
-
- - @Jay-0331 - -
- - - - - - -
-
- - Latest commit - 34baeec - Apr 1, 2022 - - - - - - History - - -
-
- -
- -
-
- - - 1 - - contributor - - -
- -

- Users who have contributed to this file -

-
- - - - - - -
-
-
-
- - - - - - - - - - - - -
- -
- - -
- - 9 lines (7 sloc) - - 188 Bytes -
- -
- - - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-
- -
- -
-
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
[package]
name = "stars"
version = "0.1.0"
edition = "2021"
-
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
-
[dependencies]
rand = "0.8.3"
-
- - - -
- -
- - - - -
- - -
- - -
-
- - -
- -
- - -
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - +[dependencies] +rand = "0.8.5" diff --git a/82_Stars/rust/README.md b/82_Stars/rust/README.md index 334493b2..fc6468b9 100644 --- a/82_Stars/rust/README.md +++ b/82_Stars/rust/README.md @@ -1,2692 +1,3 @@ +Original source downloaded [from Vintage Basic](http://www.vintage-basic.net/games.html) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - basic-computer-games/README.md at main · coding-horror/basic-computer-games - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - - - - - - -
- -
- - - - - - - -
- - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - coding-horror  /   - basic-computer-games  /   - -
-
- - - -
- - -
- - -
- - - -
-
- Tip: - Type # to search pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search discussions -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type ! to search projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search teams -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search people and organizations -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type > to activate command mode -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Go to your accessibility settings to change your keyboard shortcuts -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type author:@me to search your content -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:pr to filter to pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:issue to filter to issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:project to filter to projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:open to filter to open content -
-
- Type ? for help and tips -
-
-
- -
- -
-
- We’ve encountered an error and some results aren't available at this time. Type a new search or try again later. -
-
- - No results matched your search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - Search for issues and pull requests - - # - - - - Search for issues, pull requests, discussions, and projects - - # - - - - Search for organizations, repositories, and users - - @ - - - - Search for projects - - ! - - - - Search for files - - / - - - - Activate command mode - - > - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Filter to pull requests - - # is:pr - - - - Filter to issues - - # is:issue - - - - Filter to discussions - - # is:discussion - - - - Filter to projects - - # is:project - - - - Filter to open issues, pull requests, and discussions - - # is:open - - - - - - - - - - - - - - - - -
-
-
- -
- - - - - - - - - - -
- - - - -
-
-
- - - - - - - - - -
- -
- -
-

- - - / - - basic-computer-games - - - Public -

- -
- -
    - - - -
  • - -
    - - - - - - - Watch - - - 126 - - - - -
    -
    -

    Notifications

    - -
    - -
    -
    - - - - - - - - -
    - - -
    - - - - - Get push notifications on iOS or Android. - -
    -
    -
    -
    - - - - -
    -
    -
    - - - -
  • - -
  • -
    -
    - Fork - 1k - - - -
    - -

    Fork basic-computer-games

    -
    - -
    - - - - - -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - -
  • - -
  • - - -
    -
    - - -
    -
    - -
    -
    - - - - -
    - -
    -
    - - - - - - - -
    - -
    -
    -
    -
    -
    -
  • - - - -
- -
- -
-
- - - - -
- - - -
- Open in github.dev - Open in a new github.dev tab - - - - - - -
- - -
- - - - - - -Permalink - -
- -
-
- - - main - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - Go to file - - -
- - - - - -
-
-
- - - - - - - - - -
- -
-
-
 
-
- -
-
 
- Cannot retrieve contributors at this time -
-
- - - - - - - - - - - - -
- -
- - -
- - 3 lines (2 sloc) - - 139 Bytes -
- -
- - - - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-
- -
- -
-
- - -
- -
- -
- - - - -
- - -
- - -
-
- - - - -
- -
- - -
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - +Conversion to [Rust](https://www.rust-lang.org/) diff --git a/82_Stars/rust/src/main.rs b/82_Stars/rust/src/main.rs index 9cf285da..429646b3 100644 --- a/82_Stars/rust/src/main.rs +++ b/82_Stars/rust/src/main.rs @@ -1,3138 +1,85 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - basic-computer-games/main.rs at main · coding-horror/basic-computer-games - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Skip to content - - - - - - - - - - - - - - -
- -
- - - - - - - -
- - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - coding-horror  /   - basic-computer-games  /   - -
-
- - - -
- - -
- - -
- - - -
-
- Tip: - Type # to search pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type # to search discussions -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type ! to search projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search teams -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type @ to search people and organizations -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type > to activate command mode -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Go to your accessibility settings to change your keyboard shortcuts -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type author:@me to search your content -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:pr to filter to pull requests -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:issue to filter to issues -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:project to filter to projects -
-
- Type ? for help and tips -
-
-
- -
-
- Tip: - Type is:open to filter to open content -
-
- Type ? for help and tips -
-
-
- -
- -
-
- We’ve encountered an error and some results aren't available at this time. Type a new search or try again later. -
-
- - No results matched your search - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - Search for issues and pull requests - - # - - - - Search for issues, pull requests, discussions, and projects - - # - - - - Search for organizations, repositories, and users - - @ - - - - Search for projects - - ! - - - - Search for files - - / - - - - Activate command mode - - > - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Search your issues, pull requests, and discussions - - # author:@me - - - - Filter to pull requests - - # is:pr - - - - Filter to issues - - # is:issue - - - - Filter to discussions - - # is:discussion - - - - Filter to projects - - # is:project - - - - Filter to open issues, pull requests, and discussions - - # is:open - - - - - - - - - - - - - - - - -
-
-
- -
- - - - - - - - - - -
- - - - -
-
-
- - - - - - - - - -
- -
- -
-

- - - / - - basic-computer-games - - - Public -

- -
- -
    - - - -
  • - -
    - - - - - - - Watch - - - 126 - - - - -
    -
    -

    Notifications

    - -
    - -
    -
    - - - - - - - - -
    - - -
    - - - - - Get push notifications on iOS or Android. - -
    -
    -
    -
    - - - - -
    -
    -
    - - - -
  • - -
  • -
    -
    - Fork - 1k - - - -
    - -

    Fork basic-computer-games

    -
    - -
    - - - - - -

    If this dialog fails to load, you can visit the fork page directly.

    -
    -
    - -
    -
    -
    - -
  • - -
  • - - -
    -
    - - -
    -
    - -
    -
    - - - - -
    - -
    -
    - - - - - - - -
    - -
    -
    -
    -
    -
    -
  • - - - -
- -
- -
-
- - - - -
- - - -
- Open in github.dev - Open in a new github.dev tab - - - - - - -
- - -
- - - - - - -Permalink - -
- -
-
- - - main - - - - -
-
-
- Switch branches/tags - -
- - - -
- -
- -
- - -
- -
- - - - - - - - - - - - - - - - -
- - -
-
-
-
- -
- -
- - - Go to file - - -
- - - - - -
-
-
- - - - - - - - - -
- -
-
- - @Jay-0331 - -
- - - - - - -
-
- - Latest commit - 34baeec - Apr 1, 2022 - - - - - - History - - -
-
- -
- -
-
- - - 1 - - contributor - - -
- -

- Users who have contributed to this file -

-
- - - - - - -
-
-
-
- - - - - - - - - - - - -
- -
- - -
- - 85 lines (78 sloc) - - 2.63 KB -
- -
- - - - -
- - - - - - - - - - - - - - - -
- -
-
- -
-
- -
- -
-
- - - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
use rand::Rng;
use std::io;
-
fn main() {
println!(
"{: >39}\n{: >57}\n\n\n",
"STARS", "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY"
);
// STARS - PEOPLE'S COMPUTER CENTER, MENLO PARK, CA
// A IS LIMIT ON NUMBER, M IS NUMBER OF GUESSES
let a: u32 = 101;
let m: u32 = 7;
let mut need_instrut = String::new();
-
println!("DO YOU WANT INSTRUCTIONS?");
io::stdin()
.read_line(&mut need_instrut)
.expect("Failed to get input");
-
if need_instrut[..1].to_ascii_lowercase().eq("y") {
println!("I AM THINKING OF A WHOLE NUMBER FROM 1 TO {}", a - 1);
println!("TRY TO GUESS MY NUMBER. AFTER YOU GUESS, I");
println!("WILL TYPE ONE OR MORE STARS (*). THE MORE");
println!("STARS I TYPE, THE CLOSER YOU ARE TO MY NUMBER.");
println!("ONE STAR (*) MEANS FAR AWAY, SEVEN STARS (*******)");
println!("MEANS REALLY CLOSE! YOU GET {} GUESSES.\n\n", m);
}
-
loop {
println!("\nOK, I AM THINKING OF A NUMBER, START GUESSING.\n");
let rand_number: i32 = rand::thread_rng().gen_range(1..a) as i32; // generates a random number between 1 and 100
-
// GUESSING BEGINS, HUMAN GETS M GUESSES
for i in 0..m {
let mut guess = String::new();
println!("YOUR GUESS?");
io::stdin()
.read_line(&mut guess)
.expect("Failed to get input");
let guess: i32 = match guess.trim().parse() {
Ok(num) => num,
Err(_) => {
println!("PLEASE ENTER A NUMBER VALUE.\n");
continue;
}
};
if guess == rand_number {
print!("");
for _i in 0..50 {
print!("*");
}
println!("!!!");
println!("YOU GOT IT IN {} GUESSES!!! LET'S PLAY AGAIN...\n", i + 1);
break;
} else {
match_guess(rand_number - guess);
}
-
if i == 6 {
println!(
"SORRY, THAT'S {} GUESSES. THE NUMBER WAS {}",
m, rand_number
);
}
}
}
}
-
fn match_guess(diff: i32) {
if diff.abs() >= 64 {
println!("*\n");
} else if diff.abs() >= 32 {
println!("**\n");
} else if diff.abs() >= 16 {
println!("***\n");
} else if diff.abs() >= 8 {
println!("****\n");
} else if diff.abs() >= 4 {
println!("*****\n");
} else if diff.abs() >= 2 {
println!("******\n");
} else {
println!("*******\n");
}
}
-
- - - -
- -
- - - - -
- - -
- - -
-
- - -
- -
- - -
- -
-
- -
- - - - - - - - - - - - - - - - - - - - - - +use rand::Rng; +use std::io; + +fn main() { + println!( + "{: >39}\n{: >57}\n\n\n", + "STARS", "CREATIVE COMPUTING MORRISTOWN, NEW JERSEY" + ); + // STARS - PEOPLE'S COMPUTER CENTER, MENLO PARK, CA + // A IS LIMIT ON NUMBER, M IS NUMBER OF GUESSES + let a: u32 = 101; + let m: u32 = 7; + let mut need_instrut = String::new(); + + println!("DO YOU WANT INSTRUCTIONS?"); + io::stdin() + .read_line(&mut need_instrut) + .expect("Failed to get input"); + + if need_instrut[..1].to_ascii_lowercase().eq("y") { + println!("I AM THINKING OF A WHOLE NUMBER FROM 1 TO {}", a - 1); + println!("TRY TO GUESS MY NUMBER. AFTER YOU GUESS, I"); + println!("WILL TYPE ONE OR MORE STARS (*). THE MORE"); + println!("STARS I TYPE, THE CLOSER YOU ARE TO MY NUMBER."); + println!("ONE STAR (*) MEANS FAR AWAY, SEVEN STARS (*******)"); + println!("MEANS REALLY CLOSE! YOU GET {} GUESSES.\n\n", m); + } + + loop { + println!("\nOK, I AM THINKING OF A NUMBER, START GUESSING.\n"); + let rand_number: i32 = rand::thread_rng().gen_range(1..a) as i32; // generates a random number between 1 and 100 + + // GUESSING BEGINS, HUMAN GETS M GUESSES + for i in 0..m { + let mut guess = String::new(); + println!("YOUR GUESS?"); + io::stdin() + .read_line(&mut guess) + .expect("Failed to get input"); + let guess: i32 = match guess.trim().parse() { + Ok(num) => num, + Err(_) => { + println!("PLEASE ENTER A NUMBER VALUE.\n"); + continue; + } + }; + if guess == rand_number { + print!(""); + for _i in 0..50 { + print!("*"); + } + println!("!!!"); + println!("YOU GOT IT IN {} GUESSES!!! LET'S PLAY AGAIN...\n", i + 1); + break; + } else { + match_guess(rand_number - guess); + } + + if i == 6 { + println!( + "SORRY, THAT'S {} GUESSES. THE NUMBER WAS {}", + m, rand_number + ); + } + } + } +} + +fn match_guess(diff: i32) { + if diff.abs() >= 64 { + println!("*\n"); + } else if diff.abs() >= 32 { + println!("**\n"); + } else if diff.abs() >= 16 { + println!("***\n"); + } else if diff.abs() >= 8 { + println!("****\n"); + } else if diff.abs() >= 4 { + println!("*****\n"); + } else if diff.abs() >= 2 { + println!("******\n"); + } else { + println!("*******\n"); + } +}