fine, I'll put them on github

This commit is contained in:
Ben Charlton 2017-12-06 17:28:33 +00:00
commit c3bc233d82
9 changed files with 472 additions and 0 deletions

37
1/1.go Normal file
View file

@ -0,0 +1,37 @@
package main
import "os"
import "fmt"
import "strings"
import "strconv"
// go run 1.go <input>
func main() {
s := strings.Split(os.Args[1], "")
checksum := 0
checksum2 := 0
for index, element := range s {
pre := index - 1
pre2 := (index + (len(s) / 2)) % len(s)
if pre == -1 {
pre = len(s) - 1
}
fmt.Println(index, element, pre, s[pre])
if element == s[pre] {
i, _ := strconv.Atoi(element)
checksum += i
}
if element == s[pre2] {
i, _ := strconv.Atoi(element)
checksum2 += i
}
}
fmt.Println(checksum, checksum2)
}