WeixiangYan/CodeTransOcean huggingface dataset:
Task: Distribution of 0 digits in factorial series




Go: package main

import (
    "fmt"
    big "github.com/ncw/gmp"
    "rcu"
)

func main() {
    fact  := big.NewInt(1)
    sum   := 0.0
    first := int64(0)
    firstRatio := 0.0    
    fmt.Println("The mean proportion of zero digits in factorials up to the following are:")
    for n := int64(1); n <= 50000; n++  {
        fact.Mul(fact, big.NewInt(n))
        bytes  := []byte(fact.String())
        digits := len(bytes)
        zeros  := 0
        for _, b := range bytes {
            if b == '0' {
                zeros++
            }
        }
        sum += float64(zeros)/float64(digits)
        ratio := sum / float64(n)
        if n == 100 || n == 1000 || n == 10000 {
            fmt.Printf("%6s = %12.10f\n", rcu.Commatize(int(n)), ratio)
        } 
        if first > 0 && ratio >= 0.16 {
            first = 0
            firstRatio = 0.0
        } else if first == 0 && ratio < 0.16 {
            first = n
            firstRatio = ratio           
        }
    }
    fmt.Printf("%6s = %12.10f", rcu.Commatize(int(first)), firstRatio)
    fmt.Println(" (stays below 0.16 after this)")
    fmt.Printf("%6s = %12.10f\n", "50,000", sum / 50000)
}
Task: Execute CopyPasta Language




Go: 
package main

import (
    "fmt"
    "github.com/atotto/clipboard"
    "io/ioutil"
    "log"
    "os"
    "runtime"
    "strconv"
    "strings"
)

func check(err error) {
    if err != nil {
        clipboard.WriteAll("") 
        log.Fatal(err)
    }
}

func interpret(source string) {
    source2 := source
    if runtime.GOOS == "windows" {
        source2 = strings.ReplaceAll(source, "\r\n", "\n")
    }
    lines := strings.Split(source2, "\n")
    le := len(lines)
    for i := 0; i < le; i++ {
        lines[i] = strings.TrimSpace(lines[i]) 
        switch lines[i] {
        case "Copy":
            if i == le-1 {
                log.Fatal("There are no lines after the Copy command.")
            }
            i++
            err := clipboard.WriteAll(lines[i])
            check(err)
        case "CopyFile":
            if i == le-1 {
                log.Fatal("There are no lines after the CopyFile command.")
            }
            i++
            if lines[i] == "TheF*ckingCode" {
                err := clipboard.WriteAll(source)
                check(err)                
            } else {
                bytes, err := ioutil.ReadFile(lines[i])
                check(err)
                err = clipboard.WriteAll(string(bytes))
                check(err)                
            }
        case "Duplicate":
            if i == le-1 {
                log.Fatal("There are no lines after the Duplicate command.")
            }
            i++
            times, err := strconv.Atoi(lines[i])
            check(err)
            if times < 0 {
                log.Fatal("Can't duplicate text a negative number of times.")
            }
            text, err := clipboard.ReadAll()
            check(err)
            err = clipboard.WriteAll(strings.Repeat(text, times+1))
            check(err)
        case "Pasta!":
            text, err := clipboard.ReadAll()
            check(err)
            fmt.Println(text)
            return
        default:
            if lines[i] == "" {
                continue 
            }
            log.Fatal("Unknown command, " + lines[i])
        }
    }
}

func main() {
    if len(os.Args) != 2 {
        log.Fatal("There should be exactly one command line argument, the CopyPasta file path.")
    }
    bytes, err := ioutil.ReadFile(os.Args[1])
    check(err)
    interpret(string(bytes))
    err = clipboard.WriteAll("") 
    check(err)
}
Task: Suffixation of decimal numbers




Go: package main

import (
    "fmt"
    "math/big"
    "strconv"
    "strings"
)

var suffixes = " KMGTPEZYXWVU"
var ggl = googol()

func googol() *big.Float {
    g1 := new(big.Float).SetPrec(500)
    g1.SetInt64(10000000000)
    g := new(big.Float)
    g.Set(g1)
    for i := 2; i <= 10; i++ {
        g.Mul(g, g1)
    }
    return g
}

func suffize(arg string) {
    fields := strings.Fields(arg)
    a := fields[0]
    if a == "" {
        a = "0"
    }
    var places, base int
    var frac, radix string
    switch len(fields) {
    case 1:
        places = -1
        base = 10
    case 2:
        places, _ = strconv.Atoi(fields[1])
        base = 10
        frac = strconv.Itoa(places)
    case 3:
        if fields[1] == "," {
            places = 0
            frac = ","
        } else {
            places, _ = strconv.Atoi(fields[1])
            frac = strconv.Itoa(places)
        }
        base, _ = strconv.Atoi(fields[2])
        if base != 2 && base != 10 {
            base = 10
        }
        radix = strconv.Itoa(base)
    }
    a = strings.Replace(a, ",", "", -1) 
    sign := ""
    if a[0] == '+' || a[0] == '-' {
        sign = string(a[0])
        a = a[1:] 
    }
    b := new(big.Float).SetPrec(500)
    d := new(big.Float).SetPrec(500)
    b.SetString(a)
    g := false
    if b.Cmp(ggl) >= 0 {
        g = true
    }
    if !g && base == 2 {
        d.SetUint64(1024)
    } else if !g && base == 10 {
        d.SetUint64(1000)
    } else {
        d.Set(ggl)
    }
    c := 0
    for b.Cmp(d) >= 0 && c < 12 { 
        b.Quo(b, d)
        c++
    }
    var suffix string
    if !g {
        suffix = string(suffixes[c])
    } else {
        suffix = "googol"
    }
    if base == 2 {
        suffix += "i"
    }
    fmt.Println("   input number =", fields[0])
    fmt.Println("  fraction digs =", frac)
    fmt.Println("specified radix =", radix)
    fmt.Print("     new number = ")
    if places >= 0 {
        fmt.Printf("%s%.*f%s\n", sign, places, b, suffix)
    } else {
        fmt.Printf("%s%s%s\n", sign, b.Text('g', 50), suffix)
    }
    fmt.Println()
}

func main() {
    tests := []string{
        "87,654,321",
        "-998,877,665,544,332,211,000      3",
        "+112,233                          0",
        "16,777,216                        1",
        "456,789,100,000,000",
        "456,789,100,000,000               2      10",
        "456,789,100,000,000               5       2",
        "456,789,100,000.000e+00           0      10",
        "+16777216                         ,       2",
        "1.2e101",
        "446,835,273,728                   1",
        "1e36",
        "1e39", 
    }
    for _, test := range tests {
        suffize(test)
    }
}
Task: Resistance network calculator




Go: package main

import (
    "fmt"
    "math"
    "strconv"
    "strings"
)

func argmax(m [][]float64, i int) int {
    col := make([]float64, len(m))
    max, maxx := -1.0, -1
    for x := 0; x < len(m); x++ {
        col[x] = math.Abs(m[x][i])
        if col[x] > max {
            max = col[x]
            maxx = x
        }
    }
    return maxx
}

func gauss(m [][]float64) []float64 {
    n, p := len(m), len(m[0])
    for i := 0; i < n; i++ {
        k := i + argmax(m[i:n], i)
        m[i], m[k] = m[k], m[i]
        t := 1 / m[i][i]
        for j := i + 1; j < p; j++ {
            m[i][j] *= t
        }
        for j := i + 1; j < n; j++ {
            t = m[j][i]
            for l := i + 1; l < p; l++ {
                m[j][l] -= t * m[i][l]
            }
        }
    }
    for i := n - 1; i >= 0; i-- {
        for j := 0; j < i; j++ {
            m[j][p-1] -= m[j][i] * m[i][p-1]
        }
    }
    col := make([]float64, len(m))
    for x := 0; x < len(m); x++ {
        col[x] = m[x][p-1]
    }
    return col
}

func network(n, k0, k1 int, s string) float64 {
    m := make([][]float64, n)
    for i := 0; i < n; i++ {
        m[i] = make([]float64, n+1)
    }
    for _, resistor := range strings.Split(s, "|") {
        rarr := strings.Fields(resistor)
        a, _ := strconv.Atoi(rarr[0])
        b, _ := strconv.Atoi(rarr[1])
        ri, _ := strconv.Atoi(rarr[2])
        r := 1.0 / float64(ri)
        m[a][a] += r
        m[b][b] += r
        if a > 0 {
            m[a][b] -= r
        }
        if b > 0 {
            m[b][a] -= r
        }
    }
    m[k0][k0] = 1
    m[k1][n] = 1
    return gauss(m)[k1]
}

func main() {
    var fa [4]float64
    fa[0] = network(7, 0, 1, "0 2 6|2 3 4|3 4 10|4 5 2|5 6 8|6 1 4|3 5 6|3 6 6|3 1 8|2 1 8")
    fa[1] = network(9, 0, 8, "0 1 1|1 2 1|3 4 1|4 5 1|6 7 1|7 8 1|0 3 1|3 6 1|1 4 1|4 7 1|2 5 1|5 8 1")
    fa[2] = network(16, 0, 15, "0 1 1|1 2 1|2 3 1|4 5 1|5 6 1|6 7 1|8 9 1|9 10 1|10 11 1|12 13 1|13 14 1|14 15 1|0 4 1|4 8 1|8 12 1|1 5 1|5 9 1|9 13 1|2 6 1|6 10 1|10 14 1|3 7 1|7 11 1|11 15 1")
    fa[3] = network(4, 0, 3, "0 1 150|0 2 50|1 3 300|2 3 250")
    for _, f := range fa {
        fmt.Printf("%.6g\n", f)
    }
}
Task: Resistance calculator




Go: package main

import "fmt"

type Resistor struct {
    symbol              rune
    resistance, voltage float64
    a, b                *Resistor
}

func (r *Resistor) res() float64 {
    switch r.symbol {
    case '+':
        return r.a.res() + r.b.res()
    case '*':
        return 1 / (1/r.a.res() + 1/r.b.res())
    default:
        return r.resistance
    }
}

func (r *Resistor) setVoltage(voltage float64) {
    switch r.symbol {
    case '+':
        ra := r.a.res()
        rb := r.b.res()
        r.a.setVoltage(ra / (ra + rb) * voltage)
        r.b.setVoltage(rb / (ra + rb) * voltage)
    case '*':
        r.a.setVoltage(voltage)
        r.b.setVoltage(voltage)
    }
    r.voltage = voltage
}

func (r *Resistor) current() float64 {
    return r.voltage / r.res()
}

func (r *Resistor) effect() float64 {
    return r.current() * r.voltage
}

func (r *Resistor) report(level string) {
    fmt.Printf("%8.3f %8.3f %8.3f %8.3f  %s%c\n", r.res(), r.voltage, r.current(), r.effect(), level, r.symbol)
    if r.a != nil {
        r.a.report(level + "| ")
    }
    if r.b != nil {
        r.b.report(level + "| ")
    }
}

func (r *Resistor) add(other *Resistor) *Resistor {
    return &Resistor{'+', 0, 0, r, other}
}

func (r *Resistor) mul(other *Resistor) *Resistor {
    return &Resistor{'*', 0, 0, r, other}
}

func main() {
    var r [10]*Resistor
    resistances := []float64{6, 8, 4, 8, 4, 6, 8, 10, 6, 2}
    for i := 0; i < 10; i++ {
        r[i] = &Resistor{'r', resistances[i], 0, nil, nil}
    }
    node := r[7].add(r[9]).mul(r[8]).add(r[6]).mul(r[5]).add(r[4]).mul(r[3]).add(r[2]).mul(r[1]).add(r[0])
    node.setVoltage(18)
    fmt.Println("     Ohm     Volt   Ampere     Watt  Network tree")
    node.report("")
}
Task: Smallest enclosing circle problem




Go: package main

import (
    "fmt"
    "log"
    "math"
    "math/rand"
    "time"
)

type Point struct{ x, y float64 }

type Circle struct {
    c Point
    r float64
}


func (p Point) String() string { return fmt.Sprintf("(%f, %f)", p.x, p.y) }


func distSq(a, b Point) float64 {
    return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y)
}


func getCircleCenter(bx, by, cx, cy float64) Point {
    b := bx*bx + by*by
    c := cx*cx + cy*cy
    d := bx*cy - by*cx
    return Point{(cy*b - by*c) / (2 * d), (bx*c - cx*b) / (2 * d)}
}


func (ci Circle) contains(p Point) bool {
    return distSq(ci.c, p) <= ci.r*ci.r
}


func (ci Circle) encloses(ps []Point) bool {
    for _, p := range ps {
        if !ci.contains(p) {
            return false
        }
    }
    return true
}


func (ci Circle) String() string { return fmt.Sprintf("{%v, %f}", ci.c, ci.r) }


func circleFrom3(a, b, c Point) Circle {
    i := getCircleCenter(b.x-a.x, b.y-a.y, c.x-a.x, c.y-a.y)
    i.x += a.x
    i.y += a.y
    return Circle{i, math.Sqrt(distSq(i, a))}
}


func circleFrom2(a, b Point) Circle {
    c := Point{(a.x + b.x) / 2, (a.y + b.y) / 2}
    return Circle{c, math.Sqrt(distSq(a, b)) / 2}
}


func secTrivial(rs []Point) Circle {
    size := len(rs)
    if size > 3 {
        log.Fatal("There shouldn't be more than 3 points.")
    }
    if size == 0 {
        return Circle{Point{0, 0}, 0}
    }
    if size == 1 {
        return Circle{rs[0], 0}
    }
    if size == 2 {
        return circleFrom2(rs[0], rs[1])
    }
    for i := 0; i < 2; i++ {
        for j := i + 1; j < 3; j++ {
            c := circleFrom2(rs[i], rs[j])
            if c.encloses(rs) {
                return c
            }
        }
    }
    return circleFrom3(rs[0], rs[1], rs[2])
}


func welzlHelper(ps, rs []Point, n int) Circle {
    rc := make([]Point, len(rs))
    copy(rc, rs) 
    if n == 0 || len(rc) == 3 {
        return secTrivial(rc)
    }
    idx := rand.Intn(n)
    p := ps[idx]
    ps[idx], ps[n-1] = ps[n-1], p
    d := welzlHelper(ps, rc, n-1)
    if d.contains(p) {
        return d
    }
    rc = append(rc, p)
    return welzlHelper(ps, rc, n-1)
}


func welzl(ps []Point) Circle {
    var pc = make([]Point, len(ps))
    copy(pc, ps)
    rand.Shuffle(len(pc), func(i, j int) {
        pc[i], pc[j] = pc[j], pc[i]
    })
    return welzlHelper(pc, []Point{}, len(pc))
}

func main() {
    rand.Seed(time.Now().UnixNano())
    tests := [][]Point{
        {Point{0, 0}, Point{0, 1}, Point{1, 0}},
        {Point{5, -2}, Point{-3, -2}, Point{-2, 5}, Point{1, 6}, Point{0, 2}},
    }
    for _, test := range tests {
        fmt.Println(welzl(test))
    }
}
Task: Upside-down numbers




Go: package main

import (
    "fmt"
    "rcu"
)

func genUpsideDown(limit int) chan int {
    ch := make(chan int)
    wrappings := [][2]int{
        {1, 9}, {2, 8}, {3, 7}, {4, 6}, {5, 5},
        {6, 4}, {7, 3}, {8, 2}, {9, 1},
    }
    evens := []int{19, 28, 37, 46, 55, 64, 73, 82, 91}
    odds := []int{5}
    oddIndex := 0
    evenIndex := 0
    ndigits := 1
    pow := 100
    count := 0
    go func() {
        for count < limit {
            if ndigits%2 == 1 {
                if len(odds) > oddIndex {
                    ch <- odds[oddIndex]
                    count++
                    oddIndex++
                } else {
                    
                    var nextOdds []int
                    for _, w := range wrappings {
                        for _, i := range odds {
                            nextOdds = append(nextOdds, w[0]*pow+i*10+w[1])
                        }
                    }
                    odds = nextOdds
                    ndigits++
                    pow *= 10
                    oddIndex = 0
                }
            } else {
                if len(evens) > evenIndex {
                    ch <- evens[evenIndex]
                    count++
                    evenIndex++
                } else {
                    
                    var nextEvens []int
                    for _, w := range wrappings {
                        for _, i := range evens {
                            nextEvens = append(nextEvens, w[0]*pow+i*10+w[1])
                        }
                    }
                    evens = nextEvens
                    ndigits++
                    pow *= 10
                    evenIndex = 0
                }
            }
        }
        close(ch)
    }()
    return ch
}

func main() {
    const limit = 50_000_000
    count := 0
    var ud50s []int
    pow := 50
    for n := range genUpsideDown(limit) {
        count++
        if count < 50 {
            ud50s = append(ud50s, n)
        } else if count == 50 {
            ud50s = append(ud50s, n)
            fmt.Println("First 50 upside down numbers:")
            rcu.PrintTable(ud50s, 10, 5, true)
            fmt.Println()
            pow = 500
        } else if count == pow {
            fmt.Printf("%sth : %s\n", rcu.Commatize(pow), rcu.Commatize(n))
            pow *= 10
        }
    }
}
Task: Price list behind API




Go: package main

import (
    "fmt"
    "log"
    "math"
    "math/rand"
    "time"
)

var minDelta = 1.0

func getMaxPrice(prices []float64) float64 {
    max := prices[0]
    for i := 1; i < len(prices); i++ {
        if prices[i] > max {
            max = prices[i]
        }
    }
    return max
}

func getPRangeCount(prices []float64, min, max float64) int {
    count := 0
    for _, price := range prices {
        if price >= min && price <= max {
            count++
        }
    }
    return count
}

func get5000(prices []float64, min, max float64, n int) (float64, int) {
    count := getPRangeCount(prices, min, max)
    delta := (max - min) / 2
    for count != n && delta >= minDelta/2 {
        if count > n {
            max -= delta
        } else {
            max += delta
        }
        max = math.Floor(max)
        count = getPRangeCount(prices, min, max)
        delta /= 2
    }
    return max, count
}

func getAll5000(prices []float64, min, max float64, n int) [][3]float64 {
    pmax, pcount := get5000(prices, min, max, n)
    res := [][3]float64{{min, pmax, float64(pcount)}}
    for pmax < max {
        pmin := pmax + 1
        pmax, pcount = get5000(prices, pmin, max, n)
        if pcount == 0 {
            log.Fatal("Price list from", pmin, "has too many with same price.")
        }
        res = append(res, [3]float64{pmin, pmax, float64(pcount)})
    }
    return res
}

func main() {
    rand.Seed(time.Now().UnixNano())
    numPrices := 99000 + rand.Intn(2001)
    maxPrice := 1e5
    prices := make([]float64, numPrices) 
    for i := 0; i < numPrices; i++ {
        prices[i] = float64(rand.Intn(int(maxPrice) + 1))
    }
    actualMax := getMaxPrice(prices)
    fmt.Println("Using", numPrices, "items with prices from 0 to", actualMax, "\b:")
    res := getAll5000(prices, 0, actualMax, 5000)
    fmt.Println("Split into", len(res), "bins of approx 5000 elements:")
    total := 0
    for _, r := range res {
        min := int(r[0])
        tmx := r[1]
        if tmx > actualMax {
            tmx = actualMax
        }
        max := int(tmx)
        cnt := int(r[2])
        total += cnt
        fmt.Printf("   From %6d to %6d with %4d items\n", min, max, cnt)
    }
    if total != numPrices {
        fmt.Println("Something went wrong - grand total of", total, "doesn't equal", numPrices, "\b!")
    }
}
Task: Text to HTML




Go: package main

import (
    "fmt"
    "html"
    "regexp"
    "strings"
)

var t = `     Sample Text

This is an example of converting plain text to HTML which demonstrates extracting a title and escaping certain characters within bulleted and numbered lists.

* This is a bulleted list with a less than sign (<)

* And this is its second line with a greater than sign (>)

A 'normal' paragraph between the lists. 

1. This is a numbered list with an ampersand (&)

2. "Second line" in double quotes

3. 'Third line' in single quotes

That's all folks.`

func main() {
    p := regexp.MustCompile(`\n\s*(\n\s*)+`)
    ul := regexp.MustCompile(`^\*`)
    ol := regexp.MustCompile(`^\d\.`)
    t = html.EscapeString(t) 
    paras := p.Split(t, -1)

    
    
    firstChar := paras[0][0]
    title := "Untitled"
    k := 0
    if firstChar == ' ' || firstChar == '\t' {
        title = strings.TrimSpace(paras[0])
        k = 1
    }
    fmt.Println("<html>")
    fmt.Printf("<head><title>%s</title></head>\n", title)
    fmt.Println("<body>")

    blist := false
    nlist := false
    for _, para := range paras[k:] {
        para2 := strings.TrimSpace(para)

        if ul.MatchString(para2) {
            if !blist {
                blist = true
                fmt.Println("<ul>")
            }
            para2 = strings.TrimSpace(para2[1:])
            fmt.Printf("  <li>%s</li>\n", para2)
            continue
        } else if blist {
            blist = false
            fmt.Println("</ul>")
        }

        if ol.MatchString(para2) {
            if !nlist {
                nlist = true
                fmt.Println("<ol>")
            }
            para2 = strings.TrimSpace(para2[2:])
            fmt.Printf("  <li>%s</li>\n", para2)
            continue
        } else if nlist {
            nlist = false
            fmt.Println("</ol>")
        }

        if !blist && !nlist {
            fmt.Printf("<p>%s</p>\n", para2)
        }
    }
    if blist {
        fmt.Println("</ul>")
    }
    if nlist {
        fmt.Println("</ol>")
    }
    fmt.Println("</body>")
    fmt.Println("</html>")
}
Task: Smallest number k such that k+2^m is composite for all m less than k




Go: package main

import (
    "fmt"
    big "github.com/ncw/gmp"
)


func a(k int64) bool {
    if k == 1 {
        return false
    }
    bk := big.NewInt(k)
    for m := uint(1); m < uint(k); m++ {
        n := big.NewInt(1)
        n.Lsh(n, m)
        n.Add(n, bk)
        if n.ProbablyPrime(15) {
            return false
        }
    }
    return true
}

func main() {
    count := 0
    k := int64(1)
    for count < 5 {
        if a(k) {
            fmt.Printf("%d ", k)
            count++
        }
        k += 2
    }
    fmt.Println()
}
Task: Checksumcolor




Go: package main

import (
    "bufio"
    "fmt"
    "golang.org/x/crypto/ssh/terminal"
    "log"
    "os"
    "regexp"
    "strconv"
)

type Color struct{ r, g, b int }

type ColorEx struct {
    color Color
    code  string
}

var colors = []ColorEx{
    {Color{15, 0, 0}, "31"},
    {Color{0, 15, 0}, "32"},
    {Color{15, 15, 0}, "33"},
    {Color{0, 0, 15}, "34"},
    {Color{15, 0, 15}, "35"},
    {Color{0, 15, 15}, "36"},
}

func squareDist(c1, c2 Color) int {
    xd := c2.r - c1.r
    yd := c2.g - c1.g
    zd := c2.b - c1.b
    return xd*xd + yd*yd + zd*zd
}

func printColor(s string) {
    n := len(s)
    k := 0
    for i := 0; i < n/3; i++ {
        j := i * 3
        c1 := s[j]
        c2 := s[j+1]
        c3 := s[j+2]
        k = j + 3
        r, err := strconv.ParseInt(fmt.Sprintf("0x%c", c1), 0, 64)
        check(err)
        g, err := strconv.ParseInt(fmt.Sprintf("0x%c", c2), 0, 64)
        check(err)
        b, err := strconv.ParseInt(fmt.Sprintf("0x%c", c3), 0, 64)
        check(err)
        rgb := Color{int(r), int(g), int(b)}
        m := 676
        colorCode := ""
        for _, cex := range colors {
            sqd := squareDist(cex.color, rgb)
            if sqd < m {
                colorCode = cex.code
                m = sqd
            }
        }
        fmt.Printf("\033[%s;1m%c%c%c\033[00m", colorCode, c1, c2, c3)
    }
    for j := k; j < n; j++ {
        c := s[j]
        fmt.Printf("\033[0;1m%c\033[00m", c)
    }
}

var (
    r       = regexp.MustCompile("^([A-Fa-f0-9]+)([ \t]+.+)$")
    scanner = bufio.NewScanner(os.Stdin)
    err     error
)

func colorChecksum() {
    for scanner.Scan() {
        line := scanner.Text()
        if r.MatchString(line) {
            submatches := r.FindStringSubmatch(line)
            s1 := submatches[1]
            s2 := submatches[2]
            printColor(s1)
            fmt.Println(s2)
        } else {
            fmt.Println(line)
        }
    }
    check(scanner.Err())
}

func cat() {
    for scanner.Scan() {
        line := scanner.Text()
        fmt.Println(line)
    }
    check(scanner.Err())
}

func check(err error) {
    if err != nil {
        log.Fatal(err)
    }
}

func main() {
    if terminal.IsTerminal(int(os.Stdout.Fd())) {
        colorChecksum()
    } else {
        cat()
    }
}