Last active
August 29, 2015 14:13
-
-
Save EarlGray/6b3a29a841b5036b3d8e 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
#include <iostream> | |
#include <string> | |
#include <set> | |
#include <vector> | |
#include <iterator> | |
#include <algorithm> | |
int main() { | |
std::string s; | |
std::getline(std::cin, s); | |
std::transform(s.begin(), s.end(), s.begin(), ::tolower); | |
std::set<char> inpset{s.begin(), s.end()}; | |
std::vector<char> abcv('z' - 'a'); | |
std::iota(abcv.begin(), abcv.end(), 'a'); | |
std::set<char> abcset{abcv.begin(), abcv.end()}; | |
std::vector<char> diff; | |
std::set_difference(abcset.begin(), abcset.end(), | |
inpset.begin(), inpset.end(), | |
std::inserter(diff, diff.begin())); | |
std::cout << (diff.empty() ? "pangram" : "not pangram") << std::endl; | |
} |
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; | |
use std::collections::HashSet; | |
fn main() { | |
let s: String = io::stdin().read_line().ok().expect("line").as_slice().trim().to_string(); | |
let bs: Vec<char> = s.as_slice().chars().map(|x| x.to_lowercase()).collect(); | |
let st: HashSet<char> = bs.into_iter().collect(); | |
// How the fuck to do ASCII ranges in this fucking Rust? | |
let absv: Vec<char> = "abcdefghijklmnopqrstuvwxyz".chars().collect(); | |
let abc: HashSet<char> = absv.into_iter().collect(); | |
match abc.difference(&st).next() { | |
Some(_) => println!("not pangram"), | |
None => println!("pangram") | |
} | |
} |
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
import Data.Char (toLower) | |
import qualified Data.Set as S | |
bool thenb elseb cond = if cond then thenb else elseb | |
pangram s = S.null $ S.difference (S.fromList ['a'..'z']) (S.fromList s) | |
main = interact (cond "pangram" "not pangram" . pangram . map toLower) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment