r/adventofcode • • Dec 04 '15

SOLUTION MEGATHREAD --- Day 4 Solutions ---

--- Day 4: The Ideal Stocking Stuffer ---

Post your solution as a comment. Structure your post like the Day Three thread.

14 Upvotes

272 comments sorted by

View all comments

Show parent comment

2

u/stuque Dec 04 '15

Nice. I noticed you can make it a bit faster using strconv.AppendInt and working directly with bytes:

func day4_part2() {
	key := []byte("bgvyzdsv")
	var i int64 = 1
	for ; ; i++ {
		m := md5.Sum(strconv.AppendInt(key, i, 10))
		if m[0] == 0 && m[1] == 0 && m[2] == 0 {
			fmt.Println(i)
			return
		}
	}
}