''' Purpose: demonstrate a primitive 'random' digit generator ''' SCALAR = 3141592653589793 * 2718281828459045 * 16180339887 # set the seed of the black box based on the length of what the user supplies reply = input( 'Enter something: ' ) seed = ( len( reply ) + 1 ) * 7 # generate initial value from which to grab the 'random' digit s = seed * SCALAR s = str( s ) # store the generated digits in digits digits = [] # let's generate 20 digits for i in range( 0, 20 ) : # grab and save the middle digit of s n = len( s ) d = s [ n // 2 ] d = int( d ) digits.append( d ) # generate a new s by first decomposing it into thirds a = s[ 0 : n // 3 ] b = s[ n // 3 : 2 * n // 3 ] c = s[ 2 * n // 3 : ] # get rid of leading and trailing 0's of the thirds a = a.strip( '0' ) b = b.strip( '0' ) c = c.strip( '0' ) # convert the thirds into int's a = int( a ) b = int( b ) c = int( c ) # new s is initially the product of thirds times the SCALAR s = ( a * b * c * SCALAR ) # convert product to a string s = str( s ) # to keep process manageable hang onto only the middle fifty characters of s n = len( s ) s = s[ n // 2 - 25 : n // 2 + 25 ] # let's see what we got print() print( digits )