-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathListaReal.py
More file actions
57 lines (48 loc) · 1.41 KB
/
ListaReal.py
File metadata and controls
57 lines (48 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class Nodo:
def __init__(self, dado=None,ant=None):
self.dado = dado
self.ant = ant
def nodoGet(self):
return self.dado
def nodoSet(self, dado):
self.dado = dado
class Lista:
def __init__(self):
self.ultimo = None
def vazia(self):
if self.ultimo == None:
return True
else:
return False
def inserir(self,dado):
self.ultimo = Nodo(dado,self.ultimo)
def removeFim(self):
if self.ultimo == None:
pass
aux = self.ultimo
self.ultimo = aux.ant
"list() = instance created"
#the code below is the answer for one exercise
"""n = int(input())
for x in range(n):
printed = False
pilhas = input()
lista = Lista()
for y in pilhas:
if y == '(' or y == '[' or y == '{':
lista.inserir(y)
elif y == ']' and lista.ultimo != None and lista.ultimo.dado == '[':
lista.removeFim()
elif y == ')' and lista.ultimo != None and lista.ultimo.dado == '(':
lista.removeFim()
elif y == '}' and lista.ultimo != None and lista.ultimo.dado == '{':
lista.removeFim()
else:
print('N')
printed = True
break
if not printed:
if (lista.ultimo == None):
print('S')
else:
print('N')"""