Advertisement
Spocoman

04. Walking

Sep 22nd, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.67 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "math"
  6.     "strconv"
  7. )
  8.  
  9. func main() {
  10.     var neededSteps = 10000
  11.  
  12.     var input string
  13.    
  14.     for ; neededSteps > 0; {
  15.         fmt.Scanln(&input)
  16.         if input == "Going home" {
  17.             fmt.Scanln(&input)
  18.             steps,_ := strconv.Atoi(input)
  19.             neededSteps -= steps
  20.             break
  21.         }
  22.         steps,_ := strconv.Atoi(input)
  23.         neededSteps -= steps
  24.     }
  25.  
  26.     if neededSteps > 0 {
  27.         fmt.Printf("%d more steps to reach goal.\n", neededSteps)
  28.     } else {
  29.         fmt.Printf("Goal reached! Good job!\n%d steps over the goal!", int(math.Abs(float64(neededSteps))))
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement