imk0tter

BUSINESS_MATH

Mar 17th, 2025
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.67 KB | None | 0 0
  1. # FORWARDS PERMUTATION (FIRST TO LAST)
  2. # FOR: WHOEVER
  3. # FROM: NICHOLAS STEVEN DAVILA (Imk0tter/LiTHiuM)
  4. def INFINITY_UNIQUE_NUMBER_SERIES(x, *args):
  5.     if (len(args) > 0): return INFINITY_UNIQUE_NUMBER_SERIES(((x + 0) * 2 - 1) * (2 ** args[0]), *args[1:])
  6.     return x
  7.  
  8.  
  9. def FACTORIAL(x):
  10.     result = 1
  11.     for i in range(0, x):
  12.         result = result * (i + 1)
  13.     return result
  14.  
  15. def FACTORIAL_BASE(x):
  16.     results = []
  17.     radix = 1
  18.     while x > 0:
  19.         current = x % radix
  20.         results = [int(current)] + results
  21.         x = (x - current) / radix
  22.         radix += 1
  23.     return tuple(results)
  24.  
  25. def DECIMAL_TO_PERMUTATION(number, factorial_list):
  26.     current_permutation = FACTORIAL_BASE(number)
  27.     new_factorial_list = list(reversed(tuple(factorial_list)))
  28.  
  29.     permutation = []
  30.     permutation2 = []
  31.  
  32.     for i in range(0, len(new_factorial_list) - len(current_permutation)):
  33.         permutation2 = [new_factorial_list.pop(0)] + permutation2
  34.     for element in current_permutation:
  35.         current_factorial = new_factorial_list.pop(element)
  36.         permutation = [current_factorial] + permutation
  37.     return permutation + permutation2
  38.  
  39. def FACTORIAL_BASE_TO_DECIMAL(factorial_base):
  40.     current_radix = len(factorial_base) - 1
  41.     number = 0
  42.     for current_number in factorial_base:
  43.         number = current_number * FACTORIAL(current_radix) + number
  44.         current_radix = current_radix - 1
  45.     return number
  46.  
  47. def PERMUTATION_TO_FACTORIAL_BASE(business_slot_list, static_business_slot_list):
  48.     current_static_business_slot_list = list(reversed(tuple(static_business_slot_list)))
  49.     current_business_slot_list = list(reversed(tuple(business_slot_list)))
  50.  
  51.     factorial_base = []
  52.  
  53.     while len(current_static_business_slot_list) > len(current_business_slot_list):
  54.         current_static_business_slot_list.pop(0)
  55.  
  56.  
  57.     for current_business_slot in current_business_slot_list:
  58.         current_index = current_static_business_slot_list.index(current_business_slot)
  59.         current_static_business_slot_list.pop(current_index)
  60.         factorial_base = factorial_base + [current_index]
  61.     return factorial_base
  62.  
  63. def PERMUTATION_TO_DECIMAL(permutation, static_business_slots):
  64.     return FACTORIAL_BASE_TO_DECIMAL(PERMUTATION_TO_FACTORIAL_BASE(permutation, static_business_slots))
  65.  
  66.  
  67. def PERMUTATION_MAX(slots):
  68.     return FACTORIAL(slots)
  69.  
  70. # EXAMPLE:
  71.  
  72. business_slots = ["MATH", "SCIENCE", "ART", "WAR", "MARTIAL ART", "MARTIAL WAR", "BIOLOGY", "PSYCHOLOGY", "PRODUCTION", "COMPUTING"]
  73.  
  74. for permutation_number in range(0, PERMUTATION_MAX(6)):
  75.     permutation = DECIMAL_TO_PERMUTATION(permutation_number, business_slots)
  76.     print(str(permutation))
  77.  
Add Comment
Please, Sign In to add comment