How could you get all the convolution instances k of n elements with just one for loop? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
0

How could you get all the convolution instances k of n elements with just one for loop?

Ex. Input: [1,2,3,4,5] with n=5, k=3 Output: [1,2,3], [1,2,4], [1,2,5],[1,3,4], [1,3,5], [1,4,5], [2,3,4], [2,3,5], [2,4,5], [3,4,5].

1st Oct 2020, 5:17 AM
Dang Van Nhan
Dang Van Nhan - avatar
1 ответ
+ 5
Those are called combinations, not convolutions! Use itertools: https://code.sololearn.com/c9Y9YbduxqwU/?ref=app
1st Oct 2020, 6:12 AM
Bilbo Baggins
Bilbo Baggins - avatar