8000 Solution for task: Guess the Word: Count Matching Letters. · ZaytsevNS/python_codewars@9c41650 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c41650

Browse files
committed
Solution for task: Guess the Word: Count Matching Letters.
1 parent cb91e8e commit 9c41650

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

7KYU/count_correct_characters.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Solution for task: https://www.codewars.com/kata/5912ded3f9f87fd271000120/
2+
3+
def count_correct_characters(correct: str, guess: str) -> int:
4+
if len(correct) != len(guess):
5+
raise Exception("Error!")
6+
set_correct = set((i, k) for i, k in enumerate(correct))
7+
set_guess = set((i, k) for i, k in enumerate(guess))
8+
return len(set_correct.intersection(set_guess))

0 commit comments

Comments
 (0)
0