Skip to content

Commit

Permalink
Implemented contains_two_pairs function
Browse files Browse the repository at this point in the history
  • Loading branch information
micknudsen committed Dec 10, 2023
1 parent 80ecf30 commit d9e4d3b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions 2015/11/code.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import unittest

from typing import Set


def contains_increasing_straight(password: str) -> bool:
for i in range(len(password) - 2):
Expand All @@ -17,6 +19,16 @@ def contains_illegal_letters(password: str) -> bool:
return False


def contains_two_pairs(password: str) -> bool:
pairs: Set[str] = set()
for x, y in zip(password, password[1:]):
if x == y:
pairs.add(x)
if len(pairs) == 2:
return True
return False


class TestCode(unittest.TestCase):
def test_contains_increasing_straight(self) -> None:
self.assertTrue(contains_increasing_straight(password="hijklmmn"))
Expand Down

0 comments on commit d9e4d3b

Please sign in to comment.