Compare commits

...

2 commits

Author SHA1 Message Date
a2f09799e5
Day 3 2024-12-02 22:15:41 -07:00
492bf51c0d
Add nix flake shell stuff i think 2024-12-02 22:15:41 -07:00
4 changed files with 95 additions and 0 deletions

8
day3/part1.ts Normal file
View file

@ -0,0 +1,8 @@
export async function solve() {
const input = await Deno.readTextFile("./input.txt");
let sum = 0;
for (const match of input.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g)) {
sum += +match[1] * +match[2];
}
return sum
}

10
day3/part2.ts Normal file
View file

@ -0,0 +1,10 @@
export async function solve() {
const input = await Deno.readTextFile("./input.txt");
let sum = 0;
for (const part of input.split("do()").slice(1).map(e => e.split("don't()")[0])) {
for (const match of part.matchAll(/mul\((\d{1,3}),(\d{1,3})\)/g)) {
sum += +match[1] * +match[2];
}
}
return sum
}

61
flake.lock Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1733015953,
"narHash": "sha256-t4BBVpwG9B4hLgc6GUBuj3cjU7lP/PJfpTHuSqE+crk=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ac35b104800bff9028425fec3b6e8a41de2bbfff",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

16
flake.nix Normal file
View file

@ -0,0 +1,16 @@
{
description = "Ty's advent of code 2024 solutions";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; in {
devShells.default = pkgs.mkShellNoCC {
packages = with pkgs; [
deno
kotlin
];
};
});
}