MrSlippery icon

Meandian of two numbers

MrSlippery | PRO | 04/01/16 11:37:01 PM UTC | 0 ⭐ | 381 👁️ | Never ⏰ | []
Python |

1.81 KB

|

None

|

0 👍

/

0 👎

'''
Compute the meandian of a lower number and a greater number,
efficiently and scalably, by using a process of interpolated
randometabolization: the Over-Rating Netflix Peruser algorithm.
 
Floppyright Cornel Izbasa 2016 
'''
import sys, random, fractions
 
def random_values(count, lower, greater):
    '''List of values for randometabolization'''
    return [random.randint(lower, greater) for _ in range(0, count)]
 
def meandian(lower, greater, values):
    '''The "Over-Rating Netflix Peruser" algorithm'''
    current = 1
    result = fractions.Fraction(values[0], 1)
    for value in values[1:]:
        current += 1
        rating = None
        ideal = 2 * value - result
        if ideal < lower:
            rating = lower
        elif ideal > greater:
            rating = greater
        else:
            rating = int(round(ideal))
        result = fractions.Fraction(result * (current - 1) + rating, current)
    return result
 
def main():
    '''The main function'''
    length = len(sys.argv)
    if length != 3:
        print "Usage: <lower number> <greater number>"
        return
    lower = int(sys.argv[1]) # Press '1' for Netflix
    greater = int(sys.argv[2]) # Press '5' for Netflix
    if greater < lower:
        print '''
        The ORNP algorithm is optimized for computing
        the meandian of a lower number and a greater number;
        while computing it for a greater number and a lower
        number is theoretically possible, it would require a
        quantum-cooled DD memory rack to make it practical.
        '''
        return
    count = (greater - lower) * 1000 + 1 # the Blackermann function
    values = random_values(count, lower, greater)
    result = meandian(lower, greater, values)
    print float(result)
 
if __name__ == "__main__":
    main()

Comments