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
| (* how to convert from an ('a -> bot) to 'a cont *) | |
| structure CCC = | |
| struct | |
| structure CC = SMLofNJ.Cont | |
| datatype bot = Bot of bot | |
| fun abort (Bot x) = abort x | |
| type 'a cont = 'a -> bot | |
| (* convert using an exception - unsatisfying *) |
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
| /* | |
| * Implementation of a simulator for the Universal Machine (UM) for the 2006 | |
| * ICFP Programming Contest. | |
| * | |
| * This is an "honest" version that doesn't rely on sticking pointers | |
| * into 32-bit integers. It is maybe a little slower, but not more | |
| * than 10%? My measurements have all been kind of noisy. | |
| * | |
| * If SAFE is defined, then we do bounds checks and the like. | |
| * That's a decent mount more slow. |
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 __future__ import annotations | |
| from dataclasses import dataclass | |
| import json | |
| import time | |
| import textwrap | |
| from typing import Any, Callable | |
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
| #!/usr/bin/env python3 | |
| import edgedb | |
| import sys | |
| EXT = 'ltree' | |
| def main(argv): | |
| db = edgedb.create_client( | |
| port=5656, database='edgedb', tls_security='insecure' |
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 textwrap | |
| from typing import Any | |
| # Escape delimeters for maintaining a nesting structure in strings | |
| # that the user produces. Obviously, as with all schemes for in-band | |
| # signalling, all hell can break loose if the signals appear in the | |
| # input data unescaped. | |
| # | |
| # Our signal sequences contain a null byte and both kinds of quote | |
| # character, so you should be fine as long as any untrusted 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
| """Hacky implementation of "view patterns" with Python match | |
| A "view pattern" is one that does some transformation on the data | |
| being matched before attempting to match it. This can be super useful, | |
| as it allows writing "helper functions" for pattern matching. | |
| We provide a class, ViewPattern, that can be subclassed with custom | |
| `match` methods that performs a transformation on the scructinee, | |
| returning a transformed value or raising NoMatch if a match is not | |
| possible. |
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 operator | |
| OPS = { | |
| x.__doc__.split()[3]: x | |
| for k in dir(operator) | |
| if not k.startswith('__') | |
| and (x := getattr(operator, k)).__doc__.startswith("Same as 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
| with | |
| # I made an object Input with a data property, which made it easier to | |
| # develop this in the CLI. It also works fine to make the input a parameter. | |
| input := (select Input filter .day = 1).data, | |
| # input := <str>$0, | |
| grps := array_unpack(str_split(input[:-1], '\n\n')), | |
| sums := (for grp in grps union ( | |
| with entries := <int64>array_unpack(str_split(grp, '\n')), | |
| select sum(entries) | |
| )), |
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 __future__ import annotations | |
| from dataclasses import dataclass | |
| import json | |
| import time | |
| import textwrap | |
| from typing import Any, Callable | |
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
| #!/usr/bin/env python3 | |
| """Script that tries to scrape all potential test inputs. | |
| By default it writes all of them to files in the directory | |
| <day>.tests. It also prints all of the contents out along | |
| with the file names so that you can quickly inspect and | |
| determine which you want to use. | |
| Depends on advent-of-code-data 1.1.0 (later versions may |
NewerOlder