Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best known English pangram is:
The quick brown fox jumps over the lazy dog.
The alphabet used consists of ASCII letters
z, inclusive, and is case
insensitive. Input will not contain non-ASCII symbols.
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
;;; pagram-test.el --- Tests for Pangram (exercism) ;;; Commentary: ;; Common test data version: 1.3.0 d79e13e ;;; Code: (load-file "pangram.el") (ert-deftest sentence-empty () (should (equal nil (is-pangram "")))) (ert-deftest recognizes-a-perfect-lower-case-pangram () (should (equal t (is-pangram "abcdefghijklmnopqrstuvwxyz")))) (ert-deftest pangram-with-only-lower-case () (should (equal t (is-pangram "the quick brown fox jumps over the lazy dog")))) (ert-deftest missing-character-x () (should (equal nil (is-pangram "a quick movement of the enemy will jeopardize five gunboats")))) (ert-deftest missing-another-character-eg-h () (should (equal nil (is-pangram "five boxing wizards jump quickly at it")))) (ert-deftest pangram-with-underscores () (should (equal t (is-pangram "the_quick_brown_fox_jumps_over_the_lazy_dog")))) (ert-deftest pangram-with-numbers () (should (equal t (is-pangram "the 1 quick brown fox jumps over the 2 lazy dogs")))) (ert-deftest missing-letters-replaced-by-numbers () (should (equal nil (is-pangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")))) (ert-deftest pangram-with-mixed-case-and-punctuation () (should (equal t (is-pangram "\"Five quacking Zephyrs jolt my wax bed.\"")))) (ert-deftest upper-and-lower-case-versions-of-the-same-character-should-not-be-counted-separately () (should (equal nil (is-pangram "the quick brown fox jumps over with lazy FX")))) (provide 'pangram-test) ;;; pagram-test.el ends here
;;; pangram.el --- Pangram (exercism) ;;; Commentary: ;;; Code: (defun is-pangram (s) "Check if string is a pangram. Takes a string S as input, and returns t if S is a pangram, which is defined as containing all 26 letters of the English alphabet (case insensitive)." (unless (stringp s) (error "The input to 's' must be a string.")) (let* ((letters (replace-regexp-in-string "[^[:alpha:]]" "" s)) (letters-lower (downcase letters)) (letters-lower-split (split-string letters-lower "" t)) (letters-lower-split-unique (delete-dups letters-lower-split)) (length-letters-unique (length letters-lower-split-unique))) (= length-letters-unique 26))) (provide 'pangram) ;;; pangram.el ends here
A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.
Here are some questions to help you reflect on this solution and learn the most from it.