62 lines
951 B
Go
62 lines
951 B
Go
|
|
package main
|
||
|
|
|
||
|
|
import (
|
||
|
|
"bufio"
|
||
|
|
"log"
|
||
|
|
"os"
|
||
|
|
"strconv"
|
||
|
|
)
|
||
|
|
|
||
|
|
func mod(a int, b int) int {
|
||
|
|
return (a%b + b) % b
|
||
|
|
}
|
||
|
|
|
||
|
|
func One() {
|
||
|
|
cur := 50
|
||
|
|
n_zeroes := 0
|
||
|
|
|
||
|
|
file, err := os.Open("one.txt")
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
defer file.Close()
|
||
|
|
|
||
|
|
scanner := bufio.NewScanner(file)
|
||
|
|
|
||
|
|
for scanner.Scan() {
|
||
|
|
text := scanner.Text()
|
||
|
|
|
||
|
|
num, err := strconv.Atoi(text[1:])
|
||
|
|
if err != nil {
|
||
|
|
log.Fatal(err)
|
||
|
|
}
|
||
|
|
|
||
|
|
var next_pre_modulo int = 0
|
||
|
|
if text[0] == 'R' {
|
||
|
|
next_pre_modulo = cur + num
|
||
|
|
n_zeroes += next_pre_modulo / 100
|
||
|
|
} else {
|
||
|
|
next_pre_modulo = cur - num
|
||
|
|
if next_pre_modulo <= 0 {
|
||
|
|
extra := (next_pre_modulo / -100)
|
||
|
|
|
||
|
|
// Omg you sneaky fuck! We only add one if we didn't start on
|
||
|
|
// 0 already.
|
||
|
|
if cur != 0 {
|
||
|
|
extra += 1
|
||
|
|
}
|
||
|
|
|
||
|
|
n_zeroes += extra
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
cur = mod(next_pre_modulo, 100)
|
||
|
|
log.Printf("Next pre mod: %d, post mod: %d, n zeroes: %d", next_pre_modulo, cur, n_zeroes)
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
func main() {
|
||
|
|
One()
|
||
|
|
}
|