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()
- var winner string
- var num, points int
- for name != "Stop" {
- currentPoints := 0
- for i := 0; i < len(name); i++ {
- scanner.Scan()
- num,_ = strconv.Atoi(scanner.Text())
- z := int(name[i])
- if num == z {
- currentPoints += 10
- } else {
- currentPoints += 2
- }
- }
- if currentPoints >= points {
- winner = name
- points = currentPoints
- }
- scanner.Scan()
- name = scanner.Text()
- }
- fmt.Printf("The winner is %s with %d points!", winner, points)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement