diff options
author | Julien Dessaux | 2021-12-09 17:54:15 +0100 |
---|---|---|
committer | Julien Dessaux | 2021-12-09 17:54:15 +0100 |
commit | 984d3d5ebb1be5e87773dd8a435e8cfd4039f4fc (patch) | |
tree | fe8a556ef488da120750d02c5fc5692e47effd02 /2021/08/first.go | |
parent | Added solutions for 7th day (diff) | |
download | advent-of-code-984d3d5ebb1be5e87773dd8a435e8cfd4039f4fc.tar.gz advent-of-code-984d3d5ebb1be5e87773dd8a435e8cfd4039f4fc.tar.bz2 advent-of-code-984d3d5ebb1be5e87773dd8a435e8cfd4039f4fc.zip |
Added solutions for 8th day : the seven segments code to guess
Diffstat (limited to '')
-rw-r--r-- | 2021/08/first.go | 25 |
1 files changed, 25 insertions, 0 deletions
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) +} |