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
"enter current millenium | |
set nocompatible | |
syntax on | |
filetype plugin indent on | |
" show existing tab with 4 spaces width | |
set tabstop=4 | |
" when indenting with '>', use 4 spaces width | |
set shiftwidth=4 | |
" On pressing tab, insert 4 spaces |
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 torch | |
import torch.nn as nn | |
import torch.nn.functional as F | |
import torch.optim as optim | |
import numpy as np | |
import os | |
from torch.utils.data import DataLoader, TensorDataset, Dataset | |
import operator | |
import data_loader | |
import pickle |
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
from search import SearchProblem, a_star_search | |
class NiceProblem(SearchProblem): | |
def __init__(self): | |
self.node = (0,0) | |
self.expanded = 0 | |
def get_start_state(self): | |
""" | |
Returns the start state for the search problem |
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
from multiprocessing.dummy import Pool | |
from subprocess import check_output | |
NUMBER_OF_PROCESSES = 4 | |
to_run = [ | |
'-p tiny_set.txt -s 4 7 -z fill', | |
'-p tiny_set.txt -f bfs -s 4 7 -z fill', | |
'-p tiny_set_2.txt -f bfs -s 6 6 -z corners', | |
'-p tiny_set_2.txt -f ucs -s 6 6 -z corners', |
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
data List a = Node a (List a) | Empty -- Recursive | |
data Maze = Maze {grid::Grid, visited::Path, stack::Stack} | |
type Path = List Cell | |
--type Stack = [Cell] | |
type Stack = List Cell | |
type Grid = [[Char]] | |
-- Linked List -- | |
push :: List a -> List a -> List a | |
push Empty ys = ys |
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
def mergeSort(A): | |
mid = len(A) // 2 | |
if len(A) > 1: | |
left = mergeSort(A[:mid]) | |
right = mergeSort(A[mid:]) | |
# merge | |
i = j = k = 0 | |
while i < len(left) and j < len(right): | |
if left[i] < right[j]: |
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
data MyList a = Empty | List (a, (MyList a)) deriving (Show, Eq) | |
instance Functor MyList where | |
fmap _ Empty = Empty | |
fmap f (List (x, xs)) = List (f x, fmap f xs) | |
flatten :: (MyList (MyList (a))) -> (MyList a) | |
flatten Empty = Empty | |
flatten (List (x, xs)) = myConcat x (flatten xs) |
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 Control.Monad.Writer | |
type Tower = ([Int], Char) | |
data Hanoi = Hanoi Tower Tower Tower deriving Show | |
move :: Hanoi -> Hanoi | |
move (Hanoi a b c) = Hanoi (init (fst a), snd a) b ((fst c) ++ [last (fst a)], snd c) | |
solve :: Hanoi -> Writer [String] Hanoi | |
solve (Hanoi a b c) = solve' (length (fst a)) (Hanoi a 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
#################################################### | |
# Measure times of executions for DB's External Sort | |
# Assumptions: | |
# - Your ExternalMemory.jar is in /tmp | |
# - fileGenerator.jar in /tmp | |
# What does it do? | |
# Generates the files 250, 500, 750, 1000 in /tmp. | |
# They should be in about the size of their name. | |
# Create the "/tmp/sortemp" directory if not exists | |
# Measures running time of your program for each |
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
data NiceTree = R | B | Node [NiceTree] deriving (Show, Eq) | |
exmpl = Node [Node [R, B, B], Node [B], Node [R, R], Node [B]] | |
eval :: NiceTree -> NiceTree | |
eval R = R | |
eval B = B | |
eval (Node xs) | |
| res == 0 = error "can't compute tie" | |
| res > 0 = R |
NewerOlder