-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
91c113c
commit 9ba140c
Showing
5 changed files
with
68 additions
and
29 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
import 'package:aoc_2024/lib.dart'; | ||
import 'package:aoc_2024/day7/part_1.dart' as part1; | ||
import 'package:aoc_2024/day7/part_2.dart' as part2; | ||
|
||
Future<void> main(List<String> arguments) async { | ||
await runDay( | ||
day: 7, | ||
part1: part1.calculate, | ||
part2: (r) => Future.value(0), | ||
part2: part2.calculate, | ||
); | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:aoc_2024/lib.dart'; | ||
|
||
import 'shared.dart'; | ||
|
||
Future<int> calculate(Resources resources) async { | ||
final equations = await loadData(resources); | ||
|
||
final result = equations | ||
.where((e) => _canEquationBeTrue(e)) | ||
.fold(0, (v, e) => v + e.result); | ||
return result; | ||
} | ||
|
||
bool _canEquationBeTrue(final AmbiguousEquation equation) => | ||
equation.potentialEquations([ | ||
Add(), | ||
Multiply(), | ||
Concatenation(), | ||
]).any((e) => e.isValid()); |
This file contains 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
This file contains 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