2023-12-06 11:02:00 +00:00
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bufio"
|
|
|
|
"os"
|
|
|
|
"strings"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
reader := bufio.NewReader(os.Stdin);
|
|
|
|
|
|
|
|
total := 0;
|
|
|
|
|
|
|
|
multipliers := []int{};
|
|
|
|
|
|
|
|
for text, err := reader.ReadString('\n'); err == nil; text, err = reader.ReadString('\n') {
|
|
|
|
text = strings.Trim(text, "\n")
|
|
|
|
points := score(text);
|
|
|
|
|
2023-12-20 19:31:01 +00:00
|
|
|
// fmt.Printf("%v: %v\n", text, points);
|
2023-12-06 11:02:00 +00:00
|
|
|
|
|
|
|
newMultipliers := []int{};
|
|
|
|
for i := range multipliers {
|
|
|
|
if multipliers[i] > 0 {
|
|
|
|
newMultipliers = append(newMultipliers, multipliers[i]-1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
multipliers = newMultipliers;
|
|
|
|
multiplier := len(multipliers) + 1;
|
|
|
|
|
|
|
|
for i := 0; i < multiplier; i++ {
|
|
|
|
multipliers = append(multipliers, points);
|
|
|
|
}
|
|
|
|
|
|
|
|
total += multiplier;
|
2023-12-20 19:31:01 +00:00
|
|
|
fmt.Printf("%v | +%v = %v\n", points, multiplier, total);
|
2023-12-06 11:02:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("total cards: %v", total);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func score(text string) (amt int) {
|
|
|
|
gameStr := strings.ReplaceAll(strings.Split(text, ": ")[1], " ", " ");
|
|
|
|
|
|
|
|
nums := strings.Split(gameStr," | ");
|
|
|
|
|
|
|
|
winners := strings.Split(nums[0]," ");
|
|
|
|
draw := strings.Split(nums[1]," ");
|
|
|
|
|
|
|
|
for _, n := range draw {
|
|
|
|
match := false;
|
|
|
|
for _, w := range winners {
|
|
|
|
match = n == w;
|
|
|
|
if match {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if match {
|
|
|
|
amt++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
|