Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- var startPoints, points, moves int
- fmt.Scanln(&startPoints)
- scanner := bufio.NewScanner(os.Stdin)
- var command string
- for startPoints > 0 {
- moves ++
- scanner.Scan()
- command = scanner.Text()
- if command == "bullseye" {
- break
- }
- scanner.Scan()
- points, _ = strconv.Atoi(scanner.Text())
- if command == "double ring" {
- points *= 2
- } else if command == "triple ring" {
- points *= 3
- }
- startPoints -= points
- }
- if startPoints == 0 {
- fmt.Printf("Congratulations! You won the game in %d moves!", moves)
- } else if startPoints < 0 {
- fmt.Printf("Sorry, you lost. Score difference: %d.", startPoints * -1)
- } else {
- fmt.Printf("Congratulations! You won the game with a bullseye in %d moves!", moves)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement