MrSlippery

Meandian of two numbers

Apr 1st, 2016
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.81 KB | None | 0 0
  1. '''
  2. Compute the meandian of a lower number and a greater number,
  3. efficiently and scalably, by using a process of interpolated
  4. randometabolization: the Over-Rating Netflix Peruser algorithm.
  5.  
  6. Floppyright Cornel Izbasa 2016
  7. '''
  8. import sys, random, fractions
  9.  
  10. def random_values(count, lower, greater):
  11.     '''List of values for randometabolization'''
  12.     return [random.randint(lower, greater) for _ in range(0, count)]
  13.  
  14. def meandian(lower, greater, values):
  15.     '''The "Over-Rating Netflix Peruser" algorithm'''
  16.     current = 1
  17.     result = fractions.Fraction(values[0], 1)
  18.     for value in values[1:]:
  19.         current += 1
  20.         rating = None
  21.         ideal = 2 * value - result
  22.         if ideal < lower:
  23.             rating = lower
  24.         elif ideal > greater:
  25.             rating = greater
  26.         else:
  27.             rating = int(round(ideal))
  28.         result = fractions.Fraction(result * (current - 1) + rating, current)
  29.     return result
  30.  
  31. def main():
  32.     '''The main function'''
  33.     length = len(sys.argv)
  34.     if length != 3:
  35.         print "Usage: <lower number> <greater number>"
  36.         return
  37.     lower = int(sys.argv[1]) # Press '1' for Netflix
  38.     greater = int(sys.argv[2]) # Press '5' for Netflix
  39.     if greater < lower:
  40.         print '''
  41.        The ORNP algorithm is optimized for computing
  42.        the meandian of a lower number and a greater number;
  43.        while computing it for a greater number and a lower
  44.        number is theoretically possible, it would require a
  45.        quantum-cooled DD memory rack to make it practical.
  46.        '''
  47.         return
  48.     count = (greater - lower) * 1000 + 1 # the Blackermann function
  49.     values = random_values(count, lower, greater)
  50.     result = meandian(lower, greater, values)
  51.     print float(result)
  52.  
  53. if __name__ == "__main__":
  54.     main()
Advertisement
Add Comment
Please, Sign In to add comment