Skip to content

Instantly share code, notes, and snippets.

@cipepser
Created Oct 26, 2017
Embed
What would you like to do?
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