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
| """Ask clang what a struct looks like | |
| Structs like stat don't necessarily have the same fields in the same order on | |
| different platforms. This makes writing a language with C FFI sound pretty | |
| awful... since all the different platforms would need to be handled by the FFI | |
| library of that language. Maybe with something like this, the C compiler could | |
| be queried to find out what these structs look like? | |
| """ | |
| import io |
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 std::collections::BTreeSet; | |
| type Point = [i64; 3]; | |
| type Rotation = [u8; 3]; | |
| #[derive(Debug)] | |
| struct Orientation { | |
| signs: [i8; 3], | |
| rotation: Rotation, | |
| } |
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: |