- Koch Snowflake
- Toothpick Pattern
- Ulam Warburton Cellular Automaton
- Hilbert's Curve
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
/** | |
* | |
* -10 | |
/ \ | |
9 20 | |
/ \ | |
15 7 | |
* | |
* | |
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
type AVLNode<T> = { | |
left: AVLNode<T>, | |
right: AVLNode<T>, | |
val: T, | |
height: number | |
} | null; | |
type CompareResult = -1 | 0 | 1; | |
function compare<T>(x: T, y: T): CompareResult { |
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
const arr_odd = [ | |
[1, 2, 3, 4, 5], | |
[16, 17, 18, 19, 6], | |
[15, 24, 25, 20, 7], | |
[14, 23, 22, 21, 8], | |
[13, 12, 11, 10, 9] | |
]; | |
const arr_even = [ | |
[1, 2, 3, 4, 5, 6], |
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
// TOKEN types | |
const COLON = 'COLON'; | |
const L_CURLY = 'L_CURLY'; | |
const R_CURLY = 'R_CURLY'; | |
const L_SQUARE = 'L_SQUARE'; | |
const R_SQUARE = 'R_SQUARE'; | |
const COMMA = 'COMMA'; | |
const BOOLEAN_LITERAL = 'BOOLEAN_LITERAL'; | |
const NUMBER_LITERAL = 'NUMBER_LITERAL'; |
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 | |
//Result deines the result of a Computation | |
type Result struct { | |
product int | |
row, col int | |
} | |
//Compute take a Compuataion as input and writes the Result on to a channel | |
func Compute(row, col int, rowSlice, colSlice []int, out chan<- Result) { |
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
function ColorGenerator() { | |
let index = 0; | |
const colors = ["red", "green", "blue", "yellow", "black", "white"]; | |
const rand = (s, e) => Math.random() * (e - s + 1); | |
return { | |
generate: () => colors[index++ % colors.length], | |
generateRGB: () => `rgb(${rand(0, 255)}, ${1}, ${rand(0, 255)})` | |
}; |
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
function flatten(xs) { | |
var ys = []; | |
var stack = [[0, xs]]; | |
while(stack.length > 0) { | |
var [index, arr] = stack.pop(); | |
while(index < arr.length) { | |
if (Array.isArray(arr[index])) { | |
stack.push([index+1, arr]); |
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
function flatten(xs) { | |
var itr = xs; | |
while (true) { | |
var ys = []; | |
var allFlat = true; | |
itr.forEach(x => !(allFlat = (!Array.isArray(x) && allFlat)) ? (ys = ys.concat(x)) : ys.push(x)); | |
if (allFlat) return ys; | |
itr = ys; | |
} | |
} |
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> | |
<title>Snake Pub Sub</title> | |
</head> | |
<body> | |
<canvas id="canvas" height="500" width="500"> |