package main import ( "bufio" "fmt" "io" "os" "strconv" ) func main() { const numOfPlayers = 2 var players [numOfPlayers]*player sc := NewScanner(os.Stdin) for i := 0; i < numOfPlayers; i++ { name, _ := sc.Next() points, _ := sc.Next() sc.Next() players[i] = NewPlayer(name, points) } fmt.Println(solve(players[0], players[1])) } func solve(a, b *player) string { switch { case len(a.points) > len(b.points): return a.name case len(a.points) < len(b.points): return b.name default: switch { case a.points > b.points: return a.name case a.points < b.points: return b.name default: return "-1" } } } type player struct { name string points string } func NewPlayer(name string, points string) *player { return &player{ name, points, } } type scanner struct { *bufio.Scanner } func NewScanner(r io.Reader) *scanner { return &scanner{ bufio.NewScanner(r), } } func (s *scanner) Next() (string, error) { s.Scanner.Split(bufio.ScanWords) return s.nextToken() } func (s *scanner) nextToken() (string, error) { sc := s.Scanner if sc.Scan() { return sc.Text(), nil } if sc.Err() != nil { return "", sc.Err() } return "", io.EOF } func (s *scanner) NextInt() (int, error) { token, err := s.Next() if err != nil { return 0, err } return strconv.Atoi(token) }