forked from mouredev/roadmap-retos-programacion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzetared92.py
89 lines (66 loc) · 1.62 KB
/
zetared92.py
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Reto #07 PILAS Y COLAS
""" Pilas o Stacks: principio LI-FO (Last in First Out) -> último en entrar,
primero en salir."""
stack = []
# Push
stack.append(1)
stack.append(2)
stack.append(3)
print(stack)
# Pop
stack_item = stack[len(stack) - 1]
del stack[len(stack) - 1]
print(stack_item)
print(stack.pop())
print(stack)
""" Colas o Queue: principio FI-FO (First In-First Out) -> primero en entrar,
primero en salir."""
queue = []
# Enqueue
queue.append(1)
queue.append(2)
queue.append(3)
print(queue)
# Dequeue
queue_item = queue[0]
del queue[0]
print(queue_item)
print(queue.pop(0))
print(queue)
# Extra
print("🧩 DIFICULTAD EXTRA - SIMULADOR DE NAVEGADOR WEB🧩")
def web_nav():
stack = []
while True:
action = input(
"Input your URL"
)
if action == "exit":
print("Exit...")
break
elif action == "forward":
pass
elif action == "back":
if len(stack) > 0:
stack.pop()
else:
stack.append(action)
if len(stack) > 0:
print(f"You're in the {stack[len(stack) - 1]} web.")
else:
print("You're in Home page.")
web_nav()
print("🧩 DIFICULTAD EXTRA - SIMULADOR DE IMPRESORA🧩")
def shared_printed():
queue = []
while True:
action = input("Add a doc o select print/exit: ")
if action == "exit":
break
elif action == "print":
if len(queue) > 0:
print(f"Printing: {queue.pop(0)}")
else:
queue.append(action)
print(f"Print spooler: {queue}")
shared_printed()