This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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-') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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,:] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"io/ioutil" | |
"log" | |
) | |
func temp(...interface{}) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
) | |
var ( | |
n int = 8 | |
l []int = make([]int, n*2) | |
used map[int]bool = make(map[int]bool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
limit = 6 | |
frac = 0.8 | |
def draw(size, inv = False): | |
if size > limit: | |
t.lt(90) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
@NSApplicationMain | |
class AppDelegate: NSObject, NSApplicationDelegate { | |
var statusItem:NSStatusItem! | |
var timer:NSTimer! | |
func applicationDidFinishLaunching(aNotification: NSNotification) { | |
let statusBar = NSStatusBar.systemStatusBar() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
import Journey | |
import copy | |
__pool_size__ = 90 | |
__survival_limit__ = 30 | |
__mutation_rate__ = 5 | |