🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉
Avatar of behaghel

behaghel's solution

to Pangram in the Emacs Lisp Track

Published at Sep 11 2020 · 0 comments
Test suite

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 a to z, inclusive, and is case insensitive. Input will not contain non-ASCII symbols.


Wikipedia https://en.wikipedia.org/wiki/Pangram

Submitting Incomplete Solutions

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:

(require 'seq)

(defun is-pangram (text)
  "Assert TEXT uses every letter of the alphabet at least once."
  (seq-every-p (apply-partially #'seq-contains-p (downcase text))
               (number-sequence ?a ?z)))

(provide 'pangram)
;;; pangram.el ends here

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

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.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?