Files
learngo/23-input-scanning/exercises/05-quit/solution/main.go

32 lines
586 B
Go
Raw Normal View History

2019-04-12 16:55:26 +03:00
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
2019-10-30 19:34:44 +03:00
// For more tutorials : https://learngoprogramming.com
// In-person training : https://www.linkedin.com/in/inancgumus/
// Follow me on twitter: https://twitter.com/inancgumus
2019-04-12 16:55:26 +03:00
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
in := bufio.NewScanner(os.Stdin)
2019-05-07 12:17:07 +03:00
words := make(map[string]bool)
2019-04-12 16:55:26 +03:00
for in.Scan() {
2019-05-07 12:17:07 +03:00
w := strings.ToLower(in.Text())
if words[w] {
fmt.Println("TWICE!")
return
2019-04-12 16:55:26 +03:00
}
2019-05-07 12:17:07 +03:00
words[in.Text()] = true
2019-04-12 16:55:26 +03:00
}
}