aboutsummaryrefslogtreecommitdiff
path: root/2015/10/puzzles.go
blob: 65de02fa2dd611c641ee2074e6485046f6d8649a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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))
}