summaryrefslogtreecommitdiff
path: root/capset.go
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2014-07-02 10:09:04 -0500
committerJoe Anderson <jandew+dev@gmail.com>2014-07-02 10:10:03 -0500
commit85f763714aa2b71053b3d03bbe1612fd27cfa780 (patch)
tree2a1b7d0bd4b9122f17b941edf4d22feb49d0aea4 /capset.go
parent565dd814caa4efe601db2ae55c8fdb8291c8c4bc (diff)
downloadcapset-85f763714aa2b71053b3d03bbe1612fd27cfa780.tar.gz
capset-85f763714aa2b71053b3d03bbe1612fd27cfa780.zip
Added arg parsing and test case, fixed an ungeneralized 18
Diffstat (limited to 'capset.go')
-rw-r--r--capset.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/capset.go b/capset.go
index f28484a..0f5af79 100644
--- a/capset.go
+++ b/capset.go
@@ -11,6 +11,8 @@ import (
"log"
"math"
"os"
+ "flag"
+ "strconv"
)
var maximForDim = []int{1, 2, 4, 9, 20, 45, 112, 236}
@@ -157,7 +159,7 @@ func (cs *Capset) incrementTableau() bool {
index = cs.d.card2int(cs.popTableau()) + 1
if len(cs.tableau) == 1 {
fmt.Println("incrementing second card to index", index)
- if index+18 > len(cs.d.cards) {
+ if index+cs.maxim-2 > len(cs.d.cards) {
return false
}
}
@@ -274,7 +276,17 @@ func loadFromSave(d *Deck) *Capset {
}
func main() {
- d := NewDeck(4)
+ flag.Parse()
+ args := flag.Args()
+ if len(args) != 1 {
+ fmt.Println("Usage: capset dim\n\tdim int := number of dimensions/attributes")
+ log.Fatal("Improper Usage")
+ }
+ dim, err := strconv.Atoi(args[0])
+ if err != nil {
+ log.Fatal(err)
+ }
+ d := NewDeck(dim)
cs := loadFromSave(d)
if cs == nil {
cs = NewCapset(d, -1)