From a66adaa15a47e76460360505a8c58d550f08e8ed Mon Sep 17 00:00:00 2001 From: Giftlin <31629119+Giftlin@users.noreply.github.com> Date: Wed, 13 Sep 2017 00:11:14 +0530 Subject: [PATCH 1/3] Create nDigitNumberCombinations.py n digit number combinations --- nDigitNumberCombinations.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 nDigitNumberCombinations.py diff --git a/nDigitNumberCombinations.py b/nDigitNumberCombinations.py new file mode 100644 index 00000000000..c5910f81e69 --- /dev/null +++ b/nDigitNumberCombinations.py @@ -0,0 +1,12 @@ +# ALL the combinations of n digit combo +def FourDigitCombinations(): + try: + pow = 10**n + numbers=[] + for code in range(pow): + code=str(code).zfill(n) + numbers.append(code) + except: + # handle all other exceptions + pass + return(numbers) From 9f7403a054d379a18560ab5b10a02ee2f531383f Mon Sep 17 00:00:00 2001 From: Giftlin <31629119+Giftlin@users.noreply.github.com> Date: Wed, 13 Sep 2017 00:13:41 +0530 Subject: [PATCH 2/3] Update nDigitNumberCombinations.py --- nDigitNumberCombinations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nDigitNumberCombinations.py b/nDigitNumberCombinations.py index c5910f81e69..77855af7220 100644 --- a/nDigitNumberCombinations.py +++ b/nDigitNumberCombinations.py @@ -1,5 +1,5 @@ # ALL the combinations of n digit combo -def FourDigitCombinations(): +def nDigitCombinations(): try: pow = 10**n numbers=[] From b3650de628b26d003ffc332392baecb64ba69952 Mon Sep 17 00:00:00 2001 From: Giftlin <31629119+Giftlin@users.noreply.github.com> Date: Wed, 13 Sep 2017 00:14:24 +0530 Subject: [PATCH 3/3] Update nDigitNumberCombinations.py --- nDigitNumberCombinations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nDigitNumberCombinations.py b/nDigitNumberCombinations.py index 77855af7220..302452c7f52 100644 --- a/nDigitNumberCombinations.py +++ b/nDigitNumberCombinations.py @@ -1,9 +1,9 @@ # ALL the combinations of n digit combo def nDigitCombinations(): try: - pow = 10**n + npow = 10**n numbers=[] - for code in range(pow): + for code in range(npow): code=str(code).zfill(n) numbers.append(code) except: