Skip to content

Commit c5b74ed

Browse files
committed
Isogram: Exercise for isogram with test cases.
An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter. Examples of isograms: -lumberjacks -background -downstream The word isograms, however, is not an isogram, because the s repeats.
1 parent cf145f7 commit c5b74ed

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

config.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,16 @@
6464
"poker",
6565
"zebra-puzzle",
6666
"rectangles",
67-
"binary-search"
67+
"binary-search",
68+
"isogram"
6869
],
6970
"exercises": [
71+
{
72+
"slug": "isogram",
73+
"difficulty": 1,
74+
"topics": [
75+
]
76+
},
7077
{
7178
"slug": "hello-world",
7279
"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 isogram(string):
2+
string = string.lower()
3+
return len(set(string)) == len(string)

exercises/isogram/isogram_test.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import unittest
2+
from example import isogram
3+
4+
5+
class TestIsogram(unittest.TestCase):
6+
7+
def test_isogram(self):
8+
tests = ['lumberjacks', 'background', 'downstream']
9+
for test in tests:
10+
string = isogram(test)
11+
self.assertTrue(string, True)
12+
13+
def test_isogram_false(self):
14+
tests = ['isograms', 'aba', ' ']
15+
for test in tests:
16+
string = isogram(test)
17+
self.assertFalse(string, False)
18+
19+
if __name__ == '__main__':
20+
unittest.main()

0 commit comments

Comments
 (0)