Skip to content

Instantly share code, notes, and snippets.

static class Day9
{
public static void Run()
{
var lines = Input.Split('\n', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
long total = 0;
foreach (var line in lines)
{
// for part 2 just reverse this array
@snluu
snluu / coins.cpp
Last active November 22, 2023 15:30
coins
// Input `n`: number of coin_types
// Input `X`: the wanted sum
int coin_types = { ... };
const int32_t TRASH = 2 << 24; // guaranteed greater than X
std::vector<int32_t> coin_count(TRASH, X);
for (int x = 1; x <= X; x++) {
for (int c = 0; c < n; c++) {
require "common"
require "./types"
require "./serializer"
require "./annotations"
macro rpc_object(name, &block)
class {{name}}
extend TxtRPC::Object
extend BuilderPattern
@snluu
snluu / lenote.js
Last active March 28, 2020 17:11
Main lenote JavaScript file
import init, { run_app } from '/ui/lenote_ui.js';
async function main() {
await init('/ui/lenote_ui_bg.wasm');
run_app();
}
main()
@snluu
snluu / autorebuild.sh
Last active March 28, 2020 16:53
Using fswatch to automatically rebuild changes
# Start the server:
cd lenote-server; fswatch src -vro | (while read; do clear; \
date; \
pkill lenote-server; \
sleep 2; \
(RUST_LOG="warn,lenote_server=info" cargo run -- --ui ../target/pkg/debug/ --pages ../pages --data ~/lenote-data &); \
done)
# On a different terminal, start file-watcher to compiler the UI on changes:
cd lenote-ui; fswatch src -vro | (while read; do clear; \
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
@snluu
snluu / x.csproj
Created February 11, 2020 04:10
The magical csproj file that won't work
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<Reference Include="http://Microsoft.NET.Sdk.Web">
<HintPath>$SDK_ROOT/Microsoft.NET.Sdk.Web.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
"use strict";
class Test_Location {
get name() {
return this._name;
}
set name(val) {
if (val === null || val === undefined) {
throw "Cannot set null or undefined value for 'name'";
def fib(i : Int32, ch : Channel(Int32) | Nil)
if i < 2
return i if ch.nil?
ch.send(i)
return 0
end
sub_ch = Channel(Int32).new
spawn fib(i - 1, sub_ch)
x = fib(i - 2, nil)
type FileInfo* = object