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
// AOC 2023, Day 2: Cube Conundrum | |
// Each lines holds a number of draws of coloured cubes from a bag. | |
// 1) Given some limits, how many lines contain valid draws. | |
// 2) Determine the minimum cubes needed for each line. | |
// https://dartpad.dev/?id=203b3f0a9a1ad7a51daf14a1aeb6cf67 | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; | |
MapEntry<int, List<Map<String, int>>> parseLine(String s) { |
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
// AOC 2022, Day 25: Full of Hot Air | |
// Convert numbers to "balanced base"(q.v.) 5 and back | |
// https://dartpad.dev/?id=004680836fce05e69a8be7e05b68cf3c | |
import 'package:collection/collection.dart'; | |
var si = {'2': 2, '1': 1, '0': 0, '-': -1, '=': -2}; | |
var i2s = ['0', '1', '2', '=', '-']; | |
int sToI(String n) => n.split('').fold(0, (int s, String t) => s * 5 + si[t]!); | |
String iToS(int i) => [ |
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
// AOC 2022, Day 24: Blizzard Basin | |
// Move round a map avoiding blizzards | |
// 1) once | |
// 2) there and back and there again | |
// https://dartpad.dev/?id=0673f9bfd8af2158050f0e55ba75451b | |
import 'dart:collection'; | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; |
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
// AOC 2022, Day 23: Unstable Diffusion | |
// Move some elves around according to odd rules | |
// 1) See how much they spread out after 10 moves. | |
// 2) How long does it take for them to all get stuck? | |
// https://dartpad.dev/?id=5c5cc4b78c1b541159db97f34a5b389a | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; |
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
// AOC 2022, Day 22: Monkey Map | |
// Navigate your way around a grid. | |
// 1) Following instructions. | |
// 2) But first, wrap it round a cube. | |
// https://dartpad.dev/?id=12713657a02660c09fe3c9e548e7d7e9 | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; | |
extension MathNumberExtension on num { |
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
// AOC 2022, Day 21: Monkey Math | |
// Build a tree | |
// 1) And visit it. | |
// 2) And fix the answer. | |
// https://dartpad.dev/?id=95d1e587ec0cf63b4cfe987e8a582fbf | |
final ops = { | |
'+': (num a, num b) => a + b, | |
'-': (num a, num b) => a - b, | |
'*': (num a, num b) => a * b, |
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
// AOC 2022, Day 20: Grove Positioning System | |
// Mix a list according to some rules | |
// 1) Once. | |
// 2) Ten times with a key. | |
// https://dartpad.dev/?id=2ae60c3e3a6ae2edf57a5eff9c298d8d | |
import 'package:collection/collection.dart'; | |
extension IntegerRangeExtension on int { | |
List<int> to(int end, {int step = 1}) => |
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
// AOC 2022, Day 19: Not Enough Minerals | |
// Produce some machines that produce resources in a horrible network :-) | |
// 1) Find best results for a long list. | |
// 2) Now for a short list over a longer time. | |
// https://dartpad.dev/?id=741c3d8304eb54a167e065c0702eb38f | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; |
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
// AOC 2022, Day 18: Boiling Boulders | |
// Find the surface area of a cluster of cubes | |
// 1) as given | |
// 2) excluding interior voids | |
// https://dartpad.dev/?id=d7d31d6b8c9cd1c2b2fb1f4eb272e729 | |
import 'package:collection/collection.dart'; | |
extension IntegerRangeExtension on int { | |
List<int> to(int end, {int step = 1}) => |
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
// AOC 2022, Day 17: Pyroclastic Flow | |
// Drop simple tetris pieces that get moved sideways by jets of air. | |
// Both cycle forever. Measure the height of the resulting stack. | |
// 1) after 2022 pieces. | |
// 2) after 1000000000000 pieces. | |
// https://dartpad.dev/?id=7be747054a44186eab0f39911a889b96 | |
import 'dart:math'; | |
import 'package:collection/collection.dart'; |
NewerOlder