adding 2015 & 2025 advents
This commit is contained in:
10
2015/04/golang/.vscode/settings.json
vendored
Normal file
10
2015/04/golang/.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"[go]": {
|
||||
"editor.insertSpaces": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "golang.go",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.organizeImports": "explicit"
|
||||
}
|
||||
}
|
||||
}
|
||||
3
2015/04/golang/go.mod
Normal file
3
2015/04/golang/go.mod
Normal file
@@ -0,0 +1,3 @@
|
||||
module aoc/day-4
|
||||
|
||||
go 1.24.4
|
||||
29
2015/04/golang/main.go
Normal file
29
2015/04/golang/main.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
const key = "bgvyzdsv"
|
||||
|
||||
func main() {
|
||||
i := 0
|
||||
var found = false
|
||||
for !found {
|
||||
hash := genMD5Hash(key + strconv.Itoa(i))
|
||||
if hash[0:6] == "000000" {
|
||||
found = true
|
||||
} else {
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
fmt.Println(i)
|
||||
}
|
||||
|
||||
func genMD5Hash(text string) string {
|
||||
hash := md5.Sum([]byte(text))
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
Reference in New Issue
Block a user