Skip to content

Pequena Contribuição #1

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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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: 5 additions & 3 deletions src/ex1.py
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eu não reparei que ele nesses erros, gostei muito da tua solução está muito melhor! Obrigado.

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ def cpf_verify(cpf: str)->bool:
if len(cpf)!=11:
return False
else:
cont = 0
for i in cpf:
if i.is_integer():
return True
if not i.isdigit():
continue
else:
return False
cont += 1
return True if cont == 9 else False
3 changes: 3 additions & 0 deletions src/ex2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ def string_invertor(word: str)->str:
pos = len(word)
string = [word[pos-i] for i in range(1, len(word)+1)]
return "".join(string)


string_inverter = lambda word: word[::-1]
7 changes: 3 additions & 4 deletions src/ex3.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
from ex2 import string_invertor
from ex2 import string_invertor, string_inverter

def palindromo(word:str)->bool:
return word==string_invertor(word)
return word==word[::-1]

def palindroms_using_points(word:str)->bool:
left = 0
right = len(word)-1

while left<right:
while right:
if word[left]!=word[right]:
return False
left+=1
right-=1

return True
14 changes: 2 additions & 12 deletions src/ex4.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
def cont_words(word: str)->dict:
words = dict()
for i in word:
count_word = 0
if i in words.keys:
pass
words.keys = i
for j in word:
if i==j:
count_word+=1
words.values = count_word
count_word = 0
return words
word = word.strip()
return len(word.split())
52 changes: 31 additions & 21 deletions src/ex6.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
from ex4 import cont_words

def fatoracao_number(num:int)->int:
count = 0
while count!=num:
num*=(num-count)
count+=1
return num
def fatorial(num:int)->int:
result=1
while num:
result *= num
num -= 1
return result

def anagrama(word:str)->bool:
words = cont_words(word)
numerador = fatoracao_number(len(word))
denominador = 0
denominadores = []
for i in words.values:
denominadores.append(i)
for i in denominadores:
if i>1:
denominador*=fatoracao_number(i)
words = word.split()
l = []
def counter(w):
d = {}
for i in w:
if i not in d:
d[i] = 1
else:
d[i] += 1
return d
for j in words:
l.append(counter(j))
return all(x==l[0] for x in l)

if denominador==0:
return numerador
else:
return (numerador/denominador)
def count_anagramas(word:str)->int:
n = fatorial(len(word))
h = {}
for i in word:
if i not in h:
h[i] = 1
else:
h[i] += 1

for j in h.values():
n /= fatorial(j)
return round(n)