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 java.awt.Point; | |
public class LoopFill { | |
public static void main(String[] args) { | |
LoopFill loopFiller = new LoopFill(); | |
int[] result; | |
try { | |
result = parseArgs(args); |
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
#! /usr/bin/python | |
from random import randint | |
from time import time | |
VALUE_RANGE = (0, 1000) | |
def timer(f): | |
def wrapper(first_list, second_list, required_difference): | |
t1 = time() |
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
#! /usr/bin/python | |
from time import time | |
from collections import Counter | |
from random import randint | |
######################################### | |
# Test functions. Used for testing | |
######################################## | |
VALUES = (1, 100000) |
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 java.io.*; | |
public class FilePathFinder { | |
public static void main(String[] args) { | |
String path = getInput(); | |
boolean validatePath = validatePath(path); | |
System.out.println("Path exists? "); | |
System.out.println(validatePath); |
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 java.io.*; | |
import java.util.*; | |
import com.mycompany.guesstheanimal.exceptions.InvalidTreeParsingException; | |
public class QuestionNodeTreeBuilder implements TreeBuilder<QuestionNode>{ | |
public static final String NODE_DATA_SPLITTER = QuestionNodeTreeWriter.NODE_DATA_SPLITTER; | |
public static final String QUESTION_PREFIX = QuestionNodeTreeWriter.QUESTION_PREFIX; | |
public static final String ANSWER_PREFIX = QuestionNodeTreeWriter.ANSWER_PREFIX; | |
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 itertools import ifilter | |
from time import time | |
def time_it(func, *args, **kwargs): | |
def func_wrapper(*args, **kwargs): | |
t1 = time() | |
func(*args, **kwargs) | |
t2 = time() | |
print("Function Executed in: {} seconds".format(t2 - t1)) | |
return func_wrapper |
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
class FantasyTeam(object): | |
def __init__(self): | |
self._roster = {'RB' : None, | |
'QB' : None, | |
... , | |
'WR': None} | |
self._points = 0.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
(defn every-nth [f data n & {:keys [n-times] :or {n-times -1}}] | |
"Applies the function to every nth element, leaving other elements unaltered" | |
(map-indexed #(if (and | |
(zero? (mod (Math/abs (+ %1 1)) n)) | |
(> n (quot %1 (* (Integer/signum n) n-times)))) | |
(f %2) %2) | |
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
from random import randint | |
class KMeans: | |
def __init__(self, minimum, maximum, dim, k): | |
self._centroids = [[randint(minimum, maximum) for d in range(dim)] for x in range(k] | |
self._points = {i: [] for i in range(k)} | |
def update(self, vector): | |
distance = lambda v: sqrt(sum([(x2-x1) ** 2 for x1, x2 in zip(v[1], vector)])) |
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
#! /usr/bin/env python | |
import subprocess | |
import argparse | |
import httplib | |
import json | |
parser = argparse.ArgumentParser(description="print out all documents in an index to stdout") | |
parser.add_argument("--index", type=str) | |
parser.add_argument("--host", type=str) | |
parser.add_argument("--port", default=9200, type=int) |
OlderNewer