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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started