View js-parseint.py
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
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
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
import { Puzzle } from './index'; | |
type Predicate<T> = (value: T) => boolean; | |
interface Passport { | |
byr: string | |
iyr: string | |
eyr: string | |
hgt: string | |
hcl: string |
View build.gradle
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
plugins { | |
id 'java-library' | |
} | |
repositories { | |
jcenter() | |
maven { | |
name = "SpongeMaven" | |
url = "https://repo.spongepowered.org/maven" | |
} |
View GameMode.java
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
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
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
import enum | |
from typing import Dict, Tuple | |
import aoc | |
import bytecode | |
def main(): | |
instrs = load_instructions() | |
w = World(instrs) |
View day8.py
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
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
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 python | |
import importlib | |
import sys | |
def open_input(name): | |
return open(f"input/{name}.txt") | |
def main(): |
View day6.py
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
from collections import defaultdict | |
from typing import NamedTuple, List | |
import aoc | |
class Orbit(NamedTuple): | |
origin: str | |
name: str |
View day5.py
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
from typing import List | |
import aoc | |
P_MODE_POSITION = 0 | |
P_MODE_IMMEDIATE = 1 | |
class Opcodes(dict): | |
def __call__(self, code): |
View day4.py
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
import re | |
def NewType(name, base=object): | |
class _NewType(base): | |
pass | |
_NewType.__name__ = name | |
return _NewType |
NewerOlder