Skip to content

Commit

Permalink
Refactor day 4 puzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
Flashky committed Dec 4, 2023
1 parent 077a466 commit d6c2f25
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/main/java/com/adventofcode/flashk/day04/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public Card(String input) {
}

public int calculateWinningPoints() {
return matchingNumbers.isEmpty() ?
0 : IntStream.range(1, matchingNumbers.size()).reduce(1, (a,b) -> a*2);
return (int) Math.floor(Math.pow(2, (double) matchingNumbers.size()-1));
}

public int totalMatchingNumbers() {
Expand Down

0 comments on commit d6c2f25

Please sign in to comment.