aboutsummaryrefslogtreecommitdiff
path: root/2015/10/puzzles.go
diff options
context:
space:
mode:
Diffstat (limited to '2015/10/puzzles.go')
-rw-r--r--2015/10/puzzles.go31
1 files changed, 31 insertions, 0 deletions
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))
+}