Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- "strings"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- word := scanner.Text()
- vowels := "aeiouyAEIOUY"
- strongWord := ""
- strongSum := 0.0
- for word != "End of words" {
- wordSum := 0.0
- for i := 0; i < len(word); i++ {
- wordSum += float64(int(word[i]))
- }
- if strings.Contains(vowels, string(word[0])) {
- wordSum *= float64(len(word))
- } else {
- wordSum /= float64(len(word))
- }
- if wordSum > strongSum {
- strongWord = word
- strongSum = wordSum
- }
- scanner.Scan()
- word = scanner.Text()
- }
- fmt.Printf("The most powerful word is %s - %d", strongWord, int(strongSum))
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement