Skip to content

Instantly share code, notes, and snippets.

@ggarnier
Created April 28, 2017 21:54
Show Gist options
  • Save ggarnier/a3a22af2adba559c1a9bfdf83e49de66 to your computer and use it in GitHub Desktop.
Save ggarnier/a3a22af2adba559c1a9bfdf83e49de66 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"math"
"os"
"strconv"
)
func main() {
input, _ := strconv.Atoi(os.Args[1])
output := []int{}
numDigits := len(strconv.Itoa(input))
for i := numDigits - 1; i > 0; i-- {
power := int(math.Pow10(i))
part := (input / power) * power
output = append(output, part)
input -= part
}
output = append(output, input)
fmt.Println(output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment