Skip to content
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

Refactoring #4

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8088a9
Add files via upload
Leonardosu Oct 14, 2019
8f5309f
Merge pull request #1 from Leonardosu/Leonardosu-patch-1
Leonardosu Oct 14, 2019
c51cddf
Create grep_alternative
dev-adriano-lira Oct 18, 2019
0ffb294
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
57a5c7a
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
cf3f933
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
2816758
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
281cec7
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
1fd6de9
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
c86d393
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
969a38b
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
4dec94b
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
f56c2c6
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
6fdae69
Unidade 10 Adicionada
Leonardosu Oct 18, 2019
a6220a0
Merge pull request #15 from Leonardosu/master
dderking Oct 18, 2019
90119b2
Merge pull request #16 from liradriano/master
dderking Oct 18, 2019
fe4cf74
Create hello_world.c
mxlysb Oct 19, 2019
d342fc4
iptu_alternative.py
dev-adriano-lira Oct 19, 2019
1cad0c6
Create soma.c
mxlysb Oct 19, 2019
c891340
Create aprovacao.c
mxlysb Oct 19, 2019
ea7767f
Create conversaoreais.c
mxlysb Oct 19, 2019
cc0edba
Merge pull request #18 from mxlysb/master
dderking Oct 19, 2019
5a48092
Merge pull request #19 from mxlysb/patch-1
dderking Oct 19, 2019
a98fede
Merge pull request #20 from mxlysb/patch-2
dderking Oct 19, 2019
a3f3595
Merge pull request #21 from mxlysb/patch-3
dderking Oct 19, 2019
c5de3c8
Merge pull request #17 from liradriano/patch-1
dderking Oct 19, 2019
69bef2c
refactoring
Pedro-Manoel Oct 20, 2019
0567a5e
refactorin
Pedro-Manoel Oct 20, 2019
f90cae9
refactoring
Pedro-Manoel Oct 20, 2019
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
7 changes: 7 additions & 0 deletions Alternative_Unidade6/MaiorPalavra_AndreLucas/biggestWord.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def biggestWord(phrase, bigger = ""):
phrase = phrase.split()
for v in phrase:
if len(v) > len(bigger): bigger = v
return bigger

assert biggestWord("eu acredito que seja um bom exemplo") == "acredito"
19 changes: 19 additions & 0 deletions Alternative_Unidade6/TradutorMorse_AndreLucas/morseTranslator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
def morseTranslete(code):
word = ""
morse = {
'.-' : "a", '.---': "j", '...' : "s",
'-...': "b", '-.-' : "k", '-' : "t",
'-.-.': "c", '.-..': "l", '..-' : "u",
'-..' : "d", '--' : "m", '...-': "v",
'.' : "e", '-.' : "n", '.--' : "w",
'..-.': "f", '---' : "o", '-..-': "x",
'--.' : "g", '.--.' : "p", '-.--': "y",
'....': "h", '--.-': "q", '--..': "z",
'..' : "i", '.-.' : "r",
}
for v in code: word += morse[v]
return word

assert morseTranslete(['.--.', '-.--', '-', '....', '---', '-.']) == 'python'


7 changes: 7 additions & 0 deletions Unidade 10/AgrupaNegativos/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 5822912953057280,
"key": "5822912953057280",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
16 changes: 16 additions & 0 deletions Unidade 10/AgrupaNegativos/public_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest
import sys

undertest = __import__(sys.argv[-1].split(".py")[0])
agrupa_negativos = getattr(undertest, 'agrupa_negativos', None)

class PublicTests(unittest.TestCase):

def test_example(self):
assert agrupa_negativos([10, -2, -7, 8]) == {"nao-negativos":[10, 8], "negativos":[-2,-7]}
assert agrupa_negativos([-1, -5]) == {"nao-negativos":[ ], "negativos":[-1, -5]}

if __name__ == '__main__':
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
runner.run(loader.loadTestsFromModule(sys.modules[__name__]))
3 changes: 3 additions & 0 deletions Unidade 10/AgrupaNegativos/public_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: script
script: python public_tests.py {}

15 changes: 15 additions & 0 deletions Unidade 10/AgrupaNegativos/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#Leonardo Su 17:00 16/10/2019

def agrupa_negativos(lista):
di = {'nao-negativos' : [] ,'negativos' : [] }
for e in lista:
if e >= 0:
di['nao-negativos'].append(e)
if e < 0:
di['negativos'].append(e)
return di

# print(agrupa_negativos([10, -2, -7, 8,0]))

assert agrupa_negativos([10, -2, -7, 8]) == {"nao-negativos":[10, 8], "negativos":[-2,-7]}
assert agrupa_negativos([-1, -5]) == {"nao-negativos":[ ], "negativos":[-1, -5]}
4 changes: 4 additions & 0 deletions Unidade 10/AgrupaNegativos/tst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tests": [],
"title": "Agrupa negativos"
}
7 changes: 7 additions & 0 deletions Unidade 10/DisciplinasDeUmProfessor/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 5224297322774528,
"key": "5224297322774528",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
27 changes: 27 additions & 0 deletions Unidade 10/DisciplinasDeUmProfessor/public_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import unittest
import sys

undertest = __import__(sys.argv[-1].split(".py")[0])
disciplinas = getattr(undertest, 'disciplinas', None)

class PublicTests(unittest.TestCase):

def test_exemplo(self):
alocacao = {("P1", 4): ['Jorge', 'Dalton','Wilkerson'],
("LP1", 4): ['Jorge', 'Dalton', 'Eliane', 'Wilkerson'],
("EVOL", 2): ['Dalton'],
("IC", 4): ['Eliane', 'Joseana'],
("P2", 4): ['Livia', 'Raquel', 'Nazareno'],
("GRAFOS", 2): ['Patricia', 'Patricia']}

assert set(disciplinas(alocacao, "Dalton")[0]) == set(['P1', 'LP1', 'EVOL'])
assert disciplinas(alocacao, "Dalton")[1] == 10
assert set(disciplinas(alocacao, "Eliane")[0]) == set(['LP1', 'IC'])
assert disciplinas(alocacao, "Eliane")[1] == 8
assert set(disciplinas(alocacao, "Patricia")[0]) == set(['GRAFOS'])
assert disciplinas(alocacao, "Patricia")[1] == 4

if __name__ == '__main__':
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
runner.run(loader.loadTestsFromModule(sys.modules[__name__]))
3 changes: 3 additions & 0 deletions Unidade 10/DisciplinasDeUmProfessor/public_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: script
script: python public_tests.py {}

35 changes: 35 additions & 0 deletions Unidade 10/DisciplinasDeUmProfessor/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
def find(lista,x):
for e in lista:
if x == e:
return True
return False


def disciplinas(alocacao, professor):

materia = []
C = 0

for e in alocacao.keys():
for X in alocacao[e]:
if X == professor:
C+= e[1]
if not find(materia,e[0]):
materia.append(e[0])
# print((materia,C))
return (materia,C)

alocacao = {("P1", 4): ['Jorge', 'Dalton','Wilkerson'],
("LP1", 4): ['Jorge', 'Dalton', 'Eliane', 'Wilkerson'],
("EVOL", 2): ['Dalton'],
("IC", 4): ['Eliane', 'Joseana'],
("P2", 4): ['Livia', 'Raquel', 'Nazareno'],
("GRAFOS", 2): ['Patricia', 'Patricia']}

assert set(disciplinas(alocacao, "Dalton")[0]) == set(['P1', 'LP1', 'EVOL'])

assert disciplinas(alocacao, "Dalton")[1] == 10
assert set(disciplinas(alocacao, "Eliane")[0]) == set(['LP1', 'IC'])
assert disciplinas(alocacao, "Eliane")[1] == 8
assert set(disciplinas(alocacao, "Patricia")[0]) == set(['GRAFOS'])
assert disciplinas(alocacao, "Patricia")[1] == 4
4 changes: 4 additions & 0 deletions Unidade 10/DisciplinasDeUmProfessor/tst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tests": [],
"title": "Disciplinas de um Professor"
}
7 changes: 7 additions & 0 deletions Unidade 10/EstoquesDeLivros/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 5879582731272192,
"key": "5879582731272192",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
15 changes: 15 additions & 0 deletions Unidade 10/EstoquesDeLivros/public_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import unittest
import sys

undertest = __import__(sys.argv[-1].split(".py")[0])
ausentes = getattr(undertest, 'ausentes', None)

class PublicTests(unittest.TestCase):
def test_exemplo(self):
livros = { "Metamorfose": 30, "O Principe": 0, "Vigiar e Punir": 0, "Dumbo": 22}
assert ausentes(livros) == 2

if __name__ == '__main__':
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
runner.run(loader.loadTestsFromModule(sys.modules[__name__]))
3 changes: 3 additions & 0 deletions Unidade 10/EstoquesDeLivros/public_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: script
script: python public_tests.py {}

12 changes: 12 additions & 0 deletions Unidade 10/EstoquesDeLivros/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def ausentes(estoque):
books = []
qnt = 0

for e in estoque.keys():
if estoque[e] == 0:
qnt+=1

return qnt

livros = { "Metamorfose": 30, "O Principe": 0, "Vigiar e Punir": 0, "Dumbo": 22}
assert ausentes(livros) == 2
4 changes: 4 additions & 0 deletions Unidade 10/EstoquesDeLivros/tst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tests": [],
"title": "Livros Estoque"
}
7 changes: 7 additions & 0 deletions Unidade 10/NumeroDeDisciplinas/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 5897757321592832,
"key": "5897757321592832",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
24 changes: 24 additions & 0 deletions Unidade 10/NumeroDeDisciplinas/public_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import unittest
import sys

undertest = __import__(sys.argv[-1].split(".py")[0])
numero_disciplinas = getattr(undertest, 'numero_disciplinas', None)

class PublicTests(unittest.TestCase):

def teste1(self):
grade = {"p1": [], "lp1": [], "ic": [],"calc1": [], "p2": ["ic", "p1", "lp1"],
"lp2": ["ic", "p1", "lp1"], "grafos": ["ic", "p1", "lp1"], "calc2" : ["calc1"],
"edados": ["ic", "p1", "lp1", "p2", "lp2", "grafos"],
"leda": ["ic", "p1", "lp1", "p2", "lp2", "grafos"]}

horarios= {"p1": "s082", "lp1": "x082", "ic": "i142", "calc1": "q082", "p2": "t162",
"lp2": "s082", "grafos": "q082", "calc2": "x162", "edados": "x162", "leda": "t102"}

assert numero_disciplinas(grade, horarios, []) == 4
assert numero_disciplinas(grade, horarios, ["ic", "p1", "lp1"]) == 3

if __name__ == '__main__':
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
runner.run(loader.loadTestsFromModule(sys.modules[__name__]))
3 changes: 3 additions & 0 deletions Unidade 10/NumeroDeDisciplinas/public_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- type: script
script: python public_tests.py {}

61 changes: 61 additions & 0 deletions Unidade 10/NumeroDeDisciplinas/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#Leonardo Su 00:25 17/10/2019
def find(x,lista):
for e in lista:
if x == e:
return True
return False

def numero_disciplinas(m1,m2,lista):

pode_pagar = []
for e in m1.keys():
bota = True
for now in m1[e]:
if not find(now,lista):
bota = False
break

if bota == True and not find(e,lista):
pode_pagar.append(e)
horario_mark = []

for aula in pode_pagar:
time = m2[aula]

if not find(time,horario_mark):
horario_mark.append(time)

return len(horario_mark)

grade = {
"p1": [],
"lp1": [],
"ic": [],
"calc1": [],
"p2": ["ic", "p1", "lp1"],
"lp2": ["ic", "p1", "lp1"],
"grafos": ["ic", "p1", "lp1"],
"calc2" : ["calc1"],
"edados": ["ic", "p1", "lp1", "p2", "lp2", "grafos"],
"leda": ["ic", "p1", "lp1", "p2", "lp2", "grafos"]
}

horarios= {
"p1": "s082",
"lp2": "s082",

"leda": "t102",
"p2": "t162",

"calc1": "q082",
"grafos": "q082",

"calc2": "x162",
"edados": "x162",
"lp1": "x082",

"ic": "i142"
}

assert numero_disciplinas(grade, horarios, []) == 4
assert numero_disciplinas(grade, horarios, ["ic", "p1", "lp1"]) == 3
4 changes: 4 additions & 0 deletions Unidade 10/NumeroDeDisciplinas/tst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tests": [],
"title": "Número de disciplinas"
}
7 changes: 7 additions & 0 deletions Unidade 10/OcorrenciasLetra/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 4931759282061312,
"key": "4931759282061312",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
5 changes: 5 additions & 0 deletions Unidade 10/OcorrenciasLetra/public_tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- input: |
Exemplo de entrada e saida
output: |
e 5

26 changes: 26 additions & 0 deletions Unidade 10/OcorrenciasLetra/sol.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Leonardo Su 00:30 17/10/2019


entrada = input()

dic = dict()

for e in entrada:
if e != ' ':
x = e.lower()
dic[x] = 0

for e in entrada:
if e != ' ':
x = e.lower()
dic[x] += 1

maior = 0
letra = 'a'

for e in dic.keys():
if dic[e] > maior:
maior = dic[e]
letra = e

print(letra,maior)
4 changes: 4 additions & 0 deletions Unidade 10/OcorrenciasLetra/tst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"tests": [],
"title": "Ocorrências Letra"
}
7 changes: 7 additions & 0 deletions Unidade 10/QuantidadeDeUsuarios/.tst/assignment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"iid": 5825472720011264,
"key": "5825472720011264",
"kind": "assignment",
"site": "prog1",
"user": "[email protected]"
}
20 changes: 20 additions & 0 deletions Unidade 10/QuantidadeDeUsuarios/public_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
import sys

undertest = __import__(sys.argv[-1].split(".py")[0])
quantidade_usuarios = getattr(undertest, 'quantidade_usuarios', None)

class PublicTests(unittest.TestCase):

def test_example(self):

lsd = {1234:['Andrey'], 1226:['Nazareno', 'Livia'], 9999:['administrador'] }
deq = {1114:['Ana'] }

assert quantidade_usuarios(lsd) == 3
assert quantidade_usuarios(deq) == 1

if __name__ == '__main__':
loader = unittest.TestLoader()
runner = unittest.TextTestRunner()
runner.run(loader.loadTestsFromModule(sys.modules[__name__]))
Loading