2023 Day 4 Complete!

This commit is contained in:
2023-12-04 08:54:52 -06:00
parent 4fe4929cca
commit 38a74e36d9
5 changed files with 451 additions and 2 deletions

View File

@@ -153,11 +153,18 @@ func Atof(i string) float64 {
return ret
}
// Atoi is basically redundant
// Atoi goes through i and removes and characters that aren't numeric
// Then runs it through the normal Atoi
func Atoi(i string) int {
var wrk string
for _, bt := range i {
if bt >= '0' && bt <= '9' {
wrk = fmt.Sprintf("%s%s", wrk, string(bt))
}
}
var ret int
var err error
if ret, err = strconv.Atoi(i); err != nil {
if ret, err = strconv.Atoi(wrk); err != nil {
log.Fatalf("Invalid Atoi: %s\n%v", i, err)
}
return ret