Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
samabcde committed Dec 10, 2023
1 parent 53f43de commit 03a4b83
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void validate(String[] blocks) {
throw new IllegalArgumentException("below blocks contains character other than '0', '1', ',' %s".formatted(containsInvalids.toString()));
}
long weight = Arrays.stream(blocks).mapToLong(s -> s.chars().filter(c -> c == '1').count()).sum();
if (weight != width * height) {
if (weight != (long) width * height) {
throw new IllegalArgumentException("total block weight:%s must equals puzzle size %d".formatted(weight, width * height));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,6 @@ public BitSet getIsPositionIdIntersectBitSet() {
}

private boolean get(int row, int col) {
if (row - position.y() < 0 || row - position.y() > block.getHeight() - 1) {
return false;
}
if (col - position.x() < 0 || col - position.x() > block.getWidth() - 1) {
return false;
}
return block.get(row - position.y(), col - position.x());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ public class PossiblePositions {
private final List<BlockPosition> blockPositions;

public PossiblePositions(List<BlockPosition> blockPositions) {
if (blockPositions.isEmpty()) {
isCommonIntersectBitSet = new BitSet();
} else {
isCommonIntersectBitSet = new BitSet(blockPositions.get(0).getIsPositionIdIntersectBitSet().size());
}
isCommonIntersectBitSet = new BitSet(blockPositions.get(0).getIsPositionIdIntersectBitSet().size());
this.isCommonIntersectBitSet.set(0, isCommonIntersectBitSet.size(), true);
setCommonIntersect(isCommonIntersectBitSet, blockPositions);
this.blockPositions = blockPositions;
Expand Down

0 comments on commit 03a4b83

Please sign in to comment.