chore: cleanup

This commit is contained in:
xuu 2023-12-07 20:09:58 -07:00
parent 827835f12f
commit e6c53df5c5
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
2 changed files with 6 additions and 10 deletions

View File

@ -9,7 +9,7 @@ import (
func main() { func main() {
if len(os.Args) != 2 { if len(os.Args) != 2 {
fmt.Fprintln(os.Stderr, "Usage: day06 FILE") fmt.Fprintln(os.Stderr, "Usage: day07 FILE")
} }
input, err := os.Open(os.Args[1]) input, err := os.Open(os.Args[1])
@ -40,10 +40,10 @@ func run(scan *bufio.Scanner) (uint64, uint64) {
game.plays = append(game.plays, Play{bid, []rune(cards), &game}) game.plays = append(game.plays, Play{bid, []rune(cards), &game})
} }
game.cardOrder = getOrder(1) game.cardOrder = getOrder(cardTypes1)
product1 := calcProduct(game) product1 := calcProduct(game)
game.cardOrder = getOrder(2) game.cardOrder = getOrder(cardTypes2)
game.wildCard = 'J' game.wildCard = 'J'
product2 := calcProduct(game) product2 := calcProduct(game)
@ -65,11 +65,7 @@ func calcProduct(game Game) uint64 {
return product return product
} }
func getOrder(v int) map[rune]int { func getOrder(cardTypes []rune) map[rune]int {
cardTypes := cardTypes1
if v == 2 {
cardTypes = cardTypes2
}
cardOrder := make(map[rune]int, len(cardTypes)) cardOrder := make(map[rune]int, len(cardTypes))
for i, r := range cardTypes { for i, r := range cardTypes {
cardOrder[r] = len(cardTypes) - i cardOrder[r] = len(cardTypes) - i

View File

@ -24,7 +24,7 @@ func TestHands(t *testing.T) {
is := is.New(t) is := is.New(t)
var game Game var game Game
game.cardOrder = getOrder(1) game.cardOrder = getOrder(cardTypes1)
h := Play{0, []rune("AAA23"), &game} h := Play{0, []rune("AAA23"), &game}
is.Equal(h.HandType(), "3K-A") is.Equal(h.HandType(), "3K-A")