Just my learning go snippets
package ngn

import (
	"strconv"
)

func Tipping(n string) (tipping int) {
	for i := 0; i < len(n)-1; i++ {
		if n[i] > n[i+1] {
			return i
		}
	}
	return tipping
}

func Growing(n string, tipping int) (ret string) {
	//log.Printf("num: %s, tipping: %d", n, tipping)
	if tipping != 0 {
		return tipgrow(n, tipping)
	}
	// there is no tipping poing, input is already a growing number
	for i := len(n) - 1; i >= 0; i-- {
		curr := n[i]
		//log.Printf("curr: %c\t%v, i: %d\n", curr, curr, i)
		if curr != 57 && i == len(n)-1 {
			// its not 9 and it is the last so we do not have to bump the place value
			curr++
			ret = n[:len(n)-1] + string(curr)
			return ret
		}
		if curr == 57 && i == 0 {
			// it is all 9, eg: 99
			// we have to prepend 1 to it
			n = strconv.Itoa(1) + n
			return tipgrow(n, 0)
		}
		if curr != 57 {
			curr++
			//log.Printf("pre: %s, curr: %s, post: %s", n[:i], string(curr), n[i+1:])
			n = n[:i] + string(curr) + n[i+1:]
			return tipgrow(n, i)
		}
	}
	return ret
}

func tipgrow(n string, tipping int) (ret string) {
	for i := 0; i < len(n); i++ {
		if i < tipping {
			ret += string(n[i])
		} else {
			new := n[tipping]
			ret += string(new)
		}
	}
	return ret
}