Background
Instructions
Given the data in events.json
and users.json
, the available times
for a given set of users can be executed like this:
ruby availability.rb Maggie,Joe,Jordan
which will produce output like this:
2021-07-05 13:30 - 16:00
2021-07-05 17:00 - 19:00
2021-07-05 20:00 - 21:00
2021-07-06 14:30 - 15:00
2021-07-06 16:00 - 18:00
2021-07-06 19:00 - 19:30
2021-07-06 20:00 - 20:30
2021-07-07 14:00 - 15:00
2021-07-07 16:00 - 16:15
Working hours are 13:00 through 21:00 UTC.
Output will be shown for any day that is included in events.json
.
Notes
- Feel free to use whatever language you feel most comfortable working with
** I chose Ruby because I love writing Ruby. I stuck to using the standard library, no gems.**
- Please provide instructions for execution of your program
** Listed above. **
- Please include a description of your approach to the problem, as well as any documentation about key parts of your code.
** The bulk of the problem seemed to be the calculation of the available times, so I started there. I used
TDD to push test cases and build the code. The code settled around a Period
object that can be split
by other Period
objects to return available times. Tests are in period_spec.rb
.
Then I jumped to the report. I created objects for Event
and User
mostly to keep the data stuff out of
the reporting code. The availability.rb
script is just a reporting script that uses all of these objects
to build the report.
I did not build any abstractions around the report itself, as I prefer to keep the "edges" of an application clear of abstractions until I see something to abstract. **
- You'll notice that all our events start and end on 15 minute blocks. However, this is not a strict requirement. Events may start or end on any minute (for example, you may have an event from 13:26 - 13:54).
** Tests for this are here: https://github.com/darrencauthon/coding_interview/blob/master/period_spec.rb#L321 **