Наиболее эффективный способ построить все возможные комбинации четверки для 1 к n

Вам не хватает второго аргумента для второго вызова strtotime():

echo date('d/m/Y', strtotime('+2 months'));
1
задан S. L. 17 January 2019 в 16:00
поделиться

1 ответ

Сойти с макушки головы, так что здесь может быть какой-то плохой синтаксис. Должно быть достаточно, чтобы дать вам представление о том, как вы могли бы правильно решить проблему самостоятельно:

import itertools

def quads(n, required_results=None):
    arr1, arr2 = range(1,n+1), range(1,n+1)
    results = set() # only admits unique combinations
    for combination in itertools.product(arr1, arr2):
        results.add(combination)
        if required_results and required_results = len(results): 
            # if the second argument is passed, no need to go through the whole combination-space
            break
    return results
0
ответ дан user8407600 17 January 2019 в 16:00
поделиться
Другие вопросы по тегам:

Похожие вопросы: