update20140630
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import random
|
||||
import sys
|
||||
|
||||
def createCommand(joins, joinRate):
|
||||
nextLeaveNumber = 2
|
||||
joinCount = 0
|
||||
commands = []
|
||||
while joinCount < joins:
|
||||
if random.random() < joinRate:
|
||||
commands.append("J")
|
||||
joinCount += 1
|
||||
elif nextLeaveNumber < joinCount:
|
||||
commands.append("L" + repr(nextLeaveNumber))
|
||||
nextLeaveNumber += 1
|
||||
resultStr = ""
|
||||
resultStr += "###\n"
|
||||
jsString = "{"
|
||||
index = 0
|
||||
for command in commands:
|
||||
jsString += "\"" + repr(index) + "\":\"" + command + "\","
|
||||
index += 1
|
||||
resultStr += command + "\n"
|
||||
jsString = jsString[:-1] + "}"
|
||||
|
||||
resultStr += "###" + "\n"
|
||||
resultStr += jsString + "\n"
|
||||
|
||||
return resultStr
|
||||
if __name__ == "__main__":
|
||||
createCommand(int(sys.argv[1]), float(sys.argv[2]))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user