Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "math"
- "strconv"
- )
- func main() {
- var neededSteps = 10000
- var input string
- for ; neededSteps > 0; {
- fmt.Scanln(&input)
- if input == "Going home" {
- fmt.Scanln(&input)
- steps,_ := strconv.Atoi(input)
- neededSteps -= steps
- break
- }
- steps,_ := strconv.Atoi(input)
- neededSteps -= steps
- }
- if neededSteps > 0 {
- fmt.Printf("%d more steps to reach goal.\n", neededSteps)
- } else {
- fmt.Printf("Goal reached! Good job!\n%d steps over the goal!", int(math.Abs(float64(neededSteps))))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement