#๐Ÿ”’ Creating branching possibilities?

8 messages ยท Page 1 of 1 (latest)

thorn spade
#

I'm creating a program that branches off into multiple different possibilities if certain conditions are met, and then all of the end results of all the possibilities are combined to form the output.

winged forgeBOT
#

@thorn spade

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

thorn spade
#

The problem is: A company is hosting interviews. There are a total of K interviewers. The interviewees line up in numerical order for the interviews, with the first in line being the first to get interviewed. Jack, one of the interviewees looking to be hired, is in line as well with N interviewees in front of him, so his position is N+1. The interviews start at t=0, at which time interviewer 1 will immediately interview the first person in line. the second person in line will go to interviewer 2, the third to interviewer 3, and so on. Each person takes a certain amount of time to complete their interview, t. after an interviewer is finished interviewing a person, the next person in line will go to them (the time between a person finishing their interview and a person coming in for their interview IS 0). **If two interviewers are finished at the same time, the next person in line may choose which interviewer to go to. ** accounting for all of these possibilities, find the time, t, at which Jack will be interviewed and which of the interviewers could possibly interview him.
Input format:
First line contains intergers N and K, separated by a space
The next line contains N integers, separated by a space, each representing the amount of time, t, the Nth person will take on their interview.
Output format:
First line should contain the integer time in which Jack will get interviewed.
The next line should consist of a bitstring of the interviewers that could possibly interview him, with 1 in the ith position of the bitstring representing that interviewer i could interview them, and 0 meaning no.

#
def find_time(N, K, t):
    int_finish = [0] * K
    for cow_time in t:
        next_interviewer = min(range(K), key=lambda i: int_finish[i])
        int_finish[next_interviewer] += cow_time
        if (int_finish.count(min(int_finish)) > 1) and (min(int_finish) !=0):
            for i in range(K):
                if int_finish[i] == min(int_finish):
                    new_finish = int_finish[:]
                    new_finish[i] += [j+1]
                    
    target_time = min(int_finish)
    bitstring = [1 if time == target_time else 0 for time in int_finish]

    return target_time, ''.join(map(str, bitstring))

N, K = map(int, input().split())
t = list(map(int, input().split()))

target_time, bitstring = find_time(N, K, t)

print(target_time)
print(bitstring)

here is my code so far.

#

In the if statement, I'm trying to create multiple possibilities that continue down the path

#

How would I do that?

winged forgeBOT
#

@thorn spade

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.