-
Notifications
You must be signed in to change notification settings - Fork 1
/
day8.go
34 lines (28 loc) · 781 Bytes
/
day8.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"strings"
"utils"
)
func run(filepath string) (sumNonVisibleChar int) {
lines := utils.ReadFileToLines(filepath)
for _, l := range lines {
sumNonVisibleChar += strings.Count(l, "\\\\")
l = strings.Replace(l, "\\\\", "", -1)
sumNonVisibleChar += strings.Count(l, "\\\"")
l = strings.Replace(l, "\\\"", "", -1)
sumNonVisibleChar += strings.Count(l, "\"")
l = strings.Replace(l, "\"", "", -1)
sumNonVisibleChar += strings.Count(l, "\\x") * 3
}
return sumNonVisibleChar
}
func run2(filepath string) (sumEncodeChar int) {
lines := utils.ReadFileToLines(filepath)
for _, l := range lines {
sumEncodeChar += strings.Count(l, "\"")
sumEncodeChar += strings.Count(l, "\\")
sumEncodeChar += 2
}
return sumEncodeChar
}
func main() {}