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
Shadow and highlight create depth (3D).<br> TRUE OR FALSE
tamaranim1 [39]

Answer:

true because then it would be like not popping out

7 0
2 years ago
When youre working with a word processing document and you press the Del key what happens
REY [17]
Typically, "Del" stands for "delete."
Most times, this key will do different things depending on the type of keyboard/computer you have. For example, on macs, the "delete" key is also the backspace key, so it will delete the last character you typed. However, on most pcs, the "delete" key will delete characters you typed that are in front of your cursor.
5 0
3 years ago
Who is mostly affected by computer viruses?
Komok [63]
People who use Windows OS.
3 0
3 years ago
Are Microsoft an Apple more secure from malicious action because of their closed-source approach?
omeli [17]

Yes Microsoft and Apple used the closed-source approach to better secure from malware and make to make their operating systems more user friendly.

7 0
3 years ago
When starting a computer running Windows Vista, a technician sees that the error message "BOOTMGR is missing" appears after the
docker41 [41]

Answer:

B and C

Explanation:

Possible solution to solving "BOOTMGR is missing" error in Windows Vista is to use the Windows Recovery Environment.

Another option is to run "bootrec/fixboot" command from the comman prompt and the command prompt is also accessible from the windows recovery environment.

8 0
3 years ago
Other questions:
  • In which scenario would instant messaging be more useful than other forms of communication?
    10·1 answer
  • Assume you previously entered these lines of code.
    14·2 answers
  • Draw the hierarchy chart and then plan the logic for a program that calculates a person’s body mass index (BMI).
    11·1 answer
  • Which character formatting effect makes text appear in a small font size below the midpoint of a line of text
    6·1 answer
  • Which of the following guidelines about the subject line of e-mail messages is most appropriate?
    15·2 answers
  • How would you describe<br> "analogous color harmony" to a six year old?
    13·1 answer
  • To increase security on your company's internal network, the administrator has disabled as many ports as possible. Now, however,
    12·1 answer
  • Five uses of the operating system​
    10·2 answers
  • What safety do you need to have ready to start a device repair?
    6·1 answer
  • What is the purpose of the Subtotal feature?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!