Question: NEED Python CODE PLEASE How could I implement that: c, n = map(int, l[:2]) a, b, d = map(int, l[2].split()) a1, b1, d1 = map(int,

NEED Python CODE PLEASE

How could I implement that:

c, n = map(int, l[:2]) a, b, d = map(int, l[2].split()) a1, b1, d1 = map(int, l[3].split())

to that below when I getting input from sys.stdin?:

def train_journey(capability, depots, measures): num_passengers = 0 for I in range(depots): left, entered, staying = measures[i] num_passengers -= left if num_passengers < 0 or num_passengers + joined > capability: return 'impossible' num_passengers += entered if num_passengers < staying: return 'impossible' num_passengers -= staying if num_passengers == 0: return 'possible' else : return 'impossible'

capability, depots = map(int, input().split()) measures = [list(map(int, input().split())) for I in range(depots)] print(train_journey(capability, depots, measures))

As I mentioned before I getting input from sys.stdin and as I understand, I have to check/iterate list which looks like:

Sample Input 1: 1 2 0 1 1 1 0 0

Sample Input 2 1 2 1 0 0 0 1 0

Sample Input 3 1 2 0 1 0 1 0 1

Sample Input 4 1 2 0 1 1 0 0 0

It is still the problem with the train and passengers.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!