aoc/aoc2015/day04.go

28 lines
396 B
Go
Raw Permalink Normal View History

2024-07-24 14:29:59 +00:00
package aoc2015
2024-07-24 18:03:39 +00:00
import (
"aoc/internal/utility"
"fmt"
"strings"
)
2024-07-24 14:29:59 +00:00
func day04() {
2024-07-24 18:03:39 +00:00
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++
}
2024-07-24 14:29:59 +00:00
}