Мой код на данный момент:
Код: Выделить всё
import argparse
from itertools import combinations
#get code to automatically get the formula from whatever you're doing in combination_to_index
def combination_to_index(combination, iterable):
base = len(iterable)
index = 0
for char in combination:
index = index * base + iterable.index(char)
return index
# Example iterable
iterable = '0123456789abcdefg'
# Length of combinations
repeat = 74 # Example length
# Define the target combination you want to stop at
target_combination = ('1'*74) # Example target combination
# Calculate the position (index) of the target combination
target_index = combination_to_index(target_combination, iterable)
# Calculate the total number of combinations
print(f"Index of target combination: {target_index}")
Если бы вы, ребята, могли бы использовать iterable, чтобы разрешить мне использовать случайный порядок, что было бы неплохо. Я не могу просто изменить порядок итерации, потому что она не будет следовать случайному заказному порядку.
Подробнее здесь: https://stackoverflow.com/questions/789 ... -string-fr