This is an implementation of The Knight's Tour problem/solution in JavaScript.
To run:
node tour.js
// Implementation of breadth-first search in JavaScript. | |
function breadthFirstSearch(g, start, end) { | |
const queue = [[start]]; | |
const visited = {}; | |
while (queue.length > 0) { | |
const path = queue.shift(); | |
const node = path[path.length - 1]; | |
if (node === end) { | |
console.log("number of steps:", path.length - 1); |
// Implementation of heapsort in JavaScript. | |
LENGTH = 1e2; | |
MAX = 2e4; | |
MIN = 1; | |
function generateInput(min, max, length) { | |
const res = []; | |
while (res.length < length) { | |
res.push(Math.round(Math.random() * (max - min) + min)); |
// Implementation of bubblesort in JavaScript. This might take a while... | |
LENGTH = 1e5; | |
MAX = 2e4; | |
MIN = 1; | |
function generateInput(min, max, length) { | |
const res = []; | |
while (res.length < length) { | |
res.push(Math.round(Math.random() * (max - min) + min)); |
/** | |
* Add each integer in a string which matches the next integer in the string. | |
* | |
* @param {string} input A string of integers to add up. | |
* @param {boolean} circular Indicates whether we should wrap around to the | |
* beginning of the input string when evaluating the last integer. | |
*/ | |
function addEmUpNext(input, circular = false) { | |
let res = 0; | |
for (let i = 0; i < input.length; i++) { |
// The Tron Problem | |
// Greetings future Episource employee! You have been "randomly" selected to participate in the 11th annual Tron games! | |
// Don't worry, you won't be actually playing the games. You'll be judging the battles after the fact! | |
// Let me take a quick second to brief you on the Tron Standard Rules(TSRs). | |
// 1) The game is played on a standard 10x10 board | |
// 2) Player 1 starts on position 0x0 (top left corner). Player 2 starts on position 9x9 (bottom right corner). | |
// 3) At each turn, a player may move up, down, left, or right on the board. | |
// These steps are held in an array and take the form 'u', 'd', 'l', and 'r' respectively. | |
// 4) If a player crosses a previous path of another player, including themselves, they are eliminated. |
/* @flow */ | |
export type Range<P> = { | |
payload: P, | |
start: number, | |
end: number, | |
priority: number, | |
}; | |
/** |
const MIN = -1e3; | |
const MAX = 1e3; | |
const SIZE = 1e6; | |
/** | |
* Get a random number between min and max. | |
* | |
* @param min the minimum integer possible. | |
* @param max the maximum integer possible. | |
*/ |
I hereby claim:
To claim this, I am signing this object:
filter @type = "REPORT" | |
| stats | |
avg(@billedDuration) as Average, | |
percentile(@billedDuration, 99) as NinetyNinth, | |
percentile(@billedDuration, 95) as NinetyFifth, | |
percentile(@billedDuration, 90) as Ninetieth | |
by bin(30m) |