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 bash | |
npx shadow-cljs compile run-one-test && node ./target/run-one-test.js $@ |
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
(ns route.core | |
(:require [clojure.string :as string])) | |
(defn map-vals [f m] | |
(into {} (map (fn [[k v]] [k (f v)]) m))) | |
(defn split-path [path] | |
(let [sub-paths (string/split path #"/")] | |
(if (= (first sub-paths) "") | |
(rest sub-paths) |
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
# node | |
node_modules | |
build | |
# VS Code | |
.vscode | |
# Mac | |
.DS_Store |
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
module RecursiveBacktrackerMazeGenerator | |
// ++++++++++ | |
// + Random + | |
// ++++++++++ | |
module Random = | |
let _rng = new System.Random() | |
let nextInt lo hi = _rng.Next(lo, hi) |
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
use std::iter::FromIterator; | |
use std::iter::Iterator; | |
use std::cmp::min; | |
use std::cmp::Ord; | |
#[derive(Debug)] | |
#[derive(Clone)] | |
pub enum Edit{ | |
Delete, | |
Insert, |
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
fn partition<T, F>(elems: &mut [T], pred: F ) -> usize | |
where F: Fn(&T) -> bool | |
{ | |
let mut i = 0; | |
for j in 0 .. elems.len(){ | |
if pred(&elems[j]) { | |
elems.swap(i, j); | |
i += 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
module SuffixArray | |
open System | |
// ++++++++ | |
// + util + | |
// ++++++++ | |
let time f = | |
let t = new Diagnostics.Stopwatch() |
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
module StreamFizzBuzz | |
// Infinite stream of positive integers starting at 1. | |
let nums = Seq.initInfinite ((+) 1) | |
// Infinite stream of boolean literals, every fifth literal is true. | |
let buzzes = seq {while true do yield! [false; false; false; false; true]} | |
// Infinite stream of boolean literals, every third literal is true. | |
let fizzes = seq {while true do yield! [false; false; true]} |
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
use std::fs::File; | |
use std::fmt::Write as W; | |
use std::os::unix::io::{FromRawFd, IntoRawFd}; | |
use std::io::{BufRead, BufReader, BufWriter, Write}; | |
// ++++++++++++++ | |
// + IO helpers + | |
// ++++++++++++++ | |
macro_rules! scan { |