View disjointSet.js
/* | |
Useful for HackerRank problems. | |
*/ | |
function main (numNodes, edges) { | |
const parent = []; | |
const rank = []; | |
function makeSet (x) { |
View gist:fcb7548ef7cde329c460
I) About me: | |
a) Peter Hayes, engineer at ClassDojo | |
b) Studied mathematical economics at Brown, used to be a high school math teacher | |
c) Follow me on github/check out my npm. don't follow my twitter | |
II) Introduction | |
a) Topics today: heaps, quadtrees, graphs | |
b) What are data structures for? | |
1) Not just to store data - an unstructured blob can store data | |
3) Rather: store data with *efficient* insertion, access, and retrieval |
View gist:2276e305ff74cce8131e
On schoolTeacher resource: | |
{ | |
_items: [ | |
{ | |
_id: 1234 | |
... | |
_links: { | |
befriend/poolWith/etc: { | |
href: "/api/teacher/1234/friends", | |
method: "POST", |
View Description
// We write the problem as a table. Each row represents the amount of change to make, | |
// and the value at each column represents the highest coin we're allowed to use | |
// in making that amount of change | |
// That is to say, in row 5, col 2 is the number of ways to make 5 cents, using only the two lowest coins. | |
// To calculate the value of each square, we add the values of two other squares together - | |
// * The square to the left, which represents all possibilites using smaller coins. | |
// * The square as many rows above as the value of that coin. | |
// This is all possibilities after taking away one of this coin | |
// This method avoids having to ever call things recursively - we just build a big table! |
View montecarlo.js
var integrate = function() { | |
// return 42; | |
var iters = 2000; | |
var d = getGraphDimensions(); | |
var width = d.x.max - d.x.min; | |
var height = d.y.max - d.y.min; | |
var xmin = d.x.min; |