Skip to content

Instantly share code, notes, and snippets.

View eltrufas's full-sized avatar

Rafael Castillo eltrufas

View GitHub Profile
@eltrufas
eltrufas / adv3.py
Created December 3, 2018 05:38
advent of code day 3
import sys
lines = list(sys.stdin)
ss = [l.split(" ") for l in lines]
rects = []
for s in ss:
print(s)
x, y = s[2][:-1].split(',')
(defun randn (s n)
"Regresa un numero aleatorio en [s, n)"
(+ s (random (- n s))))
(defun mod-exp (base exponent modulus)
"Calcula el exponente modular"
(cond ((zerop exponent) 1)
((evenp exponent) (mod-exp (mod (* base base) modulus)
(truncate exponent 2) modulus))
((oddp exponent) (mod (* base (mod-exp base

Keybase proof

I hereby claim:

  • I am eltrufas on github.
  • I am rafaelc (https://keybase.io/rafaelc) on keybase.
  • I have a public key ASCDUZGMuDzzc8utjT9tBvmg_7D0MGU0SUixw8jTDYUgnwo

To claim this, I am signing this object:

var IStates [4][16]int = [4][16]int{
{
0, 0, 0, 0,
1, 1, 1, 1,
0, 0, 0, 0,
0, 0, 0, 0,
},
{
0, 0, 1, 0,
0, 0, 1, 0,
@eltrufas
eltrufas / go.md
Created January 25, 2018 22:37
Recursos para aprender Go
package genemath
import (
"math/rand"
"github.com/eltrufas/genetic"
)
const (
// MINIMIZE means we're maximizing the algo
@eltrufas
eltrufas / genetic.go
Created February 14, 2017 04:01
Chingaderas
package genetic
import "math/rand"
// Individual representa las caracteristicas de un individuo de una poblacion
type Individual interface {
Crossover(Individual) (Individual, Individual)
Mutate() Individual
Fitness() float32
Copy() Individual
package main
import (
"fmt"
"math/rand"
"os"
"strconv"
"time"
)
@eltrufas
eltrufas / n-queens.go
Last active February 8, 2017 22:10
Solution to the n queen problem in go using genetic algorithms. Includes a solution with and without using goroutines
package main
import (
"fmt"
"math/rand"
"time"
)
type Individual struct {
queens []int