Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def INFINITY_UNIQUE_NUMBER_SERIES(x, *args):
- if (len(args) > 0): return INFINITY_UNIQUE_NUMBER_SERIES((x * 2 - 1) * (2 ** args[0]), *args[1:])
- return x
- def FACTORIAL(x):
- result = 1
- for i in range(0, x):
- result = result * (i + 1)
- return result
- def FACTORIAL_BASE(x):
- results = []
- radix = 1
- while x > 0:
- current = x % radix
- results = [int(current)] + results
- x = (x - current) / radix
- radix += 1
- return results
- def DECIMAL_TO_PERMUTATION(number, factorial_list):
- current_permutation = FACTORIAL_BASE(number)
- new_factorial_list = list(reversed(tuple(factorial_list)))
- permutation = []
- permutation2 = []
- for i in range(0, len(new_factorial_list) - len(current_permutation)):
- permutation2 = [new_factorial_list.pop(0)] + permutation2
- for element in current_permutation:
- current_factorial = new_factorial_list.pop(element)
- permutation = [current_factorial] + permutation
- return permutation + permutation2
- def FACTORIAL_BASE_TO_DECIMAL(factorial_base):
- current_radix = len(factorial_base) - 1
- number = 0
- for current_number in factorial_base:
- number = current_number * FACTORIAL(current_radix) + number
- current_radix = current_radix - 1
- return number
- def PERMUTATION_TO_FACTORIAL_BASE(business_slot_list, static_business_slot_list):
- current_static_business_slot_list = list(reversed(tuple(static_business_slot_list)))
- current_business_slot_list = list(reversed(tuple(business_slot_list)))
- factorial_base = []
- while len(current_static_business_slot_list) > len(current_business_slot_list):
- current_static_business_slot_list.pop(0)
- for current_business_slot in current_business_slot_list:
- current_index = current_static_business_slot_list.index(current_business_slot)
- current_static_business_slot_list.pop(current_index)
- factorial_base = factorial_base + [current_index]
- return factorial_base
- def PERMUTATION_TO_DECIMAL(permutation, static_business_slots):
- return FACTORIAL_BASE_TO_DECIMAL(PERMUTATION_TO_FACTORIAL_BASE(permutation, static_business_slots))
- def PERMUTATION_MAX(slots):
- return FACTORIAL(slots)
Add Comment
Please, Sign In to add comment