diff --git a/2022/11p1.go b/2022/11p1.go index 14867af..23935ea 100644 --- a/2022/11p1.go +++ b/2022/11p1.go @@ -32,31 +32,10 @@ func D11P1() { lines := utils.ReadLines("./inputs/11.txt") monkeys := parseMonkeys(lines) - for _, monkey := range monkeys { - fmt.Printf( - "Monkey ID: %d - Items: %v - Operation: %v - Test: %v\n", - monkey.id, - monkey.items, - monkey.operation, - monkey.test, - ) - } - for i := 0; i < rounds; i++ { simulateRound(&monkeys) } - for _, monkey := range monkeys { - fmt.Printf( - "Monkey ID: %d - Items: %v - Operation: %v - Test: %v - Inspect Count: %d\n", - monkey.id, - monkey.items, - monkey.operation, - monkey.test, - monkey.inspectCount, - ) - } - monkeyWithMostInspections := monkeys[0] monkeyWithSecondMostInspections := monkeys[0] for _, monkey := range monkeys { @@ -66,8 +45,6 @@ func D11P1() { } } - fmt.Printf("Monkey with most inspections: %d\n", monkeyWithMostInspections.id) - fmt.Printf("Monkey with second most inspections: %d\n", monkeyWithSecondMostInspections.id) fmt.Printf( "Product of top two monkey inspections: %d\n", monkeyWithMostInspections.inspectCount*monkeyWithSecondMostInspections.inspectCount, @@ -129,21 +106,11 @@ func parseMonkeys(lines []string) []monkey { // Set Test monkeyWhenTrue if line[7] == 't' { currentMonkey.test.monkeyWhenTrue = testCaseMonkeyId - fmt.Printf( - "ID: %d Monkey when true: %d\n ", - currentMonkey.id, - currentMonkey.test.monkeyWhenTrue, - ) continue } // Set Test monkeyWhenFalse currentMonkey.test.monkeyWhenFalse = testCaseMonkeyId - fmt.Printf( - "ID: %d Monkey when false: %d\n ", - currentMonkey.id, - currentMonkey.test.monkeyWhenFalse, - ) } } @@ -166,10 +133,8 @@ func simulateRound(monkeys *[]monkey) { } func simulateMonkeyOperations(selectedMonkey *monkey, allMonkeys *[]monkey) { - fmt.Printf("Monkey %d:\n", selectedMonkey.id) resetOperationValue := false for i, item := range selectedMonkey.items { - fmt.Printf("\tMonkey inspects item with a worry level of %d\n", item) (*allMonkeys)[selectedMonkey.id].inspectCount++ // If the monkey's operation references the item value, set to the value of the item if selectedMonkey.operation.value == 0 { @@ -179,19 +144,8 @@ func simulateMonkeyOperations(selectedMonkey *monkey, allMonkeys *[]monkey) { if selectedMonkey.operation.operationType == '*' { selectedMonkey.items[i] = item * selectedMonkey.operation.value - fmt.Printf( - "\t\tWorry level is multiplied by %d to %d\n", - selectedMonkey.operation.value, - selectedMonkey.items[i], - ) } else { selectedMonkey.items[i] = item + selectedMonkey.operation.value - - fmt.Printf( - "\t\tWorry level increases by %d to %d\n", - selectedMonkey.operation.value, - selectedMonkey.items[i], - ) } if resetOperationValue { @@ -199,11 +153,6 @@ func simulateMonkeyOperations(selectedMonkey *monkey, allMonkeys *[]monkey) { } selectedMonkey.items[i] = selectedMonkey.items[i] / 3 - fmt.Printf( - "\t\tMonkey gets bored with item. Worry level is divided by 3 to %d\n", - selectedMonkey.items[i], - ) - simulateMonkeyTest(selectedMonkey, selectedMonkey.items[i], allMonkeys) } } @@ -212,7 +161,6 @@ func simulateMonkeyTest(selectedMonkey *monkey, item int, allMonkeys *[]monkey) if item%selectedMonkey.test.divisibleBy == 0 { for _, monkey := range *allMonkeys { if monkey.id == selectedMonkey.test.monkeyWhenTrue { - fmt.Printf("\t\tItem with worry level %d is thrown to monkey %d\n", item, monkey.id) (*allMonkeys)[monkey.id].items = append((*allMonkeys)[monkey.id].items, item) break } @@ -220,7 +168,6 @@ func simulateMonkeyTest(selectedMonkey *monkey, item int, allMonkeys *[]monkey) } else { for _, monkey := range *allMonkeys { if monkey.id == selectedMonkey.test.monkeyWhenFalse { - fmt.Printf("\t\tItem with worry level %d is thrown to monkey %d\n", item, monkey.id) (*allMonkeys)[monkey.id].items = append((*allMonkeys)[monkey.id].items, item) break }