-
Notifications
You must be signed in to change notification settings - Fork 0
/
day-28.go
56 lines (46 loc) · 1005 Bytes
/
day-28.go
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"
"io"
"os"
"sort"
"strconv"
"strings"
)
func main() {
reader := bufio.NewReaderSize(os.Stdin, 16*1024*1024)
NTemp, err := strconv.ParseInt(strings.TrimSpace(readLine(reader)), 10, 64)
checkError(err)
N := int32(NTemp)
var names []string
for NItr := 0; NItr < int(N); NItr++ {
firstMultipleInput := strings.Split(strings.TrimSpace(readLine(reader)), " ")
firstName := firstMultipleInput[0]
emailID := firstMultipleInput[1]
i := 0
n := len(emailID)
for i < n && emailID[i] != '@' {
i++
}
if i+6 < n && emailID[i+1:i+6] == "gmail" && i+10 <= n && emailID[i+7:i+10] == "com" {
names = append(names, firstName)
}
}
sort.Strings(names)
for i := 0; i < len(names); i++ {
fmt.Println(names[i])
}
}
func readLine(reader *bufio.Reader) string {
str, _, err := reader.ReadLine()
if err == io.EOF {
return ""
}
return strings.TrimRight(string(str), "\r\n")
}
func checkError(err error) {
if err != nil {
panic(err)
}
}