Thank you so much for the suggestion. I have updated the code locally :)
but to do that I have to use external deps? which I am not comfortable doing. (I am newbie :) )
Thank you for the suggestions.
attempts
is used to display total attempts when user wins the game so it is used in the program, I don’t see any warnings from compiler.
done :D
use std::io;
fn main() {
let mut input: String = String::new();
let stdin = io::stdin();
let x = rand::random::<u32>() % 101;
let mut attempts = 0;
let mut user_inputs: Vec<u32> = Vec::new();
loop {
println!("Guess a number from 0 to 100:");
stdin.read_line(&mut input);
input = input.to_string().replace("\n", ""); // removing the \n
let user_input: u32 = input.parse::<u32>().unwrap();
user_inputs.push(user_input);
if x == user_input {
println!("You won! attempts: {attempts}");
println!("Your inputs:");
for input in user_inputs {
print!("{input} ");
}
println!("");
break;
}
else if x < user_input {
println!("too big");
attempts += 1;
}
else {
println!("too small");
attempts += 1;
}
input.clear()
}
}
Thank you for the suggestion, I will keep these in mind.
let is_palindrome = input.chars().eq(input.chars().rev());
wow, this is really awesome. you just made a single liner for this whole problem. I didn’t know that you could do something like this since I don’t know much about Rust yet.
I am also thinking about making an IRC bot in Rust but I don’t have enough experience to do so yet
that could be a good exercise, I haven’t got the needed knowledge to do so, but I will keep this in mind.
I have tried nixos in the past and it just works and it’s surprisingly stable!
Yeah, I have distrohoped from morning to night. It’s 9:17 here.
I did it because I really want to learn Linux and want a job related to Linux. I am really obsessed with Linux and BSD
Thanks, I didn’t know that, I thought refind-install
was it.
Which bootloader would you suggest for UEFI system?
Thanks for the reply
Thank you so much for the link. It was a good read :)
Mindustry :)
For anyone who is interested in learning about mental health or reading about other people’s experiences.
No it’s more like “lose like nine and tight like seven”. It works because of the way Gujarati numerals are structured.
We have that in Gujarati “navde nokhu satde sajjad”
There is literally written that :q to exit!
Thanks, I will keep that in mind.