Skip to content

theGerk/PythonPracticeAirportControl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This program uses Python 2.7


Input:

The program either can take it's input from standard input or takes it from a file passed as a command line argument. The program can take up to 2 command line arguments. One argument determines the number of lanes the airport has, (how many planes can be taking off in parallel), the other determines the input file. The number of lanes is given as a typed integer greater then 0. The file is given as the file name. The order these commands are passed does not mater, unless the file name is also a valid number of lanes, in which case the program assumes that you mean it to be the number of lanes. This is gotten around by putting the number of lanes as the first argument and the file name as the second.

The input is to be formated in the following form:

ID, Submission Time, Requested Start, Requested Duration

ID is a string that can contain anything and is simply the name of the plane. There may not be any control characters or commas in this string. It should be unique but the program will work weather or not it is. Submission Time is always a non-negitive integer and is never less than the previous entry's Submission Time. This number represents the time at which this plane made a request to take off. It is formated as the string representation of the number (human readable). If the number is not formated as an integer correctly then the program's behavior is undefined and may throw an error or exit. If the number is less then the previous entry's Submission Time, then it will throw an error. Requested Start is always an integer. This number represents the time at which this plane would like to start The integer is formated as the string representation of the number (human readable). If the number is not formated as an integer correctly then the program's behavior is undefined and may throw an error or exit. Requested Duration is always a non-negitive integer. This number represents the amount of time it takes this plane to take off, If this number is not a non-negitive integer, then the program's behavior is undefined and may throw an error or exit.

Example Input:

Delta 160, 0, 0, 4
UAL 120, 0, 5, 4
Made up airline PI^2, 3, 8, 10

Each of these entries are put on a single line and there may be no blank lines inbetween, or the behavior is undefined.


What it does:

The program starts with time at 0.

The program then adds each entry into a priority queue for which it's Submission Time is 0. The priority queue gives preference to putting in as many planes as quickly as possible, that means giving preference to wasting no time (no time where a plane is not on the runway if it can be avoided) and secondary preference to planes leaving sooner (if two planes are able to leave at the same time, then the one with less duration is given preference). If all these other things are the same then the preference is given to whichever plane made the request first, and after that any ordering is allowed.

Then the program increments the time by 1 and repeats, until there are no more entries, and all planes have taken off.


Output:

At every tick in which the priority queue changes the program outputs a human readable explanation of what is in the queue.

At the end a list of plane names and take off times will be printed.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages