Browse Source

Solved part1

Piotr Czajkowski 5 months ago
parent
commit
3f47900b86
1 changed files with 5 additions and 4 deletions
  1. 5 4
      07/code.go

+ 5 - 4
07/code.go

@@ -119,9 +119,11 @@ func part1(hands []Hand) int {
 	sort.Slice(hands, func(i, j int) bool {
 		if hands[i].score == hands[j].score {
 			for k := 0; k < NumberOfCards; k++ {
-				if hands[i].ranks[k] < hands[j].ranks[k] {
-					return true
+				if hands[i].ranks[k] == hands[j].ranks[k] {
+					continue
 				}
+
+				return hands[i].ranks[k] < hands[j].ranks[k]
 			}
 		}
 
@@ -132,7 +134,6 @@ func part1(hands []Hand) int {
 		result += (i + 1) * hands[i].bid
 	}
 
-	fmt.Println(hands)
 	return result
 }
 
@@ -149,5 +150,5 @@ func main() {
 	}
 
 	hands := readInput(file)
-	fmt.Println(part1(hands))
+	fmt.Println("Part1:", part1(hands))
 }