public int manhattan() {
		if (!manhattened) {
			int manhattanDistanceSum = 0;
			for (int x = 0; x < N; x++)
				// x-dimension, traversing rows (i)
				for (int y = 0; y < N; y++) { // y-dimension, traversing cols
												// (j)
					int value = tiles[x][y]; // tiles array contains board
												// elements
					if (value != 0) { // we don't compute MD for element 0
						int targetX = (value - 1) / N; // expected x-coordinate
														// (row)
						int targetY = (value - 1) % N; // expected y-coordinate
														// (col)
						int dx = x - targetX; // x-distance to expected
												// coordinate
						int dy = y - targetY; // y-distance to expected
												// coordinate
						manhattanDistanceSum += Math.abs(dx) + Math.abs(dy);
					}
				}
			manhattan = manhattanDistanceSum;
		}
		return manhattan;
	} // sum of Manhattan distances between blocks and goal