Skip to content

Commit

Permalink
Add 037
Browse files Browse the repository at this point in the history
  • Loading branch information
zsinx6 committed Jun 28, 2022
1 parent f0dccf0 commit 73964af
Show file tree
Hide file tree
Showing 4 changed files with 144 additions and 0 deletions.
79 changes: 79 additions & 0 deletions 037/1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"""
https://www.codewars.com/kumite/5b748f34b1181438060005ae
Your code should return a Boolean of true if the provided password meets the following conditions
password must be no less than 8 characters long
password must have at least 1 capital letter
password must have at least 1 number
password must have at least 1 special character
for this Kata special characters are considered ( ! " # $ % & ' ( ) * + ' - . / ; : < > = or ?)
if the password doesn't meet these requirements return false.
>>> validate_min_chars("thiago")
False
>>> validate_min_chars("thiago12345")
True
>>> validate_at_least_one_capital_letter("thiago")
False
>>> validate_at_least_one_capital_letter("thiagoC")
True
>>> validate_at_least_one_capital_letter("thiagoC123")
True
>>> validate_at_least_one_capital_letter("thiagoC#!@#1")
True
>>> validate_at_least_one_number("thiagoC")
False
>>> validate_at_least_one_number("thiago11C")
True
>>> validate_at_least_one_special("thiagoC")
False
>>> validate_at_least_one_special("thiagoC*")
True
>>> validate_password("Thiago123#")
True
>>> validate_password("thiago123#")
False
>>> validate_password("Thiago123")
False
>>> validate_password("Thiago#####")
False
>>> validate_password("Thiag@")
False
>>> validate_password("!T13132312!")
True
>>> validate_password("!t13132312!")
False
"""
def validate_min_chars(password):
min_chars = 8
return len(password) >= min_chars

def validate_at_least_one_capital_letter(password):
return password.lower() != password

def validate_at_least_one_number(password):
for char in password:
if char.isnumeric():
return True
return False

def validate_at_least_one_special(password):
special_chars = set("""!"#$%&'()*+'-./;:<>=?""")
password_set = set(password)
return bool(special_chars & password_set)

def validate_password(password):
validators = [
validate_min_chars,
validate_at_least_one_capital_letter,
validate_at_least_one_number,
validate_at_least_one_special
]
for validator in validators:
if not validator(password):
return False

return True
52 changes: 52 additions & 0 deletions 037/2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"""
https://www.codewars.com/kata/56684677dc75e3de2500002b/python
A comfortable word is a word which you can type always alternating the hand you type with (assuming you type using a QWERTY keyboard and use fingers as shown in the image below).
That being said, complete the function which receives a word and returns true if it's a comfortable word and false otherwise.
The word will always be a string consisting of only ascii letters from a to z.
To avoid problems with image availability, here's the lists of letters for each hand:
Left: q, w, e, r, t, a, s, d, f, g, z, x, c, v, b
Right: y, u, i, o, p, h, j, k, l, n, m
Examples:
"yams" --> true
"test" --> false
>>> is_comfortable("test")
False
>>> is_comfortable("yams")
True
>>> is_comfortable("qyw")
True
>>> is_comfortable("q")
True
>>> is_comfortable("qyww")
False
>>> is_comfortable("yuiop")
False
>>> is_comfortable("qwert")
False
>>> is_comfortable("aaaaa")
False
"""


def is_comfortable(word):
is_left = 1
is_right = 2
left = set(['q', 'w', 'e', 'r', 't', 'a', 's', 'd',
'f', 'g', 'z', 'x', 'c', 'v', 'b'])

previous_position = is_left if word[0] in left else is_right
for char in word[1:]:
current_position = is_left if char in left else is_right
if current_position == previous_position:
return False
previous_position = current_position

return True
11 changes: 11 additions & 0 deletions 037/retro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# O que foi bom
- Novas pessoas!
- Exercícios previamente escolhidos e bons
- Split de palavra de 2 a 2

# O que podemos melhorar

# O que aprendemos
- Sets e suas mágicas
- Busca mágica do google para devs
- Não substimar o for
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Dojos realizados pelos membros do grupy-sanca

## Dojos realizados

### [037 - 31/05/2022](https://github.com/grupy-sanca/dojos/tree/master/037)

### [036 - 10/05/2022](https://github.com/grupy-sanca/dojos/tree/master/036)

### [035 - 12/04/2022](https://github.com/grupy-sanca/dojos/tree/master/035)
Expand Down

0 comments on commit 73964af

Please sign in to comment.