Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package main
- import (
- "bufio"
- "fmt"
- "os"
- )
- func main() {
- scanner := bufio.NewScanner(os.Stdin)
- scanner.Scan()
- movie := scanner.Text()
- var bestMovie string
- var counter, bestAscii int
- for movie != "STOP" && counter < 7 {
- currentAscii := 0
- for j := 0; j < len(movie); j++ {
- currentAscii += int(movie[j])
- if int(movie[j]) > 96 && int(movie[j]) < 123 {
- currentAscii -= len(movie) * 2
- } else if int(movie[j]) > 64 && int(movie[j]) < 91 {
- currentAscii -= len(movie)
- }
- }
- if currentAscii > bestAscii {
- bestAscii = currentAscii
- bestMovie = movie
- }
- counter++
- scanner.Scan()
- movie = scanner.Text()
- }
- if counter == 7 {
- fmt.Println("The limit is reached.")
- }
- fmt.Printf("The best movie for you is %s with %d ASCII sum.", bestMovie, bestAscii)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement