From e3178b57addce3493e3f02d56cba7ceffb59756e Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Sun, 13 Aug 2017 09:25:58 -0500 Subject: [PATCH] Python Progress --- python/.gitignore | 2 ++ python/isogram/isogram.py | 11 ++++++-- python/pangram/README.md | 26 +++++++++++++++++++ python/pangram/pangram.py | 2 ++ python/pangram/pangram_test.py | 46 ++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 python/.gitignore create mode 100644 python/pangram/README.md create mode 100644 python/pangram/pangram.py create mode 100644 python/pangram/pangram_test.py diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..fa80de6 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1,2 @@ +# Ignore compiled python tests +*.pyc diff --git a/python/isogram/isogram.py b/python/isogram/isogram.py index 7b0ccf9..989bde7 100644 --- a/python/isogram/isogram.py +++ b/python/isogram/isogram.py @@ -1,2 +1,9 @@ -def is_isogram(): - pass +def is_isogram(inp): + letList = [] + for i in inp.lower(): + if i.isalpha(): + if not(i in letList): + letList.append(i) + else: + return False + return True diff --git a/python/pangram/README.md b/python/pangram/README.md new file mode 100644 index 0000000..317b23d --- /dev/null +++ b/python/pangram/README.md @@ -0,0 +1,26 @@ +# Pangram + +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. + +### Submitting Exercises + +Note that, when trying to submit an exercise, make sure the solution is in the `exercism/python/` directory. + +For example, if you're submitting `bob.py` for the Bob exercise, the submit command would be something like `exercism submit /python/bob/bob.py`. + + +For more detailed information about running tests, code style and linting, +please see the [help page](http://exercism.io/languages/python). + +## Source + +Wikipedia [https://en.wikipedia.org/wiki/Pangram](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. diff --git a/python/pangram/pangram.py b/python/pangram/pangram.py new file mode 100644 index 0000000..14eddbe --- /dev/null +++ b/python/pangram/pangram.py @@ -0,0 +1,2 @@ +def is_pangram(): + pass diff --git a/python/pangram/pangram_test.py b/python/pangram/pangram_test.py new file mode 100644 index 0000000..09465a0 --- /dev/null +++ b/python/pangram/pangram_test.py @@ -0,0 +1,46 @@ +import unittest + +from pangram import is_pangram + + +# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0 + +class PangramTests(unittest.TestCase): + def test_sentence_empty(self): + self.assertFalse(is_pangram('')) + + def test_pangram_with_only_lower_case(self): + self.assertTrue( + is_pangram('the quick brown fox jumps over the lazy dog')) + + def test_missing_character_x(self): + self.assertFalse( + is_pangram('a quick movement of the enemy will ' + 'jeopardize five gunboats')) + + def test_another_missing_character_x(self): + self.assertFalse( + is_pangram('the quick brown fish jumps over the lazy dog')) + + def test_pangram_with_underscores(self): + self.assertTrue( + is_pangram('the_quick_brown_fox_jumps_over_the_lazy_dog')) + + def test_pangram_with_numbers(self): + self.assertTrue( + is_pangram('the 1 quick brown fox jumps over the 2 lazy dogs')) + + def test_missing_letters_replaced_by_numbers(self): + self.assertFalse( + is_pangram('7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog')) + + def test_pangram_with_mixedcase_and_punctuation(self): + self.assertTrue(is_pangram('"Five quacking Zephyrs jolt my wax bed."')) + + def test_upper_and_lower_case_versions_of_the_same_character(self): + self.assertFalse( + is_pangram('the quick brown fox jumped over the lazy FOX')) + + +if __name__ == '__main__': + unittest.main()