Skip to content

Instantly share code, notes, and snippets.

View knkillname's full-sized avatar

Mario Abarca knkillname

View GitHub Profile
## Author: Mario Abarca (knkillname)
## Email: [email protected]
## Date: 25 Feb 2015
## Language: Python 3
##
## Summary: A class representing bigraph objects given by a quasi-Cartan
## Matrix. Includes elementary operations, csv formating, and ploting.
from array import array
from os.path import splitext
import ast
## ESTRUCTURA DE DATOS PARA ALMACENAR UN CIRCUITO BOOLEANO
class Nodo:
__slots__ = 'etiqueta', 'hijos'
def __init__(self, etiqueta, *hijos):
self.etiqueta = etiqueta
self.hijos = hijos
@knkillname
knkillname / programs.py
Last active April 7, 2019 05:15
Generate all posible programs
# This program prints all the programs that can be written in Python
# (even this very same program if you give it enough time)
import string
def generate_programs(alphabet = string.printable):
alphabet = tuple(alphabet)
word, m, n = [], 0, len(alphabet)
while True:
p = ''.join(alphabet[i] for i in word)
@knkillname
knkillname / caminos.py
Last active May 5, 2020 17:39
Algoritmos de optimización combinatoria
## Algoritmos de caminos más cortos
from estructuras import Cola, ColaMin
from conectividad import ordenamiento_topologico
inf = float('inf') #Tratar infinito como un numero
def recorrido_a_lo_ancho(G, s):
dist, padre = {v:inf for v in G}, {v:v for v in G}
dist[s] = 0
##Calculadora humana. Por knkillname.
##¡Diviértete!
from random import choice, randint
L = ['+', '-', '×', '/']
while True:
op = choice(L)
if op == '+':
res = randint(1, 99)
a = randint(0, res)