I'm coding in python and I'm trying to use a different random string for each value of x in my summation.
My code so far is:
from sympy import summation, Piecewise, symbols, Eq, Ge,solve, Le,Mod
import random
import string
x = symbols('x')
def generate_random_string(args,min_length, max_length):
random.seed(args)
length = random.randint(min_length, max_length)
characters = string.printable.strip()
if random.seed: # where I want to say to use a different random string according to a different seed each tie or something
result = 1
return ''.join(random.choices(characters, k=length))
def checksum1(args2):
result = args2
try:
account = int(result,16) #to test how many random numbers are hexadecimal (I need it this way)
return 1
except Exception:
return 0 #returns the result of point add
logic = checksum1(generate_random_string(x,40,100))
m = Piecewise(
(logic, Eq(logic, 1)),
(0, True)
)
result = summation(m, (x, 1, (2**100) ** 6))
print(result)
As you can see by this code, I'm generating a random string and I'm testing it with int(,16) to see how many numbers are hexadecimal out of all the different combinations.
The code only uses one random string right now. In the if statement in the generate combinations function I want to tell it that if x changes, use a different random string.
Can someone show me how to do this? right now it's just returning 0 because it uses the same random string each time.