aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-03-28 15:11:08 -0500
committerAnthony Wang2022-03-28 15:11:08 -0500
commit8962c6b9a0be9af51e06bf2b363e5e3974f7de6b (patch)
treec7b4cb9d4b2b54bda23976a4e772b4fd4bc57d2d
parent5719668a81ac212720f6266e9bf184d318b36b3a (diff)
Use seg[1] to keep track of sum instead of a sum var
-rw-r--r--sd.go6
1 files changed, 1 insertions, 5 deletions
diff --git a/sd.go b/sd.go
index f466f6b..0368e70 100644
--- a/sd.go
+++ b/sd.go
@@ -79,7 +79,6 @@ func main() {
panic(err)
}
s.build(rows, 0, N-1, 1)
- sum := s.seg[1]
rows.Close()
if *verbose {
@@ -96,11 +95,10 @@ func main() {
for {
// Choose a random card
- x := rand.Intn(sum)
+ x := rand.Intn(s.seg[1])
w, i := s.query(x, 0, N-1, 1)
if *verbose {
- fmt.Println(sum)
fmt.Println(x)
fmt.Println(w)
fmt.Println(i)
@@ -120,9 +118,7 @@ func main() {
os.Stdin.Read(b)
if b[0] == byte('y') {
w >>= 1
- sum -= w
} else if b[0] == byte('n') {
- sum += w
w <<= 1
} else {
os.Exit(0)