fine, I'll put them on github
This commit is contained in:
commit
c3bc233d82
9 changed files with 472 additions and 0 deletions
41
5/5.go
Normal file
41
5/5.go
Normal 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
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue