Skip to content

Commit 7bfe82d

Browse files
committed
Prepare year 2024
1 parent 138043b commit 7bfe82d

39 files changed

+34
-1972
lines changed

README.md

+6-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
# Advent of Code 2023 in Dart
1+
# Advent of Code 2024 in Dart
22

3-
This is my attempt at solving the [Advent of Code 2022](https://adventofcode.com/2023) puzzles in the shortest possible code using [Dart](https://dart.dev/) `3.0`.
3+
This is my attempt at solving the [Advent of Code 2024](https://adventofcode.com/2024) using [Dart](https://dart.dev/) `3.5`.
44

55
You can find the solution in `/bin`.
66

7-
Restrictions this year:
8-
- No external dependencies (except for [`package:collection`](https://pub.dev/packages/collection))
9-
- Never use `class`, force learning functional style with Records
10-
117
## Recent years
128

139
Checkout my solutions of previous years:
14-
- 2022 Dart - code golf https://github.com/passsy/aoc22_dart_code_golf
10+
- 2023 Dart https://github.com/passsy/aoc23_dart
11+
- 2022 Dart https://github.com/passsy/aoc22_dart_code_golf
1512
- 2019 Dart https://github.com/passsy/dart-aoc19
1613
- 2018 Dart https://github.com/passsy/dart-aoc18
1714
- 2017 Kotlin https://github.com/passsy/kotlin-advent-of-code/tree/master/2017
1815
- 2016 Kotlin https://github.com/passsy/kotlin-advent-of-code/tree/master/2016
1916
- 2015 Kotlin https://github.com/passsy/kotlin-advent-of-code/tree/master/2015
2017

2118
## License
19+
2220
```
23-
Copyright 2022 Pascal Welsch
21+
Copyright 2024 Pascal Welsch
2422
2523
Licensed under the Apache License, Version 2.0 (the "License");
2624
you may not use this file except in compliance with the License.
@@ -33,6 +31,5 @@ distributed under the License is distributed on an "AS IS" BASIS,
3331
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3432
See the License for the specific language governing permissions and
3533
limitations under the License.
36-
3734
```
3835

aoc23_sidekick/bin/main.dart

-5
This file was deleted.

aoc23 renamed to aoc24

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ export SIDEKICK_ENTRYPOINT_FILE="${PRG}"
2020
export SIDEKICK_ENTRYPOINT_HOME="$(pwd -P)"
2121
cd "$SAVED" >/dev/null
2222

23-
"${SIDEKICK_ENTRYPOINT_HOME}/aoc23_sidekick/tool/run.sh" "$@"
23+
"${SIDEKICK_ENTRYPOINT_HOME}/aoc24_sidekick/tool/run.sh" "$@"

aoc23_sidekick/.gitignore renamed to aoc24_sidekick/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ build/
77

88
# Directory created by dartdoc
99
doc/api/
10+
# Lock dependencies for deterministic builds on all systems
11+
!pubspec.lock

aoc24_sidekick/bin/main.dart

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'package:aoc24_sidekick/aoc24_sidekick.dart';
2+
3+
Future<void> main(List<String> arguments) async {
4+
await runAoc24(arguments);
5+
}

aoc23_sidekick/lib/aoc23_sidekick.dart renamed to aoc24_sidekick/lib/aoc24_sidekick.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import 'dart:async';
22

3-
import 'package:aoc23_sidekick/src/commands/clean_command.dart';
4-
import 'package:aoc23_sidekick/src/commands/new_day_command.dart';
3+
import 'package:aoc24_sidekick/src/commands/clean_command.dart';
4+
import 'package:aoc24_sidekick/src/commands/new_day_command.dart';
55
import 'package:sidekick_core/sidekick_core.dart';
66

7-
Future<void> runAoc23(List<String> args) async {
7+
Future<void> runAoc24(List<String> args) async {
88
final runner = initializeSidekick(
99
dartSdkPath: systemDartSdkPath(),
1010
);

aoc23_sidekick/pubspec.lock renamed to aoc24_sidekick/pubspec.lock

+3-3
Original file line numberDiff line numberDiff line change
@@ -525,10 +525,10 @@ packages:
525525
dependency: "direct main"
526526
description:
527527
name: sidekick_core
528-
sha256: "323611a8527b7094ffc4691d6a288de1d187dd017e18e62db7a6165fcc36db77"
528+
sha256: "3b08ee513dbcd7b97b2813ab24aee0e8f37d77b7548d4e72332420e67ab252dc"
529529
url: "https://pub.dev"
530530
source: hosted
531-
version: "2.1.0"
531+
version: "2.1.3"
532532
source_map_stack_trace:
533533
dependency: transitive
534534
description:
@@ -714,4 +714,4 @@ packages:
714714
source: hosted
715715
version: "2.1.1"
716716
sdks:
717-
dart: ">=3.0.7 <3.999.0"
717+
dart: ">=3.2.6 <3.999.0"
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
name: aoc23_sidekick
2-
description: Sidekick CLI for aoc23
1+
name: aoc24_sidekick
2+
description: Sidekick CLI for aoc24
33
version: 0.0.1
44
publish_to: none
55

66
environment:
7-
sdk: ">=3.0.7 <4.0.0"
7+
sdk: ">=3.2.6 <4.0.0"
88

99
executables:
1010
main:
1111

1212
dependencies:
13-
sidekick_core: ^2.1.0
13+
sidekick_core: ^2.1.3
1414

1515
dev_dependencies:
1616
lint: ^2.0.0
1717

1818
# generated code, do not edit this manually
1919
sidekick:
20-
cli_version: 2.1.0
20+
cli_version: 2.1.3

aoc23_sidekick/tool/install.sh renamed to aoc24_sidekick/tool/install.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ runSilent() {
2626
}
2727

2828
cd "${CLI_PACKAGE_DIR}" || exit
29-
echoerr "Installing aoc23 command line application..."
29+
echoerr "Installing aoc24 command line application..."
3030

3131
# Find dart executable from embedded dart sdk
3232
DART_SDK="${CLI_PACKAGE_DIR}/build/cache/dart-sdk"
File renamed without changes.

bin/day01_part1.dart

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
11
void main(List<String> args) {
2-
int sum = 0;
3-
for (final line in args) {
4-
final split = line.split(RegExp(r'\D+')).where((e) => !e.isEmpty).toList();
5-
sum += int.parse(split[0]) * 10 + int.parse(split.last);
6-
}
7-
print(sum);
2+
print(0);
83
}

bin/day01_part1.dart.golf

-1
This file was deleted.

bin/day01_part2.dart

+1-32
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,3 @@
11
void main(List<String> args) {
2-
int sum = 0;
3-
for (final line in args) {
4-
sum += getFirstInt(line, 1, 0) * 10 + getFirstInt(line, 0, 1);
5-
}
6-
print(sum);
7-
}
8-
9-
final words = {
10-
'one': 1,
11-
'two': 2,
12-
'three': 3,
13-
'four': 4,
14-
'five': 5,
15-
'six': 6,
16-
'seven': 7,
17-
'eight': 8,
18-
'nine': 9
19-
};
20-
21-
int getFirstInt(String line, int startMulti, int endMulti) {
22-
for (int index = 0; index < line.length; index++) {
23-
final start = index * startMulti + (line.length - index - 1) * endMulti;
24-
final sub = line.substring(start, line.length);
25-
for (final e in words.entries) {
26-
final n = int.tryParse(sub[0]);
27-
if (n != null) return n;
28-
if (sub.startsWith(e.key)) {
29-
return e.value;
30-
}
31-
}
32-
}
33-
throw 'No number found in $line';
2+
print(0);
343
}

bin/day01_part2.dart.golf

-2
This file was deleted.

bin/day02_part1.dart

-30
This file was deleted.

bin/day02_part2.dart

-32
This file was deleted.

bin/day03_part1.dart

-76
This file was deleted.

0 commit comments

Comments
 (0)