Python Forum
Creating permutations of N size with no same elements next to one another (recursion)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating permutations of N size with no same elements next to one another (recursion)
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:
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!

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 <itertools.permutations object at 0x7fe3cc66af68> 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

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