Skip to content

Instantly share code, notes, and snippets.

View colltoaction's full-sized avatar

Martin Coll colltoaction

View GitHub Profile
@colltoaction
colltoaction / finger4.ipynb
Created September 11, 2015 17:06
Finger Exercise 4 - Compression
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / finger2-entrega.ipynb
Created August 29, 2015 01:42
Finger Exercise 2
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / district-means.ipynb
Created August 28, 2015 04:23
Generating location means by district for kaggle.com/c/sf-crime using pyspark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@colltoaction
colltoaction / finger1.R
Last active August 29, 2015 14:27
7506 finger exercise 1
train <- read.csv("train.csv")
ss <- subset(train, select=c("Descript"))
which.max(table(ss))
# GRAND THEFT FROM LOCKED AUTO
ss <- subset(train, Category=="DRIVING UNDER THE INFLUENCE", select=c("DayOfWeek"))
which.max(table(ss))
# Saturday
@colltoaction
colltoaction / synchronous_counter_design.md
Last active August 29, 2015 14:11
Synchronous counter design

Synchronous counter design

When designing a synchronous counter, you first draw the counter's state diagram.

With that in mind, you can write the transitions table, where:

  • the independent variables are the current flip-flops' outputs Q[0], Q[1], ... Q[n]
  • you provide the desired next state of the flip-flops' outputs Q[0], Q[1], ... Q[n]
  • the dependent variables are the flip-flops' entries FF[0], FF[1], ... FF[n], which depend on the current state, the desired state, and your flip-flop type
  • there may be extra independent variables like a reset entry, or an up/down entry for an up/down counter
bool _abb_in_order(abb_nodo_t *nodo, bool visitar(const char *, void *, void *), void *extra){
if (!nodo)
return true;
return _abb_in_order(nodo->der, visitar, extra)
&& visitar(nodo->clave, nodo->dato, extra)
&& _abb_in_order(nodo->izq, visitar, extra);
}
void abb_in_order(abb_t *arbol, bool visitar(const char *, void *, void *), void *extra){
_abb_in_order(arbol->raiz, visitar, extra);
@colltoaction
colltoaction / buscar_persona_iter_interno1.c
Last active August 29, 2015 14:07
Ejemplos de iterador interno
struct paramentro_buscador_de_persona {
char* nombre;
persona_t* salida;
};
// Función usada para buscar una persona con un nombre usando
// struct paramentro_buscador_de_persona como extra
bool buscador_de_persona(void* dato, void* extra){
struct paramentro_buscador_de_persona* param = extra;
char* nombre = param->nombre;
persona_t* persona = dato;
@colltoaction
colltoaction / escalera.py
Created August 29, 2014 22:42
Ejercicio de la escalera implementado con y sin Programación Dinámica.
def escalera_feo(n):
if n == 1:
return 1
elif n == 2:
return 2
return escalera_feo(n - 1) + escalera_feo(n - 2)
def escalera(n):
d = { 1 : 1, 2 : 2 }
return escalera_r(n, d)
def replicar(lista, repeticiones):
if len(lista) <= 1:
return lista * repeticiones
mitad = len(lista) / 2
return replicar(lista[:mitad], repeticiones) + replicar(lista[mitad:], repeticiones)
#! /usr/bin/env python2
# coding=utf8
class Cruz(object):
def __repr__(self):
return "X"
def __eq__(self, other):
return isinstance(other, self.__class__)