Skip to content

Instantly share code, notes, and snippets.

View itarato's full-sized avatar

Peter Arato itarato

  • Montreal, Canada
  • 01:08 (UTC -04:00)
View GitHub Profile
@itarato
itarato / diet.py
Created March 22, 2015 12:47
Diet. FB, ch, mid.
found = False
def solve(results, parts, sums, idx):
global found
if found:
return True
if sums == results:
found = True
@itarato
itarato / Doxygen
Created May 1, 2015 14:23
Doxygen example for PHP code
# Doxyfile 1.8.9
#---------------------------------------------------------------------------
# Project related configuration options
#---------------------------------------------------------------------------
DOXYFILE_ENCODING = UTF-8
PROJECT_NAME = "Cameron & Wilding Tool"
PROJECT_NUMBER =
PROJECT_BRIEF = "Drupal 7 Architecture tool"
PROJECT_LOGO = /Users/itarato/Desktop/logo.png
@itarato
itarato / mushroom.hs
Created June 1, 2015 20:30
Mushroom eater puzzle
import System.IO
import Control.Monad
solve_v1 :: [Int] -> Int
solve_v1 (a:[]) = 0
solve_v1 (a:b:c) = (if a > b then a - b else 0) + (solve_v1 (b:c))
min_dist :: [Int] -> Int
min_dist (a:[]) = 0
min_dist (a:b:c) = if a > b then max (min_dist (b:c)) (a - b) else min_dist (b:c)
@itarato
itarato / li_reg.py
Created July 18, 2015 17:51
Linear regression of my weight
import numpy as np
import matplotlib.pyplot as plt
def plot_result(O):
sample_size = 50
linX = np.linspace(np.min(npdata[:,1]), np.max(npdata[:,1]), num=sample_size)
testX = np.concatenate((np.ones((sample_size, 1)), linX.reshape((sample_size, 1))), axis=1)
y = np.dot(testX, O)
plt.plot(linX, y[:,0], 'r-')
@itarato
itarato / lin_reg_norm_eq.py
Created July 18, 2015 18:15
Linear regression with normal equation
import numpy as np
import matplotlib.pyplot as plt
def plot_result(O):
sample_size = 50
linX = np.linspace(np.min(npdata[:,1]), np.max(npdata[:,1]), num=sample_size)
testX = np.concatenate((np.ones((sample_size, 1)), linX.reshape((sample_size, 1))), axis=1)
y = np.dot(testX, O)
plt.plot(linX, y[:,0], 'r-')
@itarato
itarato / logistic_regression_2d.py
Created July 19, 2015 11:42
2D Logistic Regression
import numpy as np
import matplotlib.pyplot as plt
if __name__ == '__main__':
fin = file('logreg.txt', 'r')
npdata = np.genfromtxt(fin, delimiter=',')
posData = npdata[npdata[:,2] == 1,:]
negData = npdata[npdata[:,2] == 0,:]
@itarato
itarato / neural_network_trainer.py
Created July 25, 2015 18:17
Small neural network trainer.
import numpy as np
class NeuralNetwork:
def __init__(self, data, layer_sizes):
"""
:param data: (M)x(N+1) matrix of inout data, Y is in last column.
:param iteration: Iteration count for training.
"""
self.data = data
@itarato
itarato / ch224i.go
Last active August 29, 2015 14:25
Challenge 224 intermediate
package main
import (
"bytes"
"io/ioutil"
"log"
)
func temp(...interface{}) {}
@itarato
itarato / ch224h.go
Created July 27, 2015 08:22
Challenge 224 hard - Langford strings
package main
import (
"log"
)
var (
n int = 8
l []int = make([]int, n*2)
used map[int]bool = make(map[int]bool)
@itarato
itarato / heighway_dragon.py
Created July 28, 2015 08:03
Heighway dragon fractal
import turtle
limit = 6
frac = 0.8
def draw(size, inv = False):
if size > limit:
t.lt(90)