This file contains hidden or 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
type Maybe = Some | None; | |
class Option<A> { | |
value: A; | |
constructor(x: ?A) { | |
if (x == null) { | |
return new None(); | |
} else { | |
return new Some(x); | |
} |
This file contains hidden or 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 lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>Webworker Redux</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.6/react-dom.js"></script> |
This file contains hidden or 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> | |
<title> D3 Shape Test</title> | |
<style type="text/css"> | |
path { | |
stroke: black; | |
fill: none; | |
stroke-width: 0.5px; | |
shape-rendering: optimizeQuality; |
This file contains hidden or 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
"use strict"; | |
const Rx = require('rx'); | |
const fetch = require('isomorphic-fetch'); /* use the fetch api on client and server */ | |
/** | |
* Given a subreddit, pull down post ids. that is, changing the subreddit by calling terms$.onNext(SUBREDDITNAME) | |
* automatically calls the reddit api and populates the store. | |
* To try it out, npm install rx and isomorphic-fetch, then | |
* var S = require('./index.js'); | |
* S.store$.subscribe(x => console.log(x)); // listen to every state change |
This file contains hidden or 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
function mergesort(xs) { | |
if (xs.length < 2) { | |
return xs | |
} | |
const n = xs.length / 2 | 0; | |
return merge(mergesort(xs.slice(0, n)), mergesort(xs.slice(n))); | |
} | |
function merge(xs, ys) { |
This file contains hidden or 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
'use strict'; | |
const example = [ | |
['a', 'c', 'l', 'b'], | |
['r', 'e', 'b', 'u'], | |
['i', 'n', 'g', 's'], | |
['l', 'm', 'n', 'o'] | |
]; | |
console.log(contains(example, 'caring')); |
This file contains hidden or 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
type Board = [[Char]] | |
data Link = Link { pos :: (Int, Int) | |
, vis :: [(Int, Int)] | |
, mat :: [Char] } deriving Show | |
neighbors :: Board -> Int -> Int -> [(Int, Int)] | |
neighbors b i j = [(x, y) | x <- [(i - 1) .. (i + 1)], | |
y <- [(j - 1) .. (j + 1)], |
This file contains hidden or 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
{- | |
Given a matrix of characters like | |
[['a', 'c', 'l', 'b'], | |
['r', 'e', 'b', 'u'], | |
['l', 'n', 'c', 's'], | |
['c', 'm', 'n', 'o']] | |
determine if a given string like "care" can | |
be found by navigating through the matrix without | |
repeating characters - ie snake rules |
This file contains hidden or 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
{- | |
Given a matrix of characters like | |
[['a', 'c', 'l', 'b'], | |
['r', 'e', 'b', 'u'], | |
['l', 'n', 'c', 's'], | |
['c', 'm', 'n', 'o']] | |
determine if a given string like "care" can | |
be found by navigating through the matrix without | |
repeating characters - ie snake rules |
This file contains hidden or 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
use std::collections::VecDeque; | |
use std::collections::HashSet; | |
use std::hash::{Hash, Hasher}; | |
use std::env::args; | |
use std::time::Instant; | |
const MAX_ITER: usize = 1000000000000; | |
const DIRECTIONS: [Move; 4] = [Move::Down, Move::Up, Move::Left, Move::Right]; | |
fn main() { |