Advertisement
Spocoman

Walking

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