Skip to content

Commit 79ff390

Browse files
committed
Merge branch 'main' of https://github.com/ikostan/python
2 parents f0792b5 + df8b6d7 commit 79ff390

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

isogram/isogram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ def is_isogram(string: str) -> bool:
2222
"""
2323
Determine if a word or phrase is an isogram.
2424
25-
An isogram is a word or phrase without repeating letters. Spaces and hyphens
26-
are allowed to appear multiple times, but alphabetic characters must be unique
27-
(case-insensitive).
25+
An isogram is a word or phrase without repeating letters. Spaces and
26+
hyphens are allowed to appear multiple times, but alphabetic
27+
characters must be unique (case-insensitive).
2828
2929
:param string: The word or phrase to check
3030
:type string: str

isogram/isogram_test.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# pylint: disable=C0114, C0115, C0116, R0904
2+
13
# These tests are auto-generated with test data from:
24
# https://github.com/exercism/problem-specifications/tree/main/exercises/isogram/canonical-data.json
35
# File last updated on 2023-07-19
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Isogram.
3+
4+
Determine if a word or phrase is an isogram.
5+
6+
An isogram (also known as a "non-pattern word") is a word or phrase
7+
without a repeating letter, however spaces and hyphens are allowed
8+
to appear multiple times.
9+
10+
Examples of isograms:
11+
12+
lumberjacks
13+
background
14+
downstream
15+
six-year-old
16+
17+
The word isograms, however, is not an isogram, because the s repeats.
18+
"""
19+
20+
21+
def is_isogram(string: str) -> bool:
22+
"""
23+
Determine if a word or phrase is an isogram.
24+
25+
An isogram is a word or phrase without repeating letters. Spaces and hyphens
26+
are allowed to appear multiple times, but alphabetic characters must be unique
27+
(case-insensitive).
28+
29+
:param string: The word or phrase to check
30+
:type string: str
31+
:returns: True if the string is an isogram, False otherwise
32+
:rtype: bool
33+
"""
34+
# empty string
35+
if not string:
36+
return True
37+
38+
letters: list[str] = [char for char in string.lower() if char.isalpha()]
39+
return len(letters) == len(set(letters))

0 commit comments

Comments
 (0)