Skip to content

Instantly share code, notes, and snippets.

@tomtheisen
tomtheisen / app.ts
Created February 15, 2019 18:43
ts-loader bigint literal repro
let a = 3n;
@tomtheisen
tomtheisen / index.html
Last active February 6, 2019 15:02
Vendor Convert
<!DOCTYPE html>
<html>
<head>
<title>Vendor Convert</title>
<meta charset=utf-8>
<style>
body {
font-size: 200%;
font-family: sans-serif;
color: firebrick;
@tomtheisen
tomtheisen / day23-2.linq
Last active January 4, 2019 19:44
AOC2018 day 23 part 2
<Query Kind="Program">
<Namespace>static System.Math</Namespace>
</Query>
struct Point3 {
public int X;
public int Y;
public int Z;
public Point3(int x, int y, int z) => (X, Y, Z) = (x, y, z);
public int ManhattanDist(Point3 other) => Abs(X - other.X) + Abs(Y - other.Y) + Abs(Z - other.Z);
#ip 1
ip0 jmp ip17 // addi 1 16 1
ip1 r[5] = 1 // seti 1 1 5
ip2 r[2] = 1 // seti 1 4 2
ip3 r[3] = r[5] * r[2] // mulr 5 2 3
ip4 r[3] = r[3] == r[4] // eqrr 3 4 3
ip5 r[1] += r[3] // addr 3 1 1
ip6 jmp ip8 // addi 1 1 1
ip7 r[0] += r[5] // addr 5 0 0
ip8 r[2] += 1 // addi 2 1 2
@tomtheisen
tomtheisen / day15
Last active December 20, 2018 17:26
AOC2018 Day15
const bool ShowSteps = false;
static readonly string[] Input = @"
################################
#########...####################
#########...###########.########
#########G..##########....######
##########..###########...######
#########G...##########...######
#########..G.###########..######
########...#.##########..#######
List<List<string>> ReadCsv(string fileName) {
using var reader = new StreamReader(File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
return ReadCsv(reader);
}
List<List<string>> ReadCsv(TextReader reader) {
var result = new List<List<string>>();
var currentRow = new List<string>();
var currentCell = new StringBuilder();
int c;
@tomtheisen
tomtheisen / unpack.stax
Created February 15, 2018 05:46
Stax program to unpack a packed stax program
convert packed stax program to ascii
build stax encoding table
248 9786 9787 9829 9830 9827 9824 8226 9688 9675 9689 9794 9792 9834 9835 9788 9658 9668 8597 8252 182 167 9644 8616 8593 8595 8594 8592 8735 8596 9650 9660
32l {i\m
8962 199 252 233 226 228 224 229 231 234 235 232 239 238 236 196 197 201 230 198 244 246 242 251 249 255 214 220 162 163 165 8359 402 225 237 243 250 241 209 170 186 191 8976 172 189 188 161 171 187 9617 9618 9619 9474 9508 9569 9570 9558 9557 9571 9553 9559 9565 9564 9563 9488 9492 9524 9516 9500 9472 9532 9566 9567 9562 9556 9577 9574 9568 9552 9580 9575 9576 9572 9573 9561 9560 9554 9555 9579 9578 9496 9484 9608 9604 9612 9616 9600 945 223 915 960 931 963 181 964 934 920 937 948 8734 966 949 8745 8801 177 8805 8804 8992 8993 247 8776 176 8729 183 8730 8319 178 9632 916
129l {i127+\m
+:f|t use tables to stax-encode character codepoints
If you already have stax-encoded bytes, start here.
lines
#["This is some very long text.","25"]
extract-array
#"This is some very long text."
#"25"
read-num
#"This is some very long text."
#25
print("hello world")
@tomtheisen
tomtheisen / expression.cs
Last active August 29, 2015 14:05
Expression Parser
void Main() {
EnsureFailure(
"",
"#",
"1 + 2 +",
"+",
"(+)1",
"()",
"1 ()",
"1 2"