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
#!/usr/bin/env zsh | |
# NOTE: Has an implicit dependency on Homebrew | |
# NOTE: Expects Ruby and Git to already be installed. | |
# Define the URL and target directory | |
zip_file="rubykoans.zip" | |
url="https://github.com/edgecase/ruby_koans/blob/master/download/${zip_file}?raw=true" | |
# Download the zip file |
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
let list = [ 'val1', 'val2' ]; | |
// Least nice | |
for(let i = 0; i < list.length; i++) { | |
console.log(list[i]); | |
} | |
// Nicer | |
list.forEach((element) => { | |
console.log(element); |
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
let thing = { attr1: 'val1', attr2: 'val2' }; | |
// Least nice | |
let keys = Object.keys(thing); | |
for(let i = 0; i < keys.length; i++) { | |
console.log(thing[keys[i]]); | |
} | |
// Nicer | |
Object.keys(thing).forEach((attribute) => { |
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
exports.handler = async function(event, context) { | |
// Your code goes here ... | |
let success = function() { | |
// Do stuff ... | |
}; | |
// Exit the handler by invoking the callback. | |
// The first argument is an error object (null indicates success). |
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
Move #0: Initial state | |
1 | |
2 | |
3 | |
4 | |
5 | |
- - - | |
Move #1: Move value=1 from Tower=0 to Tower=2 | |
2 |
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
// - An Adjacency Matrix stores the Set of all possible Edges. | |
// - Each row represents a Node, storing the complete Set of possible Edges for that Node. | |
// - The index of the element in the outer Array indicates the ID of the Node. | |
// - A value of 1 indicates an Edge. A 0 indicates no Edge. | |
// | |
// In this example: | |
// - Node 0 has an Edge to Node 3 | |
// - Node 1 has Edges to Nodes 0 and 3 | |
// - Node 2 has Edges to Nodes 0, 1 and 3 | |
// - Node 3 has an Edge to Node 1 |
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
// The index of the element in the outer Array is the 'id' of the Node in the Graph. | |
// Each element in the outer Array contains the Set of IDs to which that Node is connected. | |
// | |
// e.g. Node 0 has Edges to Nodes 1 and 2 | |
// Node 1 has no Edges | |
// Node 2 has Edges to Nodes 0, 1 and 3 | |
// Node 3 only has an Edge to Node 2 | |
let graphAsList = [ | |
[1, 2], |
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
// Each element in the Array represents an Edge between the two Nodes with the IDs in that element. | |
// Every element in the array will have exactly two values. | |
// The indices of the elements in either the inner our outer Arrays have no meaning. | |
let graph = [[1, 2], [0, 3], [1, 3], [2, 0]]; |
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
Show hidden characters
{ | |
"presets": [ | |
"env" | |
], | |
"env": { | |
"test": { | |
"presets": [ | |
"env" | |
] | |
} |
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
import Node from 'binary-tree-node'; | |
class BinaryTree { | |
constructor() { | |
this.root = new Node(); | |
} | |
// ... other methods | |
add(value) { |
NewerOlder