Files
tools/rand/main.py
flt6 606861b3a1 update
Former-commit-id: 8d2717060dc7314535a6422433dab9027b830b4f
Former-commit-id: 159f1cb3ea98a03db9bfad177cdf25b5b953b10a
2022-09-23 10:29:05 +08:00

29 lines
721 B
Python

from random import randint
bgn,end=[int(i) for i in input("Option: Input random area(like 21-43): ").split("-")]
obj=int(input("Option: Amount: "))
repeat=input("Option: Allow repeat:\nAccept: T(true) (defalt), F(false)\n").lower()
if repeat == "":
repeat=True
else:
if repeat in ["t","true"]:
repeat=True
elif repeat in ["f","false"]:
repeat=False
else:
input("Unsupported option.")
l=[]
if repeat:
l=[randint(bgn,end) for i in range(obj)]
else:
i=0
while len(l)<obj and i<500:
t=randint(bgn,end)
i+=1
if t not in l:
l.append(t)
print(l)
for i in l[1:]:
print(randint(bgn,end),end=", ")
print(l[0])