aoc/aoc2015/day04.go

28 lines
396 B
Go

package aoc2015
import (
"aoc/internal/utility"
"fmt"
"strings"
)
func day04() {
in := "yzbqklnj"
fmt.Println("Takes a few seconds....")
var p1 int
c := 1
for {
hash := utility.GetMD5Hash(fmt.Sprintf("%s%d", in, c))
if p1 == 0 && strings.HasPrefix(hash, "00000") {
p1 = c
fmt.Println(p1)
}
if strings.HasPrefix(hash, "000000") {
fmt.Println(c)
break
}
c++
}
}