From d833e9150eba674e6961757e80a901e1547a0bf5 Mon Sep 17 00:00:00 2001 From: Hakan Date: Tue, 21 Jul 2020 12:14:16 +0200 Subject: [PATCH] sifre_cozucu --- 031_pin_decoder.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 031_pin_decoder.py diff --git a/031_pin_decoder.py b/031_pin_decoder.py new file mode 100644 index 0000000..7f2f2e4 --- /dev/null +++ b/031_pin_decoder.py @@ -0,0 +1,61 @@ +from itertools import product + +def get_pins(observed): + decoder= [("0","8"),("1","2","4"),["2","1","3","5"],("3","2","6"),\ + ("4","7","1","5"),("5","2","4","6","8"),("6","3","5","9"),\ + ("7","8","4"),("8","7","5","9","0"),("9","6","8")] + dol = [decoder[int(i)]for i in observed] + k = list(product(*dol)) + return ["".join(a) for a in k] + + +# adjacents = { +# '1': ['2', '4'], +# '2': ['1', '5', '3'], +# '3': ['2', '6'], +# '4': ['1', '5', '7'], +# '5': ['2', '4', '6', '8'], +# '6': ['3', '5', '9'], +# '7': ['4', '8'], +# '8': ['5', '7', '9', '0'], +# '9': ['6', '8'], +# '0': ['8'], +# } + +# def get_pins(observed): +# if len(observed) == 1: +# return adjacents[observed] + [observed] +# return [a + b for a in adjacents[observed[0]] + [observed[0]] for b in get_pins(observed[1:])] + + + + +# from itertools import product + +# ADJACENTS = ('08', '124', '2135', '326', '4157', '52468', '6359', '748', '85790', '968') + +# def get_pins(observed): +# return [''.join(p) for p in product(*(ADJACENTS[int(d)] for d in observed))] + + +# from itertools import product + +# PIN = {'1': ('1', '2', '4'), +# '2': ('1', '2', '3', '5'), +# '3': ('2', '3', '6'), +# '4': ('1', '4', '5', '7'), +# '5': ('2', '4', '5', '6', '8'), +# '6': ('5', '6', '9', '3'), +# '7': ('4', '7', '8'), +# '8': ('7', '5', '8', '9', '0'), +# '9': ('6', '8', '9'), '0': ('0', '8')} + +# observed = "12" +# # def get_pins(observed): +# # return [''.join(a) for a in product(*(PIN[i] for i in observed))] +# # print(get_pins("12")) + +# k = list(product(*(PIN[i] for i in observed))) +# l = [*(PIN[i] for i in observed)] +# print(l) +# print(k) \ No newline at end of file