remove extra print, format
This commit is contained in:
parent
777fa8e9d6
commit
823e2c683f
10
day6/main.go
10
day6/main.go
|
@ -1,19 +1,19 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
d, _ := ioutil.ReadFile("input")
|
||||
s := string(d)
|
||||
groups := strings.Split(s,"\n\n")
|
||||
groups := strings.Split(s, "\n\n")
|
||||
total := 0
|
||||
for _, g := range groups {
|
||||
results := make(map[rune]bool)
|
||||
lines := strings.Split(g,"\n")
|
||||
results := make(map[rune]bool)
|
||||
lines := strings.Split(g, "\n")
|
||||
for _, l := range lines {
|
||||
for _, c := range l {
|
||||
if _, ok := results[c]; !ok { // if it's not already accounted for
|
||||
|
@ -24,4 +24,4 @@ func main() {
|
|||
total += len(results)
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -10,11 +10,11 @@ func main() {
|
|||
d, _ := ioutil.ReadFile("input")
|
||||
s := string(d)
|
||||
//s := "abc\n\na\nb\nc\n\nab\nac\n\na\na\na\na\n\nb\n"
|
||||
groups := strings.Split(strings.Trim(s,"\n"),"\n\n")
|
||||
groups := strings.Split(strings.Trim(s, "\n"), "\n\n")
|
||||
total := 0
|
||||
for _, g := range groups {
|
||||
results := make(map[rune]int)
|
||||
lines := strings.Split(g,"\n")
|
||||
results := make(map[rune]int)
|
||||
lines := strings.Split(g, "\n")
|
||||
for _, l := range lines {
|
||||
for _, c := range l {
|
||||
if _, ok := results[c]; !ok { // if it's not already there
|
||||
|
@ -29,8 +29,7 @@ func main() {
|
|||
delete(results, q)
|
||||
}
|
||||
}
|
||||
fmt.Println(results)
|
||||
total += len(results)
|
||||
}
|
||||
fmt.Println(total)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue