diff --git a/031_pin_decoder.py b/031_pin_decoder.py index 7f2f2e4..2ae09dd 100644 --- a/031_pin_decoder.py +++ b/031_pin_decoder.py @@ -1,4 +1,4 @@ -from itertools import product +from itertools import product # Bu modül elemanlari kartezyen sekilde bir araya getiriyor. def get_pins(observed): decoder= [("0","8"),("1","2","4"),["2","1","3","5"],("3","2","6"),\ @@ -51,11 +51,5 @@ def get_pins(observed): # '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 +# def get_pins(observed): +# return [''.join(a) for a in product(*(PIN[i] for i in observed))] diff --git a/032_permutations.py b/032_permutations.py new file mode 100644 index 0000000..2771836 --- /dev/null +++ b/032_permutations.py @@ -0,0 +1,8 @@ +# daily-python-challenge +# Define a “function” to calculate permutation of 2 numbers. +# Reminder: P(n,r) = n!/(n-r)! +# Clue: Defining a function that calculates factorial of given number, may be helpful. + +from itertools import permutations +def P(n,r): + return len(list(permutations(range(n),r))) \ No newline at end of file