aboutsummaryrefslogtreecommitdiff
path: root/one.go
diff options
context:
space:
mode:
authorj-james2020-12-01 05:17:13 +0000
committerj-james2020-12-01 05:17:13 +0000
commitb23ea9372ae92b2add77213393041c62cba9a75b (patch)
tree0e4deb435849ff5a5fb0a4ce93bcd5beac5f386c /one.go
parent73f5728472dc5ffba612b0aead3126c63dd8b7d2 (diff)
Move 2019 Advent of Code work into its own folder
Diffstat (limited to 'one.go')
-rw-r--r--one.go40
1 files changed, 0 insertions, 40 deletions
diff --git a/one.go b/one.go
deleted file mode 100644
index cf27820..0000000
--- a/one.go
+++ /dev/null
@@ -1,40 +0,0 @@
-package main
-
-import (
- "fmt"
- "io/ioutil"
- "os"
- "strconv"
-)
-
-func main() {
- start, sum, fuelsum := 0, 0, 0
- if len(os.Args) < 2 {
- panic("runtime error: missing operand")
- }
- file, err := ioutil.ReadFile(os.Args[1])
- if err != nil {
- panic(err)
- }
- for i := 0; i < len(file); i++ {
- if file[i] == '\n' {
- arg, err := strconv.Atoi(string(file[start:i])) // i-1??
- if err != nil {
- panic(err)
- }
- start = i + 1
- sum += (arg / 3) - 2
- fuelsum += tyranny(arg)
- }
- }
- fmt.Println(sum)
- fmt.Println(fuelsum)
-}
-
-func tyranny(mass int) int {
- subtotal := 0
- for fuel := (mass / 3) - 2; fuel >= 0; fuel = (fuel / 3) - 2 {
- subtotal += fuel
- }
- return subtotal
-}