From 52faf37bfbe550ce58253249a7f1a94c2a3681cc Mon Sep 17 00:00:00 2001 From: CaedenPH Date: Tue, 1 Nov 2022 21:23:53 +0000 Subject: [PATCH 1/6] refactor: Condense `password` related files in one --- other/check_strong_password.py | 47 -------------------- other/{password_generator.py => password.py} | 44 +++++++++++++++++- 2 files changed, 42 insertions(+), 49 deletions(-) delete mode 100644 other/check_strong_password.py rename other/{password_generator.py => password.py} (58%) diff --git a/other/check_strong_password.py b/other/check_strong_password.py deleted file mode 100644 index 95bb327addf4..000000000000 --- a/other/check_strong_password.py +++ /dev/null @@ -1,47 +0,0 @@ -# This Will Check Whether A Given Password Is Strong Or Not -# It Follows The Rule that Length Of Password Should Be At Least 8 Characters -# And At Least 1 Lower, 1 Upper, 1 Number And 1 Special Character - -from string import ascii_lowercase, ascii_uppercase, digits, punctuation - - -def strong_password_detector(password: str, min_length: int = 8) -> str: - """ - >>> strong_password_detector('Hwea7$2!') - 'This is a strong Password' - - >>> strong_password_detector('Sh0r1') - 'Your Password must be at least 8 characters long' - - >>> strong_password_detector('Hello123') - 'Password should contain UPPERCASE, lowercase, numbers, special characters' - - >>> strong_password_detector('Hello1238udfhiaf038fajdvjjf!jaiuFhkqi1') - 'This is a strong Password' - - >>> strong_password_detector(0) - 'Your Password must be at least 8 characters long' - """ - - if len(str(password)) < 8: - return "Your Password must be at least 8 characters long" - - upper = any(char in ascii_uppercase for char in password) - lower = any(char in ascii_lowercase for char in password) - num = any(char in digits for char in password) - spec_char = any(char in punctuation for char in password) - - if upper and lower and num and spec_char: - return "This is a strong Password" - - else: - return ( - "Password should contain UPPERCASE, lowercase, " - "numbers, special characters" - ) - - -if __name__ == "__main__": - import doctest - - doctest.testmod() diff --git a/other/password_generator.py b/other/password.py similarity index 58% rename from other/password_generator.py rename to other/password.py index 8f9d58a33b82..5b392f13321f 100644 --- a/other/password_generator.py +++ b/other/password.py @@ -1,11 +1,12 @@ -"""Password Generator allows you to generate a random password of length N.""" import secrets from random import shuffle -from string import ascii_letters, digits, punctuation +from string import ascii_letters, digits, punctuation, ascii_lowercase, ascii_uppercase def password_generator(length: int = 8) -> str: """ + Password Generator allows you to generate a random password of length N. + >>> len(password_generator()) 8 >>> len(password_generator(length=16)) @@ -62,6 +63,45 @@ def random_characters(chars_incl, i): pass # Put your code here... +# This Will Check Whether A Given Password Is Strong Or Not +# It Follows The Rule that Length Of Password Should Be At Least 8 Characters +# And At Least 1 Lower, 1 Upper, 1 Number And 1 Special Character +def strong_password_detector(password: str, min_length: int = 8) -> str: + """ + >>> strong_password_detector('Hwea7$2!') + 'This is a strong Password' + + >>> strong_password_detector('Sh0r1') + 'Your Password must be at least 8 characters long' + + >>> strong_password_detector('Hello123') + 'Password should contain UPPERCASE, lowercase, numbers, special characters' + + >>> strong_password_detector('Hello1238udfhiaf038fajdvjjf!jaiuFhkqi1') + 'This is a strong Password' + + >>> strong_password_detector(0) + 'Your Password must be at least 8 characters long' + """ + + if len(str(password)) < 8: + return "Your Password must be at least 8 characters long" + + upper = any(char in ascii_uppercase for char in password) + lower = any(char in ascii_lowercase for char in password) + num = any(char in digits for char in password) + spec_char = any(char in punctuation for char in password) + + if upper and lower and num and spec_char: + return "This is a strong Password" + + else: + return ( + "Password should contain UPPERCASE, lowercase, " + "numbers, special characters" + ) + + def main(): length = int(input("Please indicate the max length of your password: ").strip()) chars_incl = input( From 631725fcda58e3fea226737ac15625d31be77178 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Nov 2022 21:27:41 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- other/password.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/password.py b/other/password.py index 5b392f13321f..95f91400e246 100644 --- a/other/password.py +++ b/other/password.py @@ -1,6 +1,6 @@ import secrets from random import shuffle -from string import ascii_letters, digits, punctuation, ascii_lowercase, ascii_uppercase +from string import ascii_letters, ascii_lowercase, ascii_uppercase, digits, punctuation def password_generator(length: int = 8) -> str: From 515c8c228db449f950fe2d89994845e7460cc78a Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Wed, 2 Nov 2022 15:32:09 +0000 Subject: [PATCH 3/6] Update other/password.py Co-authored-by: Christian Clauss --- other/password.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/password.py b/other/password.py index 95f91400e246..64b69392cc2c 100644 --- a/other/password.py +++ b/other/password.py @@ -84,7 +84,7 @@ def strong_password_detector(password: str, min_length: int = 8) -> str: 'Your Password must be at least 8 characters long' """ - if len(str(password)) < 8: + if len(password) < min_length: return "Your Password must be at least 8 characters long" upper = any(char in ascii_uppercase for char in password) From 4dc2d9d359acd63f5b425c3131835df2298b4bd3 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 2 Nov 2022 17:16:04 +0100 Subject: [PATCH 4/6] dynamic_programming --- dynamic_programming/minimum_tickets_cost.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dynamic_programming/minimum_tickets_cost.py b/dynamic_programming/minimum_tickets_cost.py index 261a5a7cf42a..d07056d9217f 100644 --- a/dynamic_programming/minimum_tickets_cost.py +++ b/dynamic_programming/minimum_tickets_cost.py @@ -112,12 +112,12 @@ def dynamic_programming(index: int) -> int: return 0 if index not in days_set: - return dp(index + 1) + return dynamic_programming(index + 1) return min( - costs[0] + dp(index + 1), - costs[1] + dp(index + 7), - costs[2] + dp(index + 30), + costs[0] + dynamic_programming(index + 1), + costs[1] + dynamic_programming(index + 7), + costs[2] + dynamic_programming(index + 30), ) return dynamic_programming(1) From e490085c8c6266b0858f9394c2f51264f57d65fd Mon Sep 17 00:00:00 2001 From: CaedenPH Date: Wed, 2 Nov 2022 16:16:24 +0000 Subject: [PATCH 5/6] test: Make test input `str` --- other/password.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/password.py b/other/password.py index 64b69392cc2c..8f6833073288 100644 --- a/other/password.py +++ b/other/password.py @@ -80,7 +80,7 @@ def strong_password_detector(password: str, min_length: int = 8) -> str: >>> strong_password_detector('Hello1238udfhiaf038fajdvjjf!jaiuFhkqi1') 'This is a strong Password' - >>> strong_password_detector(0) + >>> strong_password_detector('0') 'Your Password must be at least 8 characters long' """ From 76b5ca9352c6cf2205205deb1e81c3cb0c527245 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 2 Nov 2022 17:16:47 +0100 Subject: [PATCH 6/6] requirements.txt: Remove cython>=0.29.28 # For statsmodels on Python 3.11 --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 2e278245541d..00f31b85e404 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ beautifulsoup4 -cython>=0.29.28 # For statsmodels on Python 3.11 fake_useragent keras lxml