Enumerating Oriented Gene Orderings
This problem asks:
Given: A positive integer n≤6
Return: The total number of signed permutations of length n, followed by a list of all such permutations.
Required reading
None.
Restate the problem
A signed permutation of length n is an ordering of the first n positive integers in which each integer is then provided with either a positive or negative sign.
Solution steps
First, I made a two-element list for each number up to six like this:
list1 = [-1, 1]
list2 = [-2, 2]
list3 = [-3, 3]
list4 = [-4, 4]
list5 = [-5, 5]
list6 = [-6, 6]
Then, after I downloaded the dataset from Project Rosalind to see how many numbers I needed to include, I built a list of the list products for those numbers. In my case, I needed the first three, so I used:
firstlist = list(product(list1, list2, list3))
Finally, I made a second list with all the permutations of every item in the first list.
secondlist = []
for item in firstlist:
secondlist.append(list(permutations(item)))