imk0tter

Imk0tter PERMUTATION

Jul 28th, 2023 (edited)
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.25 KB | None | 0 0
  1. def INFINITY_UNIQUE_NUMBER_SERIES(x, *args):
  2.     if (len(args) > 0): return INFINITY_UNIQUE_NUMBER_SERIES((x * 2 - 1) * (2 ** args[0]), *args[1:])
  3.     return x
  4.  
  5.  
  6. def FACTORIAL(x):
  7.     result = 1
  8.     for i in range(0, x):
  9.         result = result * (i + 1)
  10.     return result
  11.  
  12. def FACTORIAL_BASE(x):
  13.     results = []
  14.     radix = 1
  15.     while x > 0:
  16.         current = x % radix
  17.         results = [int(current)] + results
  18.         x = (x - current) / radix
  19.         radix += 1
  20.     return results
  21.  
  22. def DECIMAL_TO_PERMUTATION(number, factorial_list):
  23.     current_permutation = FACTORIAL_BASE(number)
  24.     new_factorial_list = list(reversed(tuple(factorial_list)))
  25.  
  26.     permutation = []
  27.     permutation2 = []
  28.     for i in range(0, len(new_factorial_list) - len(current_permutation)):
  29.         permutation2 = [new_factorial_list.pop(0)] + permutation2
  30.     for element in current_permutation:
  31.         current_factorial = new_factorial_list.pop(element)
  32.         permutation = [current_factorial] + permutation
  33.     return permutation + permutation2
  34.  
  35. def FACTORIAL_BASE_TO_DECIMAL(factorial_base):
  36.     current_radix = len(factorial_base) - 1
  37.     number = 0
  38.     for current_number in factorial_base:
  39.         number = current_number * FACTORIAL(current_radix) + number
  40.         current_radix = current_radix - 1
  41.     return number
  42.  
  43. def PERMUTATION_TO_FACTORIAL_BASE(business_slot_list, static_business_slot_list):
  44.     current_static_business_slot_list = list(reversed(tuple(static_business_slot_list)))
  45.     current_business_slot_list = list(reversed(tuple(business_slot_list)))
  46.  
  47.     factorial_base = []
  48.  
  49.     while len(current_static_business_slot_list) > len(current_business_slot_list):
  50.         current_static_business_slot_list.pop(0)
  51.  
  52.  
  53.     for current_business_slot in current_business_slot_list:
  54.         current_index = current_static_business_slot_list.index(current_business_slot)
  55.         current_static_business_slot_list.pop(current_index)
  56.         factorial_base = factorial_base + [current_index]
  57.     return factorial_base
  58.  
  59. def PERMUTATION_TO_DECIMAL(permutation, static_business_slots):
  60.     return FACTORIAL_BASE_TO_DECIMAL(PERMUTATION_TO_FACTORIAL_BASE(permutation, static_business_slots))
  61.  
  62.  
  63. def PERMUTATION_MAX(slots):
  64.     return FACTORIAL(slots)
Add Comment
Please, Sign In to add comment