Skip to content

Commit 4dae1b5

Browse files
committed
Add favicon
1 parent 97745f7 commit 4dae1b5

13 files changed

Lines changed: 33 additions & 238 deletions

File tree

content/programming/data-structures/queues/index.en.md

Lines changed: 4 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -39,58 +39,10 @@ The basic queue operations are:
3939
Like stacks, queues can be implemented using linked lists.
4040
Elements are added at the end and removed from the front by keeping references to both ends.
4141

42-
```python
43-
class Node:
44-
def __init__(self, value):
45-
self.value = value
46-
self.next = None
47-
48-
49-
class Queue:
50-
def __init__(self):
51-
self.front = None
52-
self.end = None
53-
self.size = 0
54-
55-
def enqueue(self, value):
56-
new_node = Node(value)
57-
if self.end is None:
58-
self.end = new_node
59-
self.front = new_node
60-
return
61-
self.end.next = new_node
62-
self.end = new_node
63-
self.size += 1
64-
65-
def dequeue(self):
66-
if self.is_empty():
67-
return None
68-
value = self.front.value
69-
self.front = self.front.next
70-
if self.front is None:
71-
self.end = None
72-
self.size -= 1
73-
return value
74-
75-
def peek(self):
76-
if self.is_empty():
77-
return None
78-
return self.front.value
79-
80-
def is_empty(self):
81-
return self.front is None # Returns true if front is None
82-
83-
def __len__(self):
84-
return self.size
85-
86-
def __str__(self):
87-
values = []
88-
current = self.front
89-
while current:
90-
values.append(str(current.value))
91-
current = current.next
92-
return "\n".join(values)
93-
```
42+
{{< codeimporter
43+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/data_structures/queues.py"
44+
type="python"
45+
>}}
9446

9547
---
9648

content/programming/data-structures/queues/index.es.md

Lines changed: 5 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -39,58 +39,11 @@ Las operaciones básicas de una cola son:
3939
Al igual que las pilas, las colas se pueden implementar usando listas enlazadas.
4040
Se agrega al final y se saca del frente manteniendo referencias a ambos extremos.
4141

42-
```python
43-
class Node:
44-
def __init__(self, value):
45-
self.value = value
46-
self.next = None
47-
48-
49-
class Queue:
50-
def __init__(self):
51-
self.front = None
52-
self.end = None
53-
self.size = 0
54-
55-
def enqueue(self, value):
56-
new_node = Node(value)
57-
if self.end is None:
58-
self.end = new_node
59-
self.front = new_node
60-
return
61-
self.end.next = new_node
62-
self.end = new_node
63-
self.size += 1
64-
65-
def dequeue(self):
66-
if self.is_empty():
67-
return None
68-
value = self.front.value
69-
self.front = self.front.next
70-
if self.front is None:
71-
self.end = None
72-
self.size -= 1
73-
return value
74-
75-
def peek(self):
76-
if self.is_empty():
77-
return None
78-
return self.front.value
79-
80-
def is_empty(self):
81-
return self.front is None # Returns true if front is None
82-
83-
def __len__(self):
84-
return self.size
85-
86-
def __str__(self):
87-
values = []
88-
current = self.front
89-
while current:
90-
values.append(str(current.value))
91-
current = current.next
92-
return "\n".join(values)
93-
```
42+
{{< codeimporter
43+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/data_structures/queues.py"
44+
type="python"
45+
>}}
46+
9447
---
9548

9649
## Ejemplos de uso

content/programming/data-structures/stacks/index.en.md

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,54 +38,10 @@ Most languages like Python and Java provide stack implementations in their stand
3838

3939
A stack can be implemented using a linked list so that each node points to the previous node.
4040

41-
```python
42-
class Node:
43-
def __init__(self, value):
44-
self.value = value
45-
self.previous = None
46-
47-
48-
class Stack:
49-
def __init__(self):
50-
self.top = None
51-
self.size = 0
52-
53-
def push(self, value):
54-
new_node = Node(value)
55-
if self.top is None:
56-
self.top = new_node
57-
else:
58-
new_node.previous = self.top
59-
self.top = new_node
60-
self.size += 1
61-
62-
def pop(self):
63-
if self.top is None:
64-
return None
65-
top_node = self.top
66-
self.top = self.top.previous
67-
self.size -= 1
68-
return top_node.value
69-
70-
def peek(self):
71-
if self.top is None:
72-
return None
73-
return self.top.value
74-
75-
def is_empty(self):
76-
return self.top is None # Returns true if top is None
77-
78-
def __len__(self):
79-
return self.size
80-
81-
def __str__(self):
82-
values = []
83-
current = self.top
84-
while current:
85-
values.append(str(current.value))
86-
current = current.previous
87-
return "\n".join(values)
88-
```
41+
{{< codeimporter
42+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/data_structures/stacks.py"
43+
type="python"
44+
>}}
8945

9046
---
9147

content/programming/data-structures/stacks/index.es.md

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -38,54 +38,10 @@ La mayoría de los lenguajes como Python y Java proveen implementaciones de pila
3838

3939
Una pila puede implementarse utilizando una lista enlazada de manera que cada node apunte al nodo anterior.
4040

41-
```python
42-
class Node:
43-
def __init__(self, value):
44-
self.value = value
45-
self.previous = None
46-
47-
48-
class Stack:
49-
def __init__(self):
50-
self.top = None
51-
self.size = 0
52-
53-
def push(self, value):
54-
new_node = Node(value)
55-
if self.top is None:
56-
self.top = new_node
57-
else:
58-
new_node.previous = self.top
59-
self.top = new_node
60-
self.size += 1
61-
62-
def pop(self):
63-
if self.top is None:
64-
return None
65-
top_node = self.top
66-
self.top = self.top.previous
67-
self.size -= 1
68-
return top_node.value
69-
70-
def peek(self):
71-
if self.top is None:
72-
return None
73-
return self.top.value
74-
75-
def is_empty(self):
76-
return self.top is None # Returns true if top is None
77-
78-
def __len__(self):
79-
return self.size
80-
81-
def __str__(self):
82-
values = []
83-
current = self.top
84-
while current:
85-
values.append(str(current.value))
86-
current = current.previous
87-
return "\n".join(values)
88-
```
41+
{{< codeimporter
42+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/data_structures/stacks.py"
43+
type="python"
44+
>}}
8945

9046
---
9147

content/programming/intro/setup-dev-environment/index.en.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ Once you've set up your programming environment, it's time to dive into coding.
146146
147147
This is arguably the most iconic program for beginners. It's simple, but it introduces you to the process of writing and executing code.
148148

149-
```python
150-
print("Hello, World!")
151-
```
149+
{{< codeimporter
150+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/intro/hello_world.py"
151+
type="python"
152+
>}}
152153

153154
{{< figure
154155
src="running-hello-world.en.png"
@@ -160,22 +161,10 @@ print("Hello, World!")
160161

161162
This program is a tad more intricate. It doesn't just print out a message; it also performs mathematical calculations.
162163
163-
```python
164-
# User input
165-
side1 = float(input("Enter the length of the first side: "))
166-
side2 = float(input("Enter the length of the second side: "))
167-
side3 = float(input("Enter the length of the third side: "))
168-
169-
# Perimeter calculation
170-
perimeter = side1 + side2 + side3
171-
172-
# Area calculation using Heron's formula
173-
s = perimeter / 2
174-
area = (s*(s-side1)*(s-side2)*(s-side3)) ** 0.5
175-
176-
print(f"The triangle's perimeter is: {perimeter}")
177-
print(f"The triangle's area is: {area:.2f}")
178-
```
164+
{{< codeimporter
165+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/intro/triangle.py"
166+
type="python"
167+
>}}
179168
180169
{{< figure
181170
src="running-triangle.en.png"

content/programming/intro/setup-dev-environment/index.es.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,10 @@ Una vez que hayas configurado tu entorno de programación, es hora de sumergirse
146146

147147
Este es posiblemente el programa más icónico para principiantes. Es simple, pero te introduce al proceso de escribir y ejecutar código.
148148

149-
```python
150-
print("¡Hola mundo!")
151-
```
149+
{{< codeimporter
150+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/intro/hola_mundo.py"
151+
type="python"
152+
>}}
152153

153154
{{< figure
154155
src="running-hello-world.es.png"
@@ -160,22 +161,10 @@ print("¡Hola mundo!")
160161

161162
Este programa es un poco más complejo. No solo imprime un mensaje, sino que también realiza cálculos matemáticos.
162163

163-
```python
164-
# Entrada del usuario
165-
lado1 = float(input("Introduce la longitud del primer lado: "))
166-
lado2 = float(input("Introduce la longitud del segundo lado: "))
167-
lado3 = float(input("Introduce la longitud del tercer lado: "))
168-
169-
# Cálculo del perímetro
170-
perimetro = lado1 + lado2 + lado3
171-
172-
# Cálculo del área usando la fórmula de Herón
173-
s = perimetro / 2
174-
area = (s*(s-lado1)*(s-lado2)*(s-lado3)) ** 0.5
175-
176-
print(f"El perímetro del triángulo es: {perimetro}")
177-
print(f"El área del triángulo es: {area:.2f}")
178-
```
164+
{{< codeimporter
165+
url="https://raw.githubusercontent.com/learn-software-engineering/examples/main/programming/intro/triangulo.py"
166+
type="python"
167+
>}}
179168

180169
{{< figure
181170
src="running-triangle.es.png"

0 commit comments

Comments
 (0)