-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathtask.go
More file actions
40 lines (32 loc) · 575 Bytes
/
task.go
File metadata and controls
40 lines (32 loc) · 575 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
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"strings"
)
func main() {
var inp = GetInputFromFile()
defer inp.Close()
reader := bufio.NewReader(inp)
str, _ := reader.ReadString('\n')
str = strings.ToLower(str)
re := regexp.MustCompile("[^a-z]")
str = re.ReplaceAllString(str, "")
var result = "True"
for i := 0; i < len(str); i++ {
if str[i] != str[len(str)-(i+1)] {
result = "False"
break
}
}
fmt.Println(result)
}
func GetInputFromFile() *os.File {
file, err := os.Open("./input.txt")
if err != nil {
panic(err)
}
return file
}