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

41
5/5.go Normal file
View file

@ -0,0 +1,41 @@
package main
import "fmt"
import "bufio"
import "os"
import "strconv"
// cat input | go run 5.go
func main() {
var instructions []int
i := 0
count := 0
scanner := bufio.NewScanner(os.Stdin)
for scanner.Scan() {
i, _ := strconv.Atoi(scanner.Text())
instructions = append(instructions, i)
}
for {
if i >= len(instructions) {
fmt.Println(count)
os.Exit(0)
}
count++
current := instructions[i]
if instructions[i] < 3 {
instructions[i]++ // Just this one for the first solution
} else {
instructions[i]--
}
i += current
}
}