Compare commits
No commits in common. "26fb260a0c2f5df3b8445c2b1e8cb7bf6f27d203" and "3806e2c1bf24bd697daffc228a509972af32f5a5" have entirely different histories.
26fb260a0c
...
3806e2c1bf
2 changed files with 0 additions and 64 deletions
|
|
@ -1,3 +0,0 @@
|
||||||
module forgejo.gwairfelin.com/aoc
|
|
||||||
|
|
||||||
go 1.25.4
|
|
||||||
61
2025/one.go
61
2025/one.go
|
|
@ -1,61 +0,0 @@
|
||||||
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()
|
|
||||||
}
|
|
||||||
Loading…
Add table
Reference in a new issue