Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- 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(decimal, factorial_list, factorial_list_count = 0):
- if (factorial_list_count == 0):
- factorial_list_count = len(factorial_list)
- current_permutation = FACTORIAL_BASE(decimal)
- new_factorial_list = factorial_list.copy()
- permutation = []
- permutation2 = []
- for i in range(0, len(new_factorial_list) - len(current_permutation) - 0):
- permutation2 = permutation2 + [new_factorial_list.pop(0)]
- for element in current_permutation:
- current_factorial = new_factorial_list.pop(element)
- permutation = permutation + [current_factorial]
- while len(new_factorial_list) > 0:
- permutation2 = permutation2 + [new_factorial_list.pop(0)]
- return permutation2, permutation, current_permutation
- def FACTORIAL_BASE_TO_DECIMAL(factorial_base, padding = 0):
- current_radix = len(factorial_base) - 1
- decimal = 0
- for current_number in factorial_base:
- decimal = current_number * FACTORIAL(current_radix) + decimal
- current_radix = current_radix - 1
- return decimal
- def PERMUTATION_TO_FACTORIAL_BASE(current_business_slot_list, static_business_slot_list):
- current_static_business_slot_list = static_business_slot_list.copy()
- 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)
- # EXAMPLE:
- #business_slots = ["MATH", "SCIENCE", "WAR", "ART", "PSYCHOLOGY", "BIOLOGY", "ELECTRICITY", "BUSINESS", "RELIGION", "MARTIAL ART", "MARTIAL WAR", "PRODUCTION"]
- business_slots = ["PRODUCTION", "MARTIAL WAR", "MARTIAL ART", "RELIGION", "BUSINESS", "ELECTRICITY", "BIOLOGY", "PSYCHOLOGY", "ART", "WAR", "SCIENCE", "MATH"]
- for permutation_number in range(0, PERMUTATION_MAX(6)):
- permutation = DECIMAL_TO_PERMUTATION(permutation_number, business_slots)
- print("CURRENT_ITERATION: " + str(permutation_number) + ", " + str(permutation))
- print("DECIMAL: " + str(PERMUTATION_TO_DECIMAL(permutation[1], business_slots)))
- print("\n")
- print(str(PERMUTATION_TO_DECIMAL(["MATH", "WAR", "SCIENCE", "PSYCHOLOGY", "ART"], business_slots)))
- print(str(DECIMAL_TO_PERMUTATION(112, business_slots)))
Add Comment
Please, Sign In to add comment