Skip to content

Commit

Permalink
permutation
Browse files Browse the repository at this point in the history
  • Loading branch information
Hakan authored and Hakan committed Jul 21, 2020
1 parent d833e91 commit 74e39d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
12 changes: 3 additions & 9 deletions 031_pin_decoder.py
Original file line number Diff line number Diff line change
@@ -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"),\
Expand Down Expand Up @@ -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)
# def get_pins(observed):
# return [''.join(a) for a in product(*(PIN[i] for i in observed))]
8 changes: 8 additions & 0 deletions 032_permutations.py
Original file line number Diff line number Diff line change
@@ -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)))

0 comments on commit 74e39d4

Please sign in to comment.