Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@josh-stevens
josh-stevens / graph.js
Created April 3, 2019 20:26
Simple graph
class Graph {
constructor(numberOfVertices) {
this.size = numberOfVertices;
this.list = new Map();
}
addVertex(v) {
this.list.set(v, []);
}
addEdge(v, w) {
this.list.get(v).push(w);
@josh-stevens
josh-stevens / TextScramble.js
Created February 14, 2019 16:40
Cool text scramble effect (use Roboto Mono 100 + #FAFAFA + #757575 for colors
import React, { Component, Fragment } from 'react';
const chars = '!<>-_\\/[]{}-=+*^?#________';
class TextScramble extends Component {
constructor(props) {
super(props);
this.string = props.children;
this.length = this.string.length;
this.queue = [];
@josh-stevens
josh-stevens / BST.js
Created February 10, 2019 04:41
Basic Binary Search Tree in Javascript
class Node {
constructor(value, parent) {
this.value = value;
this.parent = parent || null;
this.left = null;
this.right = null;
}
insert(value) {
if (value > this.value) {
if (this.right === null) {
@josh-stevens
josh-stevens / elevator8.js
Last active October 19, 2018 14:46
Solution for elevator challenge 8
{
init: function(elevators, floors) {
elevators.forEach(elevator => {
elevator.on('floor_button_pressed', (num) => {
elevator.goToFloor(num);
});
});
floorHandler = (floor) => {
let closest, idle;

Keybase proof

I hereby claim:

  • I am josh-stevens on github.
  • I am joshstevens (https://keybase.io/joshstevens) on keybase.
  • I have a public key ASAE3Kf-wxBVJU1OnAi_FfQph91OvTG2C5Ex-53GxOC30go

To claim this, I am signing this object: