Skip to content

Commit 4626b91

Browse files
committed
fix hamming calculation
1 parent 93a47e7 commit 4626b91

File tree

1 file changed

+5
-2
lines changed
  • week4/priority-queues/assignment-8-puzzle

1 file changed

+5
-2
lines changed

week4/priority-queues/assignment-8-puzzle/Board.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,11 @@ public int hamming() {
4141
int cnt = 0;
4242
for (int i = 0; i < dimension(); ++i)
4343
for (int j = 0; j < dimension(); ++j) {
44-
if (tiles[i][j] != goalAt(i, j)) {
45-
cnt++;
44+
int v = tiles[i][j];
45+
if (v == 0) continue;
46+
47+
if (v != goalAt(i, j)) {
48+
++cnt;
4649
}
4750
}
4851
return cnt;

0 commit comments

Comments
 (0)