Made by Alec and Chris at the Recurse Center.
import math | |
"""Implementation of min heap | |
Works with Python 2 or 3 | |
Run from terminal: | |
`python heap.py` | |
""" | |
class Heap(object): |
### Implementation of Hash Table | |
# Methods: insert, search, delete | |
# Language: Python 2 or Python 3 | |
import json | |
## initialize hash_table | |
# arg n (int): length of the hash table | |
class hash_table(object): | |
def __init__(self,n=10): | |
self.length = n |
Inspired by the New York Times' You Draw It, which allows the user to trace a line with the mouse that immediately appears on the screen, with specific constraints. Mouse event technique from https://bl.ocks.org/mbostock/4198499.
#Subway (1) Line as Network Graph
I set out to create a map of the entire subway as a network graph. I got bogged down with cleaning the data, which I drew from two NYC Open Data sets. Until I can get the full subway system working, here is what one subway line looks like.
The subway stations data set does not indicate the order of the stations, and the lines dataset does not have the stations in it. I'm working on devising a better system of placing stations on the lines, but in the mean time I have resorted to a heuristic where a station is on a line if it is "close enough" to the line.
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.4/lodash.min.js"></script> | |
<script | |
src="https://code.jquery.com/jquery-3.1.1.min.js" | |
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" | |
crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css"> |
import math | |
import functools | |
""" radix_sort | |
in: list_to_sort (list) | |
in: base (optional) | |
out: sorted list_to_sort | |
""" | |
def radix_sort(list_to_sort,base=10): | |
# number of significant digits of largest number |
;; LRU Cache Implementation | |
;; New items are added to the end and old items removed from the start. | |
;; Try running it at https://repl.it/languages/scheme | |
;; make-lru-cache: returns procedure with access to cache procedures | |
;; [arg] maxlen: maximum length of the cache | |
(define (make-lru-cache maxlen) | |
;; cache is initialized as empty list | |
;; first elem is actual cache, second elem is pointer to end of cache |
<html> | |
<head> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/vis/4.18.1/vis.min.js"></script> | |
<script | |
src="https://code.jquery.com/jquery-3.1.1.min.js" | |
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" | |
crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css"> | |
<style> |
#!/bin/python3 | |
import sys | |
import itertools | |
import functools | |
n = int(input().strip()) | |
letters = [ | |
[x for x in "aeiou"], |