瀏覽代碼

Able to read sequence

Piotr Czajkowski 3 年之前
父節點
當前提交
05975d40e2
共有 1 個文件被更改,包括 31 次插入0 次删除
  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]))
+}