Skip to content

Commit

Permalink
Day06: Set => HashSet
Browse files Browse the repository at this point in the history
Provides a good speed boost on my machine.
  • Loading branch information
julemand101 committed Dec 7, 2024
1 parent 3bb5893 commit a5416c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/day06.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// --- Day 6: Guard Gallivant ---
// https://adventofcode.com/2024/day/6

import 'dart:collection';
import 'dart:io';
import 'dart:isolate';
import 'dart:typed_data';
Expand Down Expand Up @@ -43,7 +44,7 @@ Future<int> solveB(List<String> input) async {

// Point and direction set.
// If we detect the same combo, we are in a loop
final loopDetect = <(Point, int)>{};
final loopDetect = HashSet<(Point, int)>();
var guardPosition = grid.guardStartingPoint;
var direction = 0;

Expand Down Expand Up @@ -82,7 +83,7 @@ Future<int> solveB(List<String> input) async {
List<String> input,
) {
final grid = Grid(input.first.length, input.length)..setFromInput(input);
final distinctPositions = <Point>{};
final distinctPositions = HashSet<Point>();

var guardPosition = grid.guardStartingPoint;
var direction = 0;
Expand Down

0 comments on commit a5416c6

Please sign in to comment.