Skip to content

Instantly share code, notes, and snippets.

@EarlGray
Last active August 29, 2015 14:13
Show Gist options
  • Save EarlGray/6b3a29a841b5036b3d8e to your computer and use it in GitHub Desktop.
Save EarlGray/6b3a29a841b5036b3d8e to your computer and use it in GitHub Desktop.
#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;
}
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")
}
}
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