Skip to content

Instantly share code, notes, and snippets.

@smithjessk
Created October 7, 2016 20:02
Show Gist options
  • Save smithjessk/b54326ef49ab45f376e9b005292b8c7f to your computer and use it in GitHub Desktop.
Save smithjessk/b54326ef49ab45f376e9b005292b8c7f to your computer and use it in GitHub Desktop.
Generating a test case for http://www.spoj.com/problems/BSEARCH1/
package main
import (
"fmt"
"math"
"math/rand"
"os"
)
func main() {
n := int(math.Pow10(5))
q := 5 * int(math.Pow10(5))
numString := string(rand.Int()) + ""
for i := 1; i < n; i++ {
numString = fmt.Sprintf("%s %d", numString, rand.Int())
}
file, _ := os.Create("./test")
file.WriteString(fmt.Sprintf("%d %d\n", n, q))
file.WriteString(numString + "\n")
for i := 0; i < q; i++ {
file.WriteString(fmt.Sprintf("%d\n", rand.Int()))
}
file.Close()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment