Skip to content

Commit 1e654aa

Browse files
committed
Stub out day 22 in Dart
1 parent 2addfcb commit 1e654aa

File tree

9 files changed

+97
-1
lines changed

9 files changed

+97
-1
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ My solutions to the [Advent of Code 2024](https://adventofcode.com/2024), writte
2727
- [x] [**Day 19**](day19): [PyGyat](day19/src/day19.gyat)
2828
- [x] [**Day 20**](day20): [Rust](day20/src/day20.rs)
2929
- [x] [**Day 21**](day21): [Scala](day21/src/day21.scala)
30+
- [ ] [**Day 22**](day22): [Dart](day22/src/day22.dart)
3031

3132
## Development
3233

day22/derivation.nix

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{ stdenv, dart }:
2+
stdenv.mkDerivation {
3+
name = "advent-of-code-2024-day22";
4+
src = ./src;
5+
6+
nativeBuildInputs = [
7+
dart
8+
];
9+
10+
buildPhase = ''
11+
mkdir -p {tmpbin,out}
12+
13+
# Ad-hoc signing is required on arm64 macOS, this fixes it (not sure why
14+
# the dart derivation doesn't provide it)
15+
${if stdenv.isDarwin then ''
16+
ln -s /usr/bin/codesign tmpbin/codesign
17+
'' else ""}
18+
19+
PATH="./tmpbin:$PATH" dart compile exe day22.dart -o out/day22
20+
'';
21+
22+
installPhase = ''
23+
mkdir -p $out/bin
24+
cp out/day22 $out/bin
25+
'';
26+
}

day22/flake.lock

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

day22/flake.nix

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
description = "Advent of Code 2024 - Day 22 solution";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }:
9+
let
10+
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
11+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
12+
in {
13+
packages = forAllSystems (system:
14+
let
15+
pkgs = import nixpkgs { inherit system; };
16+
in {
17+
default = pkgs.callPackage ./derivation.nix {};
18+
}
19+
);
20+
21+
apps = forAllSystems (system: {
22+
default = {
23+
type = "app";
24+
program = "${self.packages.${system}.default}/bin/day22";
25+
};
26+
});
27+
};
28+
}

day22/resources/demo.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abc

day22/resources/input.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
abc

day22/src/day22.dart

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import 'dart:io';
2+
3+
Future<void> main(List<String> args) async {
4+
final input = await File(args[0]).readAsString();
5+
print("Input: $input");
6+
}

paths.json

+7
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,12 @@
167167
},
168168
"path": "day21/src/day21.scala",
169169
"completed": true
170+
},
171+
{
172+
"lang": {
173+
"codemirror": "dart",
174+
"name": "Dart"
175+
},
176+
"path": "day22/src/day22.dart"
170177
}
171178
]

planned-languages.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
Swift
2-
Dart
32
Ruby
43
Crystal
54
Go

0 commit comments

Comments
 (0)