From 984d3d5ebb1be5e87773dd8a435e8cfd4039f4fc Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Thu, 9 Dec 2021 17:54:15 +0100 Subject: Added solutions for 8th day : the seven segments code to guess --- 2021/08/first.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 2021/08/first.go (limited to '2021/08/first.go') diff --git a/2021/08/first.go b/2021/08/first.go new file mode 100644 index 0000000..d21fe67 --- /dev/null +++ b/2021/08/first.go @@ -0,0 +1,25 @@ +package main + +import ( + "bufio" + "fmt" + "os" + "strings" +) + +func main() { + score := 0 + + s := bufio.NewScanner(os.Stdin) + for s.Scan() { + inputs := strings.Split(s.Text(), " | ") + output := strings.Split(inputs[1], " ") + for _, v := range output { + l := len(v) + if l < 5 || l == 7 { + score++ + } + } + } + fmt.Println(score) +} -- cgit v1.2.3