Browse Source

Able to read sequence

Piotr Czajkowski 3 years ago
parent
commit
05975d40e2
1 changed files with 31 additions and 0 deletions
  1. 31 0
      day23/day23.go

+ 31 - 0
day23/day23.go

@@ -0,0 +1,31 @@
+package main
+
+import (
+	"fmt"
+	"log"
+	"os"
+	"strconv"
+)
+
+func processSequence(input string) []int {
+	var sequence []int
+
+	for _, letter := range input {
+		cup, err := strconv.Atoi(string(letter))
+		if err != nil {
+			log.Fatalf("Error processing cup for %s: %s", letter, err)
+		}
+
+		sequence = append(sequence, cup)
+	}
+
+	return sequence
+}
+
+func main() {
+	if len(os.Args) < 2 {
+		log.Fatal("You need to specify a sequence!")
+	}
+
+	fmt.Println(processSequence(os.Args[1]))
+}