From e7c9108b95e39d7ea5a29ae06d619c4727f11027 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Fri, 29 Oct 2021 23:02:39 +0200 Subject: Initial commit --- 2015/10/puzzles.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 2015/10/puzzles.go (limited to '2015/10/puzzles.go') diff --git a/2015/10/puzzles.go b/2015/10/puzzles.go new file mode 100644 index 0000000..65de02f --- /dev/null +++ b/2015/10/puzzles.go @@ -0,0 +1,31 @@ +package main + +import ( + "fmt" + "strconv" +) + +func process(num string) string { + var newnum string + + for i := 0; i < len(num); { + c := num[i] + j := 0 + for i < len(num) && num[i] == c { + i++ + j++ + } + newnum += strconv.Itoa(j) + newnum = string(append([]byte(newnum), c)) + } + + return newnum +} + +func main() { + num := INPUT + for i := 0; i < LOOPS; i++ { + num = process(num) + } + fmt.Println(len(num)) +} -- cgit v1.2.3