##### Creating permutations of N size with no same elements next to one another (recursion)
 Creating permutations of N size with no same elements next to one another (recursion) melmoman Unladen Swallow Posts: 1 Threads: 1 Joined: Dec 2021 Reputation: Dec-18-2021, 06:06 PM Hello everyone! I am studying python from a Romanian book, and I have been trying some exercises on recursion. I am quite struggling with this one: I am supposed to find all permutations of size K with recursion, without there being identical elements next to one another. So, given a list [a,b,c,d] and K=3: (a,b,c) (a,b,d) would be valid permutations. The exercise asks precisely to append the permutations to a list (so generators are out of the question) and return it. Any help would be appreciated. Thanks in advance! Reply Larz60+ aetate et sapientia Posts: 11,604 Threads: 449 Joined: Sep 2016 Reputation: Dec-18-2021, 09:39 PM Reply

 Possibly Related Threads… Thread Author Replies Views Last Post ValueError: Length mismatch: Expected axis has 8 elements, new values have 1 elements ilknurg 1 3,072 May-17-2022, 11:38 AM Last Post: Larz60+ Sorting Elements via parameters pointing to those elements. rpalmer 3 1,957 Feb-10-2021, 04:53 PM Last Post: rpalmer What happens to a after it is read? Pedroski55 3 1,574 Nov-29-2020, 08:35 AM Last Post: DeaD_EyE Permutations mikke3141 2 1,724 Dec-23-2019, 06:09 PM Last Post: mikke3141 size of set vs size of dict zweb 0 1,761 Oct-11-2019, 01:32 AM Last Post: zweb More Efficent Way of Generating Permutations/ w Rep ClassicalSoul 2 2,142 Aug-22-2019, 05:22 AM Last Post: perfringo permutations calculation with a while instruction kwak86 2 1,810 Sep-10-2018, 02:09 PM Last Post: kwak86 CSV file created is huge in size. How to reduce the size? pramoddsrb 0 9,639 Apr-26-2018, 12:38 AM Last Post: pramoddsrb How to find the number of permutations of a list of lists? JoeB 5 4,364 Nov-18-2017, 06:31 PM Last Post: heiner55

Forum Jump:

### User Panel Messages

##### Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020