##The rule for Problem 1
- The conference has multiple tracks each of which has a morning and afternoon session. Each session contains multiple talks.
- Morning sessions begin at 9am and must finish before 12 noon, for lunch.
- Afternoon sessions begin at 1pm and must finish in time for the networking event.
- The networking event can start no earlier than 4:00 and no later than 5:00.
- No talk title has numbers in it.
- All talk lengths are either in minutes (not hours) or lightning (5 minutes).
- Presenters will be very punctual; there needs to be no gap between sessions.
##The Solution Refer to the First-fit algorithm https://en.wikipedia.org/wiki/Bin_packing_problem
Based on Object-Oriented Analysis, OOA, which includes the following entities.
The relationship of entities as below
Conference -- 1 * n --> Track -- 1 * n --> Period -- 1 * n --> Event
The conference can contains multiple tracks.
Each track can contains multiple event periods, that may include morning session period, lunch period, or afternoon session period, or networking period.
Each Period can contains multiple events(talk or networking).
Each event represents every talk session or networking, which has event description, and event duration.
The main method is in ConferenceApp
, the basic processes as below.
- Read input files, and parse file to events.
- Run the method
ConferenceApp.schedule()
to get the scheduled conference.
- Configure Morning/Lunch/Afternoon/Networking Period.
- Populate Events to Period, consuming event when the current period has enough space time.
- Populate Tracks to Conference.
- Print the context of conference.
##How to Run it
- Switch the root project directory, execute the following cmd to build it.
> sbt compile
> sbt package
- After build it successfully,in the folder
$rootproject/target/scala-2.xx
, you will find the build jarconference-track-scala_2.xx.jar
and then run the command to get conference result> scala conference-track-scala_2.xx.jar your_input_file
For example> scala target/scala-2.11/conference-track-scala_2.11-1.0.jar ./src/test/resources/InputFile