Created
October 26, 2017 14:12
-
-
Save cipepser/817e4f2f21365f6871e98e1f25dfc2a5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"os" | |
"strings" | |
) | |
type key struct { | |
t, c string | |
} | |
func main() { | |
f, err := os.Open("../data/q82.out.txt") | |
defer f.Close() | |
if err != nil { | |
panic(err) | |
} | |
r := bufio.NewReaderSize(f, 4096) | |
m := make(map[key]int) | |
Nt := make(map[string]int) | |
Nc := make(map[string]int) | |
for { | |
l, _, err := r.ReadLine() | |
if err == io.EOF { | |
break | |
} | |
if err != nil { | |
panic(err) | |
} | |
str := strings.Split(string(l), "\t") | |
k := key{ | |
t: str[0], | |
c: str[1], | |
} | |
m[k]++ | |
Nt[k.t]++ | |
Nc[k.c]++ | |
} | |
fmt.Println("N: ", len(m)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment