This commit is contained in:
Ben Charlton 2017-12-12 21:45:36 +00:00
parent 0eec315f95
commit bf5ef31334
2 changed files with 14 additions and 16 deletions

View file

@ -4,8 +4,8 @@ import (
"bufio"
"fmt"
"os"
"strings"
"strconv"
"strings"
)
// cat input | go run 12.go
@ -43,7 +43,6 @@ func main() {
fmt.Println(cp, groups)
}
func CountPipes(pipedata []pipedata) int {
seen := make(map[int]int)
seen = getChildren(seen, pipedata, 0)
@ -76,7 +75,7 @@ func getChildren(seen map[int]int, pipedata []pipedata, pipe int) map[int]int {
p := pipedata[pipe]
for l := range p.linkedTo {
child := p.linkedTo[l]
if (seen[child] == 0) {
if seen[child] == 0 {
seen[child]++
seen = getChildren(seen, pipedata, child)
}

View file

@ -25,7 +25,6 @@ func TestCountPipes(t *testing.T) {
}
}
func TestCountGroups(t *testing.T) {
seen := make(map[int]int)
v, _ := CountGroups(seen, tests)