def ordenar(matriz):
lista = []
for x in range(len(matriz[0])):
for y in range(len(matriz)):
lista = lista + [matriz[y][x]]
for i in range(len(lista)):
for j in range(len(lista)):
if lista[i].edad > lista[j].edad:
aux = lista[i]
lista[i] = lista[j]
lista[j] = aux
return lista
from functools import reduce
#
# ─── FUNCTIONS ────────────────────────────────────────────────────────────────────
#
def read_board(filename):
with open(filename, 'r') as f:
board = [list(l.strip()) for l in f if l.strip()]
return board
def create_board():
rows = ['ABCDEF']
cols = [str(n) for n in range(1, 7)]
return list(zip(rows, cols))
def row_distance(row1, row2):
return abs(ord(row1) - ord(row2))
def col_distance(col1, col2):
return abs(int(col1) - int(col2))
def pair_distance(pair1, pair2):
return row_distance(pair1[0], pair2[0]) + col_distance(pair1[1], pair2[1])
def get_column(board, index):
return [row[index] for row in
def do_board(board):
# tablero = [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
# for i in tablero:
# print(i)
#or
for i in board:
for j in i:
print(j,end=" ")
print()
print("------------------------------------------")
for i in board:
print(i)
def make_board(board):
top = u"\u250C"
top_right = u"\u2510"
left = u"\u251C"
right = u"\u2524"
bottom_left = u"\u2514"
bottom_right = u"\u2518"
bottom = u"\u2534"
vertical = u"\u253C"
horizontal = u"\u2500"
result = top
for i in range(len(board[0])-1):
result+=
def sort_bigfoots(matrix):
bigfoots = []
for row in matrix:
for element in row:
if element == 1:
bigfoots.append(element)
bigfoots.sort(key=lambda a: a.edad, reverse=True)
return bigfoots
def print_board(board):
for row in board:
print(''.join(map(str, row)))
print_board([[1,1,1,1],[2,2,2,2],[3,3,3,3]])
def list_bigfoots(list_bigfoot):
list_bigfoots = [bigfoot.age for bigfoot in list_bigfoot]
return sorted(list_bigfoots, reverse=True)
def print_board(board, rows, cols):
pass
print_board([['a', 'a', 'c', '.', '.', '.'],
['.', '.', 'b', 'a', '.', '.'],
['.', '.', '.', '.', '.', '.'],
['.', '.', 'a', 'a', '.', '.'],
['.', '.', 'a', 'a', 'a', '1'],
['.', 'b', '.', '.', '.', 'a']
], 6, 6)
def buscar_bigfoots(matriz):
pass
def age_list(matriz):
lista = []
for x in matriz:
for y in x:
if y == 1:
lista.append(y.edad)
return lista_ordenada
def move_closer(self, matrix):
new_matrix = list(map(list, matrix))
list_1 = []
for i in range(0, len(matrix)):
for j in range(0, len(matrix[i])):
if matrix[i][j] == "1":
list_1.append(matrix[i][j])
elif matrix[i][j] == ".":
new_matrix[i][j] = self.edad
def order(item):
return item.edad
list_1.sort(key = order)
return new_matrix
def print_board(board):
# TODO:
pass
print_board([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]])
board = [
[ '.', '1', '.', '.', '.', '.', 'b' ],
[ '.', '.', '.', '.', '.', 'a', 'a' ],
[ '.', '.', '.', '.', 'a', 'a', 'a' ],
[ '.', 'a', '.', '.', '.', '.', '.' ],
[ '.', '.', '.', '.', '.', '.', '.' ],
[ '.', '.', '.', '.', '.', '.', '.' ],
[ '.', '.', '.', '.', '.', '.', '.' ]
]
def make_board(board):
_board = [
[ chr(0x2554), chr(0x2550), chr(0x2550), chr(0x2550), chr(0x2550), chr(0x2550), chr(0x2550
fix invalid codeFri, 31 Mar 2023 # <a name="Evaluacion"></a>Evaluación
## Criterios de evaluación
El proyecto tiene un valor de 10% de la nota final del curso. Se evaluará el
funcionamiento y completitud del juego.
## Criterios de aprobación
Para aprobar, el juego debe:
1. Funcionar y ser completamente jugable.
2. Tener el código bien documentado y estructurado.
3. Implementar al menos 6 movimientos diferentes.
4. Implementar la solución de errores en las entradas.
5. Implementar al menos una función recursiva.
6. Desplegar la documentación de la función recursiva.
7. Demostrar el correcto funcionamiento de la función recursiva.
8. Tener el código b
def mover(self):
posiciones = []
for i in range(len(self.lista_habitables)):
if self.lista_habitables[i] == "1":
posiciones.append(i)
posiciones = sorted(posiciones, key=lambda i: self.edad[i])
for i in reversed(posiciones):
if self.lista_habitables[i-1] == ".":
self.lista_habitables[i-1] = "1"
self.lista_habitables[i] = "."
self.edad[i-1] = self.edad[i] + 1
self.edad[i] = 0
elif self.lista_habitables[i+1] == ".":
self.lista_habitables[i+1] = "1"
self.lista_habitables[i] = "."
self.edad[i+1]
def same(a, b):
if a[0][0] == b:
return True
else:
return False
same([[1, 2, 3], [4, 5, 6]], 1)
def table(tablero,left,right,top,bottom,fill,spacing):
temp = []
res = []
for i in tablero:
for j in i:
temp.append(str(j))
temp.append(spacing)
res.append(fill.join(temp))
temp = []
res = "\n".join(res)
return left.join("\n".join(res))+right
table([[1,1,1,1],[2,2,2,2],[3,3,3,3]],"\u250C","\u2510","\u2502","\u2514","\u2500","\u2500")
import random
class Bigfoot:
def __init__(self, edad):
self.edad = edad
def lista_bigfoot(matriz):
lista_objetos = []
for fila in range(len(matriz)):
for columna in range(len(matriz[0])):
if matriz[fila][columna] == 1:
lista_objetos.append(Bigfoot(random.randint(0,100)))
return sorted(lista_objetos, key=lambda x: x.edad, reverse=True)
lista_bigfoot([[1,0,1,1], [0,1,0,0], [0,0,0,0], [0,0,1,0]])
def draw_board(board):
for row in board:
print('\u250C' + 4 * '\u2500' + '\u2510')
print('\u2502' + ' '.join(map(str, row)) + '\u2502')
print('\u2514' + 4 * '\u2500' + '\u2518')
draw_board([[1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3]])
bigfoots = [
[0,0,0,0,0],
[0,0,0,0,1],
[0,0,0,0,0],
[0,1,1,0,0],
[1,0,0,0,0],
]
class BigFoot:
def __init__(self, age):
self.age = age
def find_bigfoots(matrix):
lista = []
for i in range(len(matrix)):
for j in range(len(matrix[i])):
if matrix[i][j] == 1:
lista.append(BigFoot(matrix[i][j]))
return lista
lista = find_bigfoots([
[0,0,0,0,0],
[0,0,0,0,1],
[0,0,0,0,0],
[0,1,1,0,0],
[1,
fix invalid codeFri, 31 Mar 2023 encontrado=0
if (tablero[a-1][b]==tablero[a][b]):
encontrado+=1
encontrado+=reducir_arriba(tablero,a-1,b,encontrado,Elementos)
tablero[a-1][b]=Elementos(".")
tablero[a-1][b].comprobado=True
print(tablero[a-1][b].comprobado)
if (tablero[a+1][b]==tablero[a][b]):
encontrado+=1
encontrado+=reducir_abajo(tablero,a+1,b,encontrado,Elementos)
tablero[a+1][b]=Elementos(".")
tablero[a+1][b].comprobado=True
print(tablero[a+1][b].comprobado)
if (
def ordenar_edad(matriz):
lista = []
for i in range(len(matriz)):
for j in range(len(matriz[i])):
if matriz[i][j] == 1:
# ordenar la lista y agregar el nuevo elemento
lista.append()
return lista
def add(a, b):
return a + b
add(1, 2)
board = [
[".", "b", ".", ".", ".", "a"],
[".", ".", "a", "a", "a", "1"],
[".", ".", ".", ".", ".", "."],
[".", ".", "a", "a", ".", "."],
[".", ".", "b", "a", ".", "."],
["a", "a", "c", ".", ".", "."]
]
def print_board(board):
print(" 1 2 3 4 5 6")
top_line = "┌───┬───┬───┬───┬───┬───┐"
print(top_line)
for i, row in enumerate(board):
row_text = "│ "
for cell in row:
row_text += cell + " │ "
print(chr(i+65), row_text)
if i < 5:
print("├───┼───┼───┼
def draw_board(board):
col_names = "ABCDEF"
col_numbers = [str(x) for x in range(1, 7)]
print(" " + " ".join(col_numbers))
print(u"\u250c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\u2500\u2510" + u"\u252c" + u"\u2500\u2500\u2500\
def make_board(board):
id_str = ""
for row in enumerate(board):
row_str = ""
for cell in enumerate(row[1]):
if cell[0] == 0:
row_str += u'\u250C'
if cell[0] == len(row[1]) - 1:
row_str += u'\u2510'
else:
row_str += u'\u2500'
print(row_str)
for cell in enumerate(row[1]):
if cell[0] == 0:
print(u'\u2502' + str(cell[1]) + u'\u2502', end='')
else:
print(str(cell[1]) + u'\u2502', end='')
print('\n')
if row[0] == 0:
id_str += u'\u251C'
if row[0] == len(board) - 1:
id_
# se tiene una matriz de objetos con "1" y mas elementos, si el elemento es "." es que esta vacia. Cada vez que se inicia la funcion los "1" se mueven hacia la direccion que trengan dispnible iniciando desde arriba, el primero el moverse tiene que ser el "1" con self.edad mayor, para eso metemos todos los "1" en una lista.
def move(self):
self.age += 1
poblacion = []
for i in range(len(self.game.matrix)):
for j in range(len(self.game.matrix[0])):
if self.game.matrix[i][j] == 1:
poblacion.append([i, j])
poblacion.sort(key=sortSecond)
for k in poblacion:
if k[0] > 0 and self.game.matrix[k[0] - 1][k[
fix invalid codeFri, 31 Mar 2023 def reducir_inicio(tablero,a,b,self) :
encontrado=0
if (tablero[a-1][b]==tablero[a][b]):
encontrado+=1
encontrado+=reducir_arriba(tablero,a-1,b,encontrado,Elementos)
tablero[a-1][b]=Elementos(".")
tablero[a-1][b].comprobado=True
print(tablero[a-1][b].comprobado)
if (tablero[a+1][b]==tablero[a][b]):
encontrado+=1
encontrado+=reducir_abajo(tablero,a+1,b,encontrado,Elementos)
tablero[a+1][b]=Elementos(".")
tablero[a+1][b].comprobado=True
print
def sub(word):
return("|" + "_" * (len(word) + 2) + "|\n| " + word + " |\n|" + "_" * (len(word) + 2) + "|")
print(sub("SUBURBIOUS"))
def board(tablero):
for i in range(len(tablero)):
print(u"\u250C" + u"\u2500\u2500\u2500\u2510" + u"\u2502" + u"\u250C" + u"\u2500\u2500\u2500\u2510" + u"\u2502" + u"\u250C" + u"\u2500\u2500\u2500\u2510" + u"\u2502" + u"\u250C" + u"\u2500\u2500\u2500\u2510")
print(u"\u2502" + " " + tablero[i][0] + " " + u"\u2502" + " " + tablero[i][1] + " " + u"\u2502" + " " + tablero[i][2] + " " + u"\u2502" + " " + tablero[i][3] + " " + u"\u250
def bigfoot_age(matrix):
bigfoots = []
for i, row in enumerate(matrix):
for j, item in enumerate(row):
if item == 1:
bigfoots.append([i,j, item.edad])
return bigfoots
bigfoot_age(matrix)
board = [['a', 'b', 'a', 'a', 'a', '1'],
['.', '.', 'a', 'a', 'a', '1'],
['.', '.', '.', '.', '.', '.'],
['.', '.', 'a', 'a', '.', '.'],
['.', '.', 'b', 'a', '.', '.'],
['a', 'a', 'c', '.', '.', '.']]
def draw_board(board):
for i in range(0, int(len(board[0]) / 2) + 1):
print('┌───┬───┬───┬───┬───┬───┐')
for j in range(len(board)):
print(f'│ {board[j][i * 2]} │ {board[j][i * 2 + 1]} │', end=' ')
print()
print('├───┼───
#input = [1, 2, 3], 2
#output = False
#input = [2, 2, 3], 2
#output = True
#input = [3, 2, 3], 2
#output = False
def matriz(matrix, number):
last = matrix[0]
for i in range(len(matrix)):
if last == number:
return True
last = matrix[i]
return False
def print_board(board):
print(' ', end='')
for i in range(1, len(board[0])+1):
print(i, end=' ')
print('\n', end='')
for i in range(len(board)):
print(chr(i+65), end=' ')
for j in range(len(board[i])):
print('│', end=' ')
if board[i][j] == '':
print(' ', end = '')
else:
print(board[i][j], end = '')
print('│')
if i != len(board)-1:
print(chr(9473), end='')
for i in range(len(board[i])):
print(chr(9472) + chr(9472) + chr(9472), end='')
print(chr(9472))
else:
print(chr(9487), end='')
def moverse(self):
lista = []
for i in range(len(self.mapa)):
for j in range(len(self.mapa[0])):
if self.mapa[i][j] == "1":
lista.append([i,j])
lista.sort(key=lambda x: x[1])
for i in lista:
if self.mapa[i[0]][i[1]] == "1":
for j in range(len(self.vecinos)):
if self.vecinos[j][self.direccion[i[0]][i[1]]][0] == 0 and self.mapa[i[0] + self.vecinos[j][self.direccion[i[0]][i[1]]][1]][i[1] + self.vecinos[j][self.direccion[i[0]][i[1]]][2]] == ".":
self.mapa[i[0] +
def makeboard(board):
return '''
1 2 3 4 5 6
┌───┬───┬───┬───┬───┬───┐
A │ . │ b │ . │ . │ . │ a │
├───┼───┼───┼───┼───┼───┤
B │ . │ . │ a │ a │ a │ 1 │
├───┼───┼───┼───┼───┼───┤
C │ . │ . │ . │ . │ . │ . │
├───┼───┼───┼───┼───┼───┤
D │ . │ . │ a │ a │ . │ . │
├───┼───┼───┼───┼───┼───┤
E │ . │ . │ b │ a │ . │ . │
├───┼───┼───┼───┼
import os
import random
import zigpy.application
import zigpy.zcl.clusters.security as security
import zigpy.zcl.clusters.general as general
import asyncio
import sys
from typing import Optional, Union
from zigpy.quirks import CustomDevice
from zigpy_deconz.api import Deconz
from zigpy.zdo.types import NodeDescriptor
from zigpy.types import NWK
import partition
import zigpy.zcl.foundation as zcl_f
import zigpy.zcl.clusters.measurement as measurement
import zigpy.zcl.clusters.smartenergy as smartenergy
import zigpy.zcl.clusters.hvac as hvac
import zigpy.zcl.clusters.general as general
import zigpy.zcl.clusters.security as security
import zigpy.zcl.clusters.groups as groups
import zigpy.zcl.clusters.measurement as measurement
import zigpy.z
def make_board(board):
i = 0
while i < len(board):
if i == 0:
print(u"\u250C" + u"\u2500"*len(board[i]) + u"\u2510")
print(u"\u2502" + board[i] + u"\u2502")
i += 1
elif i == (len(board)-1):
print(u"\u2502" + board[i] + u"\u2502")
print(u"\u2514" + u"\u2500"*len(board[i]) + u"\u2518")
i += 1
else:
print(u"\u2502" + board[i] + u"\u2502")
i += 1
make_board(["hola", "que", "tal"])
def fun(m):
lis = []
for row in range(len(m)):
for column in range(len(m[0])):
if m[row][column] == 1:
lis.append(m[row][column].edad)
lis = sorted(lis)
return lis