Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "fmt"
- "bufio"
- "os"
- "strconv"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- name := scanner.Text()
- scanner.Scan()
- zone := scanner.Text()
- var dots, yesCount, noCount int
- total := 301
- for total > 0 && zone != "Retire" {
- scanner.Scan()
- dots, _ = strconv.Atoi(scanner.Text())
- if zone == "Double" {
- dots *= 2
- } else if zone == "Triple" {
- dots *= 3
- }
- if total < dots {
- noCount++
- } else {
- total -= dots
- yesCount++
- }
- scanner.Scan()
- zone = scanner.Text()
- }
- if total == 0 {
- fmt.Printf("%s won the leg with %d shots.", name, yesCount)
- } else {
- fmt.Printf("%s retired after %d unsuccessful shots.", name, noCount)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement