adventofcode/04dec/main.go

40 lines
518 B
Go
Raw Normal View History

2017-12-04 12:19:52 +00:00
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
var in string
func main() {
fmt.Scanf("%s", &in)
sum := 0
in := bufio.NewScanner(os.Stdin)
for in.Scan() {
if checkPassphrase(in.Text()) {
sum++
}
}
fmt.Println(sum)
}
func checkPassphrase(d string) bool {
//fmt.Println(d)
words := strings.Split(d, " ")
for i, e := range words {
if i > 0 {
//fmt.Println(i, e)
for _, f := range words[0:i] {
//fmt.Println(e, f)
if f == e {
return false
}
}
}
}
return true
}