Skip to content

Instantly share code, notes, and snippets.

@cipepser
Created October 26, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cipepser/817e4f2f21365f6871e98e1f25dfc2a5 to your computer and use it in GitHub Desktop.
Save cipepser/817e4f2f21365f6871e98e1f25dfc2a5 to your computer and use it in GitHub Desktop.
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