Search
aoc_2023_12_sat
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
const INPUT = `
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
.trim()
.split("\n");
const PROGRAM = `
![easrng avatar](https://images.clerk.dev/oauth_github/img_2Qn86tpR8Fwsj1TjoMg9t1DCmc2.png)
rssViewer
@easrng
rss viewer
a basic RSS reader
Express
return { error: e.stack, url };
return html`
<link rel="icon" href="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAAGNbWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAsaWxvYwAAAABEAAACAAEAAAABAAAEPQAABEkAAgAAAAEAAAG1AAACiAAAAEJpaW5mAAAAAAACAAAAGmluZmUCAAAAAAEAAGF2MDFDb2xvcgAAAAAaaW5mZQIAAAAAAgAAYXYwMUFscGhhAAAAABppcmVmAAAAAAAAAA5hdXhsAAIAAQABAAAAw2lwcnAAAACdaXBjbwAAABRpc3BlAAAAAAAAAMAAAADAAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAOcGl4aQAAAAABCAAAAAxhdjFDgQAcAAAAADhhdXhDAAAAAHVybjptcGVnOm1wZWdCOmNpY3A6c3lzdGVtczphdXhpbGlhcnk6YWxwaGEAAAAAHmlwbWEAAAAAAAAAAgABBAECgwQAAgQBBYYHAAAG2W1kYXQSAAoGGB3v79lUMvsEEhASOFUA6njX3QqtD7K7N40kkq8eGPZ/PT0Cs+0Q+Qo1r9B+R30YG5zsiJ/qOwb0mk7r273nrjKnEOy7uhph6IyJLdtI+grHpGHGon9w838zglZz4T3sZSNQxPBP+ifvEzI1Nb1/gAbGjCL0+fsHJtqPPzGjZYX2uy3TujIHU8e0wJ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/JnNIc8hZXW1QywHkzgTLqrOosCU+EJEvftvQ2oXfs46OyrGHexIblTdgEFCWHt39TnIVAvkfqLIUW1G4tWzS0Fw/lr9DURI24E5ONHQbJrtaEMVT5Gz+QeogYi3m5ZfRPrZZPN/+5PIJ0RIGT95ku/5ZvgBGr76wBuubGfd0zw2aFfE0cIetLpNBp8rDFzYYWp0FQJXpcCzn4bC/mz903YqmZCBe9LCXfNI1D66OHlTgmTzU5XI1WWtimO/UBulu5NNygNu8ZeWX2rJrsAw7Gu2K3DYoP73bFHh3taI+Vvb8VkMHi21c8hW8o1LyiMDNROBQY6NsNXSBXXn4Seu/50JFtcqWexnrzNmteA1DWpS5c6S5FGYCMRsqN2wlUDBPSlNcIpqQH1TBWKhDSpDTwhjOoRqTo7ELxzMAabsJGTIZXA8WGICPzSIcawRaFF6A5VMGqVNuke4x+syahi9huFTeePggRo1PWCd+gyK/ZLU+JX3Podd83h8r5alCSrWcWvYpXjfHWEJDhIR21nYMur1N0CiAjC/nnUtu9Ej41SleRpfQD+r/1HtzLLAgRnu+3tapB+WhV82umcujCBErq0EuwNYt5wdfsSALj5pT/6rpyBRS2dJF2adY/54SU0cePlzBLMepeS4ZnK5n4GugaNl/IJVeNnlwahuL3N97fckxHop/yy7Nb5Vabx7JvruQAygYgmKrhmM2fyq3eypUzkz4EOXMvctgQJHSAvIJbejEDBGrQkLiT1iiAztUVeeafGFDTBG18V7jzYj5WCPLJIoG1diZgBJjRgQEWkvtlMCyln2ezoit46wL1mFxU6CkareGbBe0jNIFoBc2ipUJl3paD/axiMLihxdRbIFkYA3El1UzIgK4M3pz4YgveGjF5I3cVSgcnNZdxLBqv/Fg6efaYN5mB6z3TKR359giRN8NY0GQBuJ0B3OGH1bcqbzeLbD5j7tDDkztdKcOJLF5oyxEBd9h70sJCfeKf/4NdXNiPWIF9KWe0TiDGVHGC0190r2Y5/DulW0T24e1/yevDM8qfInujNd7bHsqrQ=="/>
<title>rss viewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
aoc_2023_13
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
.map((grid) => grid.split("\n").map((line) => line.split("")));
const PROGRAM = `
# AOC Day 13 Solution
#builtin NAT_SUCC s
#builtin INT_MINUS minus
activitypub
@tmcw
WebFinger This is a not-quite-complete ActivityPub implementation based on my blog post about building an AP implementation . It includes enough to look up bot@tmcw-activitypub.web.val.run on Mastodon and get some basic information.
HTTP
href: `https://${DOMAIN}/u/bot`,
const publicKey = `-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7LBs3Qyuh93lRboTNXLN
hj4n92oK5Qg4oS8Cc81AXh04hD7nQSSKBhtarbHy2yPXeiKA+H3EGbcflsLvZCo2
B3OPNo2nGTCMyJM8HWDf/7JCOHHcy4tZC1ldjrItkb1YDABWwfoXxyBiGTyTVXjL
aoc_2023_12_dynamic
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
const INPUT = `
???.### 1,1,3
.??..??...?##. 1,1,3
?#?#?#?#?#?#?#? 1,3,1,6
????.#...#... 4,1,1
????.######..#####. 1,6,5
?###???????? 3,2,1
.trim()
.split("\n");
const PROGRAM = `
aoc_2023_9
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
values,
const dusa = new Dusa(`
# AOC Day 9
#builtin INT_MINUS minus
#builtin INT_PLUS plus
aoc_2023_14_feasible
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
.map((line) => line.split(""));
const PROGRAM = `
# AOC Day 14, Part 2 - Take 1
#builtin INT_MINUS minus
#builtin NAT_SUCC s
![ehodges avatar](https://images.clerk.dev/oauth_github/img_2OWXt8DwQxHkHzDt7MVCL12ERgz.jpeg)
getMcgillEvents
@ehodges
An interactive, runnable TypeScript val by ehodges
Script
export async function getMcgillEvents() {
const url =
"https://www.alumni.mcgill.ca/aoc/events-travel/registration/regwizEventsList.php?location=050%3AMA&school=&dateMonth=&title=&doSearch=1";
const items = await newRSSItems({
url: url,
aocXX_00
@karfau
This is a great template if you want to solve the https://adventofcode.com puzzles in a TDD style: dump your puzzle input into the input function copy/paste sample input and output from the page once all assertions pass, the solution is calculated There is one function for each star that can be achieved. Some helpers for common tasks are defined at the end of code: debug , toInt , exctractNumbers , sum , ... ? PS: Did you know advent of code goes as far back as 2015 and you can still solve those puzzles?
Script
This is a great template if you want to solve the <https://adventofcode.com> puzzles in a TDD style:
1. dump your puzzle input into the `input` function
2. copy/paste sample input and output from the page
3. once all assertions pass, the solution is calculated
There is one function for each star that can be achieved.
Some helpers for common tasks are defined at the end of code: `debug`, `toInt`, `exctractNumbers`, `sum`, ... ?
expect(firstStar(`sample input`), "*1 sample 1").to.equal("expected output");
// expect(firstStar(``), "*1 sample 2").to.equal("?");
function firstStar(input: string) {
return "expected output"; // implement :)
aoc23_06
@karfau
https://adventofcode.com/2023/day/6
Script
https://adventofcode.com/2023/day/6
expect(
firstStar(`Time: 7 15 30
Distance: 9 40 200`),
"*1 sample 1",
).to.equal(288);
// expect(firstStar(``), "*1 sample 2").to.equal("?");
function firstStar(input: string) {
const [times, distances] = input.split("\n").map(extractNumbers);
const winnings: number[] = times.map((time, i) => {
aoc_2023_14_infeasible
@robsimmons
An interactive, runnable TypeScript val by robsimmons
Script
.map((line) => line.split(""));
const dusa = new Dusa(`
# AOC Day 14, Part 2 - Take 1
#builtin INT_MINUS minus
#builtin NAT_SUCC s
aoc15_06
@karfau
https://adventofcode.com/2015/day/6
Script
https://adventofcode.com/2015/day/6
// expect(firstStar(`turn on 0,0 through 999,999`), "*1 sample 1").to.equal(1_000_000);
// expect(firstStar(`toggle 0,0 through 999,0`), "*1 sample 2").to.equal(1_000);
// expect(firstStar(`turn off 499,499 through 500,500`), "*1 sample 3").to.equal(0);
// expect(firstStar(``), "*1 sample 2").to.equal("?");
function firstStar(input: string) {
return "expected output"; // implement :)
// as as soon as the assertions pass, the solution is calculated
console.log("solution *1:", firstStar(input()));
expect(secondStar(``), "*2 sample 1").to.equal("?");
aoc23_07
@karfau
https://adventofcode.com/2023/day/7
Script
https://adventofcode.com/2023/day/7
let verbose = true;
const CARDS = "23456789TJQKA";
const CARDSJ = "J23456789TQKA";
const ORDERC = "ABCDEFGHIJKLM";
const FIVE_OAK = 6;
const FOUR_OAK = 5;
const FULL_HOUSE = 4;
const THREE_OAK = 3;
const TWO_PAIRS = 2;
aoc23_05
@karfau
https://adventofcode.com/2023/day/5 Oh boy, what a tedious one.
I don't see any quick and easy optimization strategies here.
the parsing is the most tedious part of this. The first part went way more smoothly than I initially thought, by splitting the different steps into smaller pieces. But the second part is a hard nut to crack.
So many runtime/performance issues because the numbers are so "big" that my intail approach no longer works. Last nut I finally cracked was in v28 by running the following on a powerful desktop machine for nearly an hour:
deno run https://esm.town/v/karfau/aoc23_05?v=28 (that is the module URL)
to get the correct solution.
Script
Last nut I finally cracked was in v28 by running the following on a powerful desktop machine for nearly an hour:
`deno run https://esm.town/v/karfau/aoc23_05?v=28` (that is the module URL)
to get the correct solution.