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 unittest | |
from functools import partial | |
class BinaryTree(object): | |
""" | |
In computer science, a binary tree is a tree data structure in which each | |
node has at most two children (referred to as the left child and the right | |
child). | |
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 unittest | |
from functools import partial | |
class BinaryTree(object): | |
""" | |
In computer science, a binary tree is a tree data structure in which each | |
node has at most two children (referred to as the left child and the right | |
child). | |
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 time | |
def print_board(board): | |
for row in board: | |
for column in row: | |
print(column), | |
print("") | |
print("- " * len(board[0])) | |
def count_neighbours(x, y, board): |
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
""" | |
Write code that, given a tree with weighted nodes, prints, for each node, | |
the weight of the subtree rooted at that node (each node only knows it's own ID, | |
it's parent's ID and it's own weight). | |
e.g | |
you get a csv with the following format: | |
id, parent, weight |
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
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<style> | |
body { | |
background-color: black; | |
} | |
#mycanvas { | |
background-color: black; | |
font-color: green; |
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 product | |
def my_product(head, *tail): | |
if not tail: | |
return ((h,) for h in head) | |
return ((h,) + t for h in head for t in my_product(*tail)) | |
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
__author__ = 'quatrix' | |
import re | |
import unittest | |
def _get_lowest_version(s): | |
""" | |
Takes a string of the following format: |
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
var React = require('react'); | |
var forms = require('newforms'); | |
var _ = require('underscore'); | |
var RegexValidator = forms.validators.RegexValidator | |
var $ = require('jquery'); | |
var schema = { | |
"$schema": "http://json-schema.org/draft-04/schema#", | |
"id": "/", | |
"type": "object", |
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 | |
// basically just reimplemented (paritally) the TimeSpanSemaphore | |
// as specified here http://joelfillmore.com/throttling-web-api-calls/ | |
import ( | |
"container/heap" | |
"fmt" | |
"sync" | |
"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
import json | |
def flatten(n): | |
while True: | |
changed = False | |
for k, v in n.iteritems(): | |
if len(v.keys()) == 1: | |
del n[k] | |
vk = v.keys()[0] | |
n[k + '/' + vk] = v[vk] |
OlderNewer