diff --git a/src/Python/005.py b/src/Python/005.py new file mode 100644 index 0000000..456cd8c --- /dev/null +++ b/src/Python/005.py @@ -0,0 +1,26 @@ +def mastermind(lst_1: list[int], lst_2: list[int]) -> tuple[int, int]: + match = 0 + index_match = 0 + for idx, element in enumerate(lst_1): + if lst_1[idx] == lst_2[idx]: + index_match += 1 + continue + if element in lst_2: + match += 1 + return (index_match, match) + +check_1 = [2, 6, 0, 7] +check_2 = [1, 4, 0, 6] +print(mastermind(check_1, check_2)) # (1, 1) + +check_1 = [2, 6, 0, 7] +check_2 = [3, 5, 9, 1] +print(mastermind(check_1, check_2)) # (0, 0) + +check_1 = [2, 6, 0, 7] +check_2 = [1, 6, 0, 4] +print(mastermind(check_1, check_2)) # (2, 0) + +check_1 = [2, 6, 0, 7] +check_2 = [2, 6, 0, 7] +print(mastermind(check_1, check_2)) # (4, 0)