This coding challenge is meant to be completed within 2 hours.
We will be making an assessment based on coding best practices and how you present and explain your work. Please use this as an opportunity to show how well you understand all aspects of high-quality software development.
In a nutshell, we value:
- code that is easy to read & understand
- carefully considered & clean code
- attention to detail
- good communication
As a technical challenge, we would like you to complete the following coding challenge that is outlined below.
If you have any questions, please let us know. Good luck! 🍀
In this challenge, you will be tasked to create an algorithm that will automatically schedule a professor's lessons depending on a their availability.
There is a test script that will be used check the accuracy and robustness of your algorithm afterwards.
This is a pair-programming exercise, meaning you, the candidate, will solve the problem while the interviewer guides you. Throughout the challenge, you may be asked to explain your thinking and coding process.
-
In scheduler.ts, your
schedule()
function should receive two arrays,lessons
andavailabilities
.lessons
is an array ofLesson
objects. ALesson
has the following required properties:title
(string)duration
(number) - a positive whole number that indicates how long the lesson is in minutes
availabilities
is an array ofAvailability
objects. AnAvailability
has the following required properties:id
(number) - unique ID of the availabilityday
(Day
) - numbers from 0-6, which indicates the day of the week the professor is available.0
is for Sunday,1
is for Monday,2
is for Tuesday, and so on.startTime
(string) - indicates the start time of the teacher's availability in 24-hour format (e.g."13:00"
).endTime
(string) - indicates the end time of the teacher's availability in 24-hour format (e.g."15:00"
).
-
The output of the algorithm is an array of schedules. There should be a corresponding
Schedule
for eachAvailability
. EachSchedule
should have the following required properties:availabilityId
: the ID of the availabilitylessons
- list of lessons for this specific schedule; it should be left empty if there are no lessons for this schedule.
-
You are required to implement the types
Lesson
,Availability
, andSchedule
in scheduler.ts yourself based on the requirements above above to demonstrate your proficiency in TypeScript.Day
is already implemented. -
You are not allowed to install new libraries. You may use the built-in
Date
object in Javascript to process time-related data.
Given the following lessons
:
[
{
title: 'JS Basics',
duration: 90,
},
{
title: 'JS Fundamentals',
duration: 90,
},
]
and the following availabilities
:
[
{
id: 1,
day: 1,
startTime: '09:00',
endTime: '10:00',
},
{
id: 2,
day: 2,
startTime: '09:00',
endTime: '10:00',
},
{
id: 3,
day: 2,
startTime: '13:00',
endTime: '14:00',
},
]
Your algorithm should output the following:
[
{
"availabilityId": 1,
"lessons": [
{
"title": "JS Basics",
"duration": 60
}
]
},
{
"availabilityId": 2,
"lessons": [
{
"title": "JS Basics",
"duration": 30
},
{
"title": "JS Fundamentals",
"duration": 30
}
]
},
{
"availabilityId": 3,
"lessons": [
{
"title": "JS Fundamentals",
"duration": 60
}
]
}
]
Note that a single lesson can be scheduled across multiple availabilities.
-
Clone this repository
-
npm install
-
npm test
to run the tests
Together with the interviewer as your guide, implement the code as per the requirements above within the 2-hour time limit. Good luck! 🍀