Skip to content

Commit ff1f8bb

Browse files
authored
Fix bug in runs when counting score
1 parent aae01c6 commit ff1f8bb

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

src/counter/Cribbage.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,15 @@ private static List<Integer> getLongestConsecutive(ArrayList<Integer> scores) {
9494
for (int i = 0; i < listWithoutDuplicates.size() - 1; i++) {
9595
if (listWithoutDuplicates.get(i) + 1 == listWithoutDuplicates.get(i + 1)) {
9696
run++;
97-
array.add(listWithoutDuplicates.get(i + 1));
9897
} else {
9998
if (maxRun < run) {
10099
maxRun = run;
101100
maxArray = array;
102101
}
103102
run = 1;
104103
array = new ArrayList<>();
105-
array.add(listWithoutDuplicates.get(i));
106104
}
105+
array.add(listWithoutDuplicates.get(i + 1));
107106
}
108107
if (maxRun < run)
109108
maxArray = array;

0 commit comments

Comments
 (0)