codeeval_challenges / 037_Pangrams /

# On CodeEval, test cases are read in from a file which is the first argument to your program
# Open the file and read in line by line. Each line represents a different test case
# (unless given different instructions in the challenge description)

import sys

ALPHABET = set([chr(idx) for idx in range(97, 123)])

def check_pangram(sentence):
    """ Checks the sentence for being a pangram (if it 
        contains each letter of the alphabet). 
        Returns string 'NULL' if sentence is a pangram
        or missing letters in lowercase otherwise.
    sentence = set(sentence.lower())

    missing_letters = ALPHABET.difference(sentence)

    if len(missing_letters) == 0:
        return 'NULL'
        return ''.join(sorted(missing_letters))

test_cases = open(sys.argv[1], 'r')

for test in test_cases:
    test = test.strip()

    if test != '':
        missing_letters = check_pangram(test)
        print missing_letters