Created
October 7, 2016 20:02
-
-
Save smithjessk/b54326ef49ab45f376e9b005292b8c7f to your computer and use it in GitHub Desktop.
Generating a test case for http://www.spoj.com/problems/BSEARCH1/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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