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
In this program you will read in the number of seconds and convert it to days, hours, minutes and remaining seconds. Your progra
mart [117]

Answer:

// here is code in c++.

// include headers

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

long long int inp_sec,days,hours,minutes,sec;

long long int s;

cout<<"please enter the seconds:";

 // read the input seconds

cin>>inp_sec;

 // make copy of input second

s=inp_sec;

 // compute days,86400 seconds in a day

days=inp_sec/86400;

 // update the seconds after counting days

inp_sec=inp_sec%86400;

 // compute hours, 3600 seconds in an hour

hours=inp_sec/3600;

 // update the seconds after counting hours

inp_sec=inp_sec%3600;

 //compute minutes, 60 seconds in a minute

minutes=inp_sec/60;

 // compute remaining seconds

sec=inp_sec%60;

 // print the output

cout<<s<<" seconds is equal to "<<days<<" days "<<hours<<" hours "<<minutes<<" minutes "<<sec<<" seconds "<<endl;

return 0;

}

Explanation:

Declare variables "inp_sec","days","hours","minutes" and "sec" of long long int type. read the seconds from user and assign it to variable "inp_sec".Make a copy of input  seconds.Then compute the days by dividing inp_sec with 86400 and update the inp_sec. then find hours by dividing inp_sec with 3600 and update the inp_sec.Similarly  find the minutes and remaining seconds.After this print the output.

Output:

please enter the seconds:83647362                                                                                                                            

83647362 seconds is equal to 968 days 3 hours 22 minutes 42 seconds

3 0
4 years ago
Why are there problems with patching electronics such as heart rate monitors and MRI machines that run embedded Windows OSs?
timofeeve [1]

Answer:

The various problems with patching electronics such as heart rate monitors and MRI machines that run embedded Windows OSs is that they have a certification which is usually at a specific revision level.

Another issue is that probably the maker or the manufacturer didn’t provide the patch method which would have been used to fix such electronics.

8 0
3 years ago
How do unstar another user
Tomtit [17]

Answer:

i dont know

Explanation:

3 0
3 years ago
What's a False statement about online time? A. Blue light from devices can make it hard to sleep. B. It's a good way to connect
mylen [45]

Answer:C

Explanation: This has no basis while the others have studied behind them.

4 0
4 years ago
Which processor is better for madvr
nadya68 [22]

Answer:

The i5.

Explanation:

It has a lower clock speed, but you do note that you have more cores, same with the cache memory.

8 0
4 years ago
Other questions:
  • An Ethernet network, all data travels across the network and between computers in which form or unit?
    12·1 answer
  • Can folders have mixed apps?
    6·1 answer
  • Sukhi needs to insert a container into her form to collect a particular type of information. Which object should she insert?
    6·1 answer
  • The following processes are being scheduled using a preemptive, round-robin scheduling algorithm. Each process is assigned a num
    6·1 answer
  • Create a new program called Time.java. From now on, we won’t remind you to start with a small, working program, but you should.
    13·1 answer
  • In what ways can you sort data by using the sort procedure? Check all that apply.
    6·1 answer
  • if someone has become very attached to their mobile device and feels anxious if the cannot connect to the internet, what are the
    7·1 answer
  • The largest group of Linux users is likely to be
    7·1 answer
  • PLSS HELP ASAP ILL GIVE BRAINLIEST THANKS
    15·2 answers
  • Why is computer economics important?​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!