1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
aev [14]
3 years ago
14

Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will rea

d a list of one word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line.
Computers and Technology
1 answer:
irinina [24]3 years ago
3 0

Answer:

Check the explanation

Explanation:

Executable Code:

def all_permutations(permList, nameList):

   # Define the function to create a list

   # of all the permutations.

   def createPermutationsList(nameList):

       # Compute and store the length of the list.

       n = len(nameList)

       # Return an empty list if the size is 0.

       if n == 0:

           return []

       # Return the element if the size is 1.

       if n == 1:

           return [nameList]

       # Create an empty list to store the permutations.

       permList = []

       # Start the loop to traverse the list.

       for i in range(n):

           # Store the first element of the current list.

           first = nameList[i]

           # Compute the store the remaining list.

           remaining = nameList[:i] + nameList[i+1:]

           # Start the loop and call the function recursively

           # with the remaining list.

           for perm in createPermutationsList(remaining):

               # Append the element in the permutation list.

               permList.append([first] + perm)

       # Return the permutation list.

       return permList

   # Call the function to compute the permutation list

   # and store the result.

   permList = createPermutationsList(nameList)

   # Start the loop to display the values.

   for perm in permList:

       for val in perm:

           print(val, end = " ")

       print()

# Call the main() function.

if __name__ == "__main__":

   # Prompt the user to enter the input.

   nameList = input().split(' ')

   permList = []

   # Call the function to create and output

   # the permutations of the list.

   all_permutations(permList, nameList)

#endcode

You might be interested in
During project management, who executes tasks and produces the deliverables as stated in the project plan and as directed by the
san4es73 [151]
B. Project team members
8 0
3 years ago
Font size, font style, and _______ are all aspects of character formatting.
mel-nik [20]
The answer, im prettysure, is d. typeface.
hope this helps (:

6 0
2 years ago
Read 2 more answers
How to deactivate the brainly app?​
galina1969 [7]

Answer:

Don't you just uninstall it?

Explanation:

5 0
2 years ago
Read 2 more answers
Some of y'all make me lose braincells with your questions
boyakko [2]

Answer:

ok done we will try

BTW have a nice day enjoy your day Stay blessed stay happy stay strong

5 0
2 years ago
Read 2 more answers
How can you insert an image file in your word document?​
Margarita [4]

Click the insert tab, it'll show a pop up window. Go to the location of where your picture may be. Double click on the photo, and it will be inserted into the word document.

6 0
2 years ago
Other questions:
  • The view side by side command is used to view and ________ two workbooks at one time
    10·1 answer
  • Each of the walls of a room with square dimensions has been built with two pieces of sheetrock, a smaller one and a larger one.
    11·1 answer
  • Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the p
    12·1 answer
  • You are photographing your friend in a local park which of the following might be supporting details you want to include in the
    6·1 answer
  • You can click the ____ button to undo an automatic correction.
    9·1 answer
  • Technology trends in education play a key role in a student’s
    15·1 answer
  • What is a common translator?​
    9·1 answer
  • What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.e
    9·1 answer
  • What do macOS and Windows use to prevent us from accidentally deleting files?
    15·1 answer
  • Wirte a program which asks the users to input length and calculates the area of a square.( Area = Length^2)​
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!