2023 Day 4 Complete!
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user