Solution to 004 in Go