Skip to content

Commit bce2aa4

Browse files
committed
Solve issue #2595
1 parent fed9345 commit bce2aa4

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def diff_integers_in_string(phrase: str) -> int:
2+
"""
3+
Given a string phrase, return the number of different integers that appear in phrase.
4+
5+
Args:
6+
phrase (str): The input string.
7+
8+
Returns:
9+
int: The number of different integers that appear in phrase.
10+
11+
Example:
12+
Input: "Smithech ha resuelto el issue #2595"
13+
Output: 3
14+
"""
15+
list_of_integers = set()
16+
17+
for char in phrase:
18+
if char.isdigit():
19+
list_of_integers.add(char)
20+
21+
return len(list_of_integers)
22+
23+
if __name__ == "__main__":
24+
example = "Smithech ha resuelto el issue #2595"
25+
result = diff_integers_in_string(example)
26+
print("Input: ", example)
27+
print("Output: ", result)

0 commit comments

Comments
 (0)