Skip to content

Commit

Permalink
Corrigir erro ao calcular o tempo decorrido
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagohm committed Aug 21, 2020
1 parent 3b6a976 commit 96ef488
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions lib/src/kociemba_solver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ class KociembaSolver extends Solver {
(search.ax[depthPhaseOne - 1] != search.ax[depthPhaseOne] &&
search.ax[depthPhaseOne - 1] !=
search.ax[depthPhaseOne] + 3)) {
final elapsedTime = sw.elapsedMilliseconds;
final moves = _moves(search, s);
return Solution(moves: moves, elapsedTime: elapsedTime);
return Solution(moves: moves, elapsedTime: sw.elapsed);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/solution.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ class Solution extends Equatable {
final List<Move> moves;

/// Elapsed time to find the [Solution].
final int elapsedTime;
final Duration elapsedTime;

/// Creates a [Solution] instance.
const Solution({
this.moves = const [],
this.elapsedTime = 0,
this.elapsedTime = const Duration(),
});

/// Empty solution.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/solver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract class Solver {
if (maxDepth > 0 && s != null && s.isNotEmpty) {
if (!solutions.contains(s)) {
solutions.add(s);
yield s;
yield Solution(moves: s.moves, elapsedTime: sw.elapsed);
maxDepth = s.length - 1;
} else {
maxDepth--;
Expand Down

0 comments on commit 96ef488

Please sign in to comment.