Skip to content

refactor: Condense password related files in one #7939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dynamic_programming/minimum_tickets_cost.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
47 changes: 0 additions & 47 deletions other/check_strong_password.py

This file was deleted.

44 changes: 42 additions & 2 deletions other/password_generator.py → other/password.py
Original file line number Diff line number Diff line change
@@ -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, ascii_lowercase, ascii_uppercase, digits, punctuation


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))
Expand Down Expand Up @@ -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(password) < min_length:
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(
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
beautifulsoup4
cython>=0.29.28 # For statsmodels on Python 3.11
fake_useragent
keras
lxml
Expand Down