-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
33 lines (30 loc) · 775 Bytes
/
main.go
File metadata and controls
33 lines (30 loc) · 775 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
package main
import (
"log"
"math"
"strconv"
//"flag"
"flag"
)
func main() {
var file = flag.String("file", "input.txt", "path to the input file")
var subFileCount = flag.Int("count", 10, "number of sub files")
flag.Parse()
var nonRepeatedIndex int64 = math.MaxInt64
var nonRepeatedString = ""
files := splitHugeFileToN(*file, *subFileCount)
// for-range files and find the non-repeated string
for i, f := range files {
for k, v := range readFileToWordMap(f.Name()) {
if v.count == 1 {
ind, _ := strconv.ParseInt(v.index, 10, 64)
if ind < nonRepeatedIndex {
nonRepeatedIndex = ind
nonRepeatedString = k
}
}
}
files[i].Close()
}
log.Printf("first non repeated str is %s, index is %d", nonRepeatedString, nonRepeatedIndex)
}