-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (40 loc) · 784 Bytes
/
main.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"aziflaj/cardcompress/cardistry"
"bytes"
"encoding/binary"
"fmt"
"os"
)
func writeToFile(filename string, data any) error {
file, err := os.Create(filename)
if err != nil {
return err
}
defer file.Close()
buf := new(bytes.Buffer)
err = binary.Write(file, binary.LittleEndian, data)
if err != nil {
return err
}
file.Write(buf.Bytes())
return nil
}
func main() {
deck := cardistry.NewDeck()
deck.Shuffle()
fmt.Println(deck)
sign, tally := deck.Compress()
fmt.Println(tally)
err := writeToFile("tally.bin", tally)
if err != nil {
panic(err)
}
matrix := cardistry.NewColorSeq(sign, tally)
fmt.Println(matrix)
err = writeToFile("matrix.bin", matrix.Frame)
if err != nil {
panic(err)
}
fmt.Println(matrix.Decompress())
}