Last active
February 13, 2023 17:29
-
-
Save BlueZeeKing/eff2f41d31da86c795725ff2b92eadfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::{ io::{ stdin, stdout, Write } }; | |
fn main() { | |
let mut input = String::new(); | |
print!("Please enter the sentence: "); | |
stdout().lock().flush().expect("Could not write the prompt"); | |
stdin().read_line(&mut input).expect("Could not get input"); | |
println!("{}", is_pangram(input.trim())) | |
} | |
fn is_pangram(input: &str) -> bool { | |
let mut letters: u32 = 0; | |
for character in input.chars() { | |
let letter = character as u32; | |
letters = | |
letters | | |
(1 << | |
(if letter <= 90 && letter >= 65 { | |
// capital letters | |
letter - 65 | |
} else if letter <= 122 && letter >= 97 { | |
// lowercase letters | |
letter - 97 | |
} else { | |
continue; | |
})); | |
} | |
letters == 67108863 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment