Professional Documents
Culture Documents
com
I love Python language, its freestyle of coding encourages myself to write solutions to many real
time problems. I have been using Python on a daily basis from past 2 years now. I mostly work
on tornado framework professionally to build web applications but I am also fascinated to write
command line applications using Python as well.
Today, I am going to share one of my coding assignments from Amazon Code Contest in which
I have been asked to write an automated job performing queue system for a warehouse
management.
Problem Statement: Create an Automated Job Performing Queue System based on jobs priority
and employees skills. Employees were given with their skills and Jobs were given with skills to
be used to finish them along with their priorities and time to finish as inputs using STDIN. Points
which should be taken care were,
1. I should maintain the order of employees in which they were entered into the system
while distributing the Jobs.
2. As Multiple employees can have similar skills and multiple jobs can be finished using
similar skills so an employee should choose a job relevant to his skills and also which
have high priority amongst similar ones.
class WareHouseManagement(object):
'''
Description:
Description:
Arguments:
Description:
Arguments:
Description:
1. it maintains tracks of
employees which says which job has been done
by which employee. This will going to be consumed
at the end of the program as to show output of
the assignment.
Arguments:
Automated Job Queue using Python-Mukul Taneja @ LinkedIn.com
Description:
Arguments:
args=(queue.get(timeout=100),
rjobs[jcount],
queue))
threads.append(thread)
Automated Job Queue using Python-Mukul Taneja @ LinkedIn.com
thread.start()
jcount += 1
return threads
def print_track(self):
'''
Function name: print_track
Description:
def main():
'''
Function name: main
Descripton:
# printing track
warehouse.print_track()
main()
Instead of using threads, one can create a multi-process system also but the multi-process system
will be much heavy when so many employees entered into the system. Queue data structure is
great and helpful library I could find while doing research for this problem statement as it
manages all the synchronization along with thread locks internally and developers do not need to
think in this area while writing solutions for problems.
That is it, Please feel free to comment and share your doubts if any.