This file contains hidden or 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 main | |
import ( | |
"math" | |
"strings" | |
) | |
const data = ` | |
` |
This file contains hidden or 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
diff --git a/12.py b/12.py | |
index 8cb48a8..e6097ae 100644 | |
--- a/12.py | |
+++ b/12.py | |
@@ -8,39 +8,39 @@ for line in data.splitlines(): | |
G.add_edge(a, b) | |
-def find_paths(G, so_far, visited, from_="start"): | |
+def find_paths(G, so_far, from_="start"): |
This file contains hidden or 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 aoc import * | |
# This function caches very well | |
@cache | |
def fuel_cost(diff): | |
return sum(range(diff + 1)) | |
data = list(map(int, data.split(","))) |
This file contains hidden or 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
type Quantity = symbol; | |
const Length: unique symbol = Symbol("Length quantity"); | |
interface Unit<Q extends Quantity> { | |
quantity: Q; | |
factor: number; | |
} | |
export const Millimeter: Unit<typeof Length> = { |
This file contains hidden or 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
ε = object() | |
# NFA for a*ab; | |
# | |
# ε a b | |
# ->(0)--->(1)--->(2)--->((3)) | |
# ^ \ | |
# |__| | |
# a | |
# |
This file contains hidden or 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
Benchmark brainf*ck program | |
>++[<+++++++++++++>-]<[[>+>+<<-]>[<+>-]++++++++ | |
[>++++++++<-]>.[-]<<>++++++++++[>++++++++++[>++ | |
++++++++[>++++++++++[>++++++++++[>++++++++++[>+ | |
+++++++++[-]<-]<-]<-]<-]<-]<-]<-]++++++++++. | |
This file contains hidden or 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
# Types and type constructors | |
# flake8: noqa | |
from __future__ import annotations | |
class TypeConstructor: | |
def __init__( | |
self, parameters: list[TypeParameter], super_: Instance | BottomType | |
) -> None: |
This file contains hidden or 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 abc | |
import typing as t | |
class TypeError(Exception): | |
pass | |
class TypeParam: | |
def __init__(self, name: str, var: "TypeVar") -> None: |
This file contains hidden or 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
use indexmap::{IndexMap, IndexSet}; | |
use slotmap::SlotMap; | |
use smol_str::SmolStr; | |
use std::collections::HashMap; | |
use std::rc::Rc; | |
use tinyvec::TinyVec; | |
fn main() { | |
let mut consts = ConstMap::with_key(); | |
let mut map = IndexMap::new(); |
This file contains hidden or 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 itertools import count | |
from lib.input import fetch | |
def main(): | |
class node: | |
__slots__ = "label", "next" | |
def __init__(self, label): | |
self.label = label |