Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthew Messinger killjoy1221

View GitHub Profile
@killjoy1221
killjoy1221 / js-parseint.py
Created Mar 3, 2022
Python implementation of parseInt, which converts a value to a string, then reads until the first non-number.
View js-parseint.py
ZERO = ord("0")
NINE = ord("9")
def parseInt(s):
result = None
for i in str(s):
ascii_value = ord(i)
if ZERO <= ascii_value <= NINE:
result = result or 0
View 4.ts
import { Puzzle } from './index';
type Predicate<T> = (value: T) => boolean;
interface Passport {
byr: string
iyr: string
eyr: string
hgt: string
hcl: string
@killjoy1221
killjoy1221 / build.gradle
Last active Jul 2, 2020
Run config for spongevanilla
View build.gradle
plugins {
id 'java-library'
}
repositories {
jcenter()
maven {
name = "SpongeMaven"
url = "https://repo.spongepowered.org/maven"
}
View GameMode.java
package splooge.api.world;
import kotlin.jvm.internal.PropertyReference1;
import kotlin.reflect.KDeclarationContainer;
import kotlin.jvm.internal.PropertyReference1Impl;
import kotlin.jvm.internal.Reflection;
import org.jetbrains.annotations.NotNull;
import kotlin.reflect.KProperty;
import splooge.api.EnumProvider;
import kotlin.Metadata;
View day11.py
import enum
from typing import Dict, Tuple
import aoc
import bytecode
def main():
instrs = load_instructions()
w = World(instrs)
View day8.py
from typing import List
import aoc
def read_layers(data: List[int], width: int, height: int):
size = width * height
for layer in range(len(data) // size):
yield Layer(data[size * layer:size * (layer + 1)], width, height)
View aoc.py
#!/usr/bin/env python
import importlib
import sys
def open_input(name):
return open(f"input/{name}.txt")
def main():
View day6.py
from collections import defaultdict
from typing import NamedTuple, List
import aoc
class Orbit(NamedTuple):
origin: str
name: str
View day5.py
from typing import List
import aoc
P_MODE_POSITION = 0
P_MODE_IMMEDIATE = 1
class Opcodes(dict):
def __call__(self, code):
View day4.py
import re
def NewType(name, base=object):
class _NewType(base):
pass
_NewType.__name__ = name
return _NewType