You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

28 lines
412 B

package main
import (
"fmt"
"io/ioutil"
"math"
"strconv"
"strings"
)
func main() {
data, err := ioutil.ReadFile("input.txt")
if err != nil {
fmt.Println("File reading error", err)
return
}
lines := strings.Split(string(data), "\n")
sum := 0.0
for _, line := range lines {
fuel, _ := strconv.Atoi(line)
result := math.Floor(float64(fuel)/3) - 2
sum += result
}
fmt.Println(int(sum))
}