-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalphabetFrequency.go
More file actions
56 lines (55 loc) · 937 Bytes
/
Copy pathalphabetFrequency.go
File metadata and controls
56 lines (55 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
//import (
// "bufio"
// "fmt"
// "os"
//)
//
//func main() {
// scanner := bufio.NewScanner(os.Stdin)
// buf := make([]byte, 1024*1024)
// scanner.Buffer(buf, 1024*1024)
// scanner.Scan()
// text := scanner.Bytes()
//
// // capitalize and normalize
// gap := byte('a') - byte('A')
// normalize := byte('A')
// for i, ch := range text {
// if ch > byte('Z') {
// text[i] = ch - gap
// }
// text[i] = text[i] - normalize
// }
//
// alphabet := [26]int{}
// for _, ch := range text {
// alphabet[ch] = alphabet[ch] + 1
// }
//
// var max int
// var index int
// for i, al := range alphabet {
// if max < al {
// max = al
// index = i
// }
// }
//
// var count int
// for i:=0; i<len(alphabet); i++ {
// if alphabet[i] == max {
// count = count + 1
// }
// }
//
// if count > 1 {
// fmt.Println("?")
// return
// }
//
// var answer byte
//
// answer = byte(index) + normalize
// fmt.Print(string(answer))
//}