Skip to content

Commit 2e39b27

Browse files
authored
isogram: Add new exercise (#424)
1 parent 1e1f5c8 commit 2e39b27

File tree

4 files changed

+46
-0
lines changed

4 files changed

+46
-0
lines changed

config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@
3333
"text formatting"
3434
]
3535
},
36+
{
37+
"slug": "isogram",
38+
"difficulty": 1,
39+
"topics": [
40+
]
41+
},
3642
{
3743
"slug": "pangram",
3844
"difficulty": 1,

exercises/isogram/example.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def is_isogram(string):
2+
characters_lower = [c.lower() for c in string if c.isalpha()]
3+
return len(set(characters_lower)) == len(characters_lower)

exercises/isogram/isogram.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def is_isogram():
2+
pass

exercises/isogram/isogram_test.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import unittest
2+
from isogram import is_isogram
3+
4+
5+
# test cases adapted from `x-common//canonical-data.json` @ version: 1.0.0
6+
7+
class TestIsogram(unittest.TestCase):
8+
9+
def test_empty_string(self):
10+
self.assertTrue(is_isogram(""))
11+
12+
def test_isogram_with_only_lower_case_characters(self):
13+
self.assertTrue(is_isogram("isogram"))
14+
15+
def test_word_with_one_duplicated_character(self):
16+
self.assertFalse(is_isogram("eleven"))
17+
18+
def test_longest_reported_english_isogram(self):
19+
self.assertTrue(is_isogram("subdermatoglyphic"))
20+
21+
def test_word_with_duplicated_character_in_mixed_case(self):
22+
self.assertFalse(is_isogram("Alphabet"))
23+
24+
def test_hypothetical_isogrammic_word_with_hyphen(self):
25+
self.assertTrue(is_isogram("thumbscrew-japingly"))
26+
27+
def test_isogram_with_duplicated_non_letter_character(self):
28+
self.assertTrue(is_isogram("Hjelmqvist-Gryb-Zock-Pfund-Wax"))
29+
30+
def test_made_up_name_that_is_an_isogram(self):
31+
self.assertTrue(is_isogram("Emily Jung Schwartzkopf"))
32+
33+
34+
if __name__ == '__main__':
35+
unittest.main()

0 commit comments

Comments
 (0)