Skip to content

Commit

Permalink
Remove verbose print statements
Browse files Browse the repository at this point in the history
scottmckendry committed Nov 23, 2023
1 parent c1b36e1 commit ca5b61a
Showing 1 changed file with 0 additions and 53 deletions.
53 changes: 0 additions & 53 deletions 2022/11p1.go
Original file line number Diff line number Diff line change
@@ -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,31 +144,15 @@ 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 {
selectedMonkey.operation.value = 0
}

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,15 +161,13 @@ 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
}
}
} 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
}

0 comments on commit ca5b61a

Please sign in to comment.