Skip to content

Instantly share code, notes, and snippets.

View niklio's full-sized avatar

Nik Liolios niklio

  • Instagram
  • New York
View GitHub Profile
template <typename T>
void SortAlg<T>::insertionSort(typename vector<T>::iterator s,
typename vector<T>::iterator e) {
typename vector<T>::iterator i, j;
for (i = s + 1; i < e; i++) for (j = i; j > s && *(j - 1) > *j; j--) iter_swap(j, j - 1);
}
/*
* ============
* Alphabetizer
* ============
*
* File: AlphaTesting.cpp
* ----------------------
* This file contains the AlphaTesting class to unit test each function in
* Alphabetizer
*
@niklio
niklio / around.nlogo
Created May 17, 2016 03:26
Netlogo explorations #1
(fn '(zeros n) '(if n '(cons 0 (zeros (- n 1))) '('())))
(fn '(cantor-2 depth)
'(if depth
'((\ '(x) '(join x (zeros (len x)) x))(cantor-2 (- depth 1)))
'('(1))))
@niklio
niklio / findsat.py
Last active December 1, 2015 23:03
import csv
class Tagged(object):
def __init__(self, data, tags):
assert len(data[0]) == len(tags)
self.data = data
self.tags = tags
import csv
import pymysql.cursors
connection = pymysql.connect(host='localhost',
user='root',
password='wpbvre999',
db='cs490',
charset='utf8mb4',
cursorclass=pymysql.cursors.DictCursor)
CREATE TABLE `space_ship` (
`name` varchar(128) NOT NULL,
`seq_num` bigint(20) NOT NULL,
`country` varchar(128) NOT NULL,
`captain` varchar(128),
`flight` timestamp,
PRIMARY KEY (seq_num),
UNIQUE KEY (captain, flight),
UNIQUE KEY (name, seq_num)
);
import wikipedia, sys
def AStar(start, goal):
closedset = []
openset = [trypage(link) for link in start.links]
navigated = {}
g_score = lambda start: 0
f_score = lambda start: g_score(start) + heuristic_cost(start, goal)