Here are some of my stax solutions for Advent of Code 2019. Input goes verbatim in the input box.
Part 1
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; |
const bool ShowSteps = false; | |
static readonly string[] Input = @" | |
################################ | |
#########...#################### | |
#########...###########.######## | |
#########G..##########....###### | |
##########..###########...###### | |
#########G...##########...###### | |
#########..G.###########..###### | |
########...#.##########..####### |
#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 |
<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); |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Vendor Convert</title> | |
<meta charset=utf-8> | |
<style> | |
body { | |
font-size: 200%; | |
font-family: sans-serif; | |
color: firebrick; |
let a = 3n; |
Ld_X store input in X | |
c"Initial size: `%"P | |
{ | |
xx2B | |
xVp:SY{{Vpxaz:r-f}M keep only substrings that leave an unused ascii char after their removal | |
|=h#~ | |
%RD{d find the length of the longest substring that occurs the most times | |
xx_B | |
y{{Vpxaz:r-f}M keep only substrings that leave an unused ascii char after their removal | |
|=h# |
declare var $: any; | |
function select2EventDispatch(el: HTMLElement, events: string[]) { | |
let dispatching = false; | |
$.fn.select2 && $.fn.select2.amd.require( | |
["select2/utils"], function (Utils: any) { | |
const instance = Utils.GetData(el, "select2"); | |
instance && events.forEach(ev => { | |
instance.on(ev, () => { | |
if (dispatching) return; else dispatching = true; |
using static System.Double; | |
using static System.Math; | |
using static System.Numerics.BigInteger; | |
using System.Numerics; | |
public static class DoubleConvert { | |
public static string Precisely(this double a) { | |
if (IsInfinity(a) || IsNaN(a)) return a.ToString(); | |
if (a == 0) return 1 / a < 0 ? "-0.0" : "0.0"; | |
BigInteger n = 0, d = 1, p = 1; |
Here are some of my stax solutions for Advent of Code 2019. Input goes verbatim in the input box.
Part 1