DEV Community

Abhishek singh
Abhishek singh

Posted on

Hackerearth hiring coding challenge

Hotel Problem

Management wants to optimize the usage of electricity consumption and also ensure that there is no inconvenience caused to the guests and staff. So, it has installed Motion Sensors at appropriate places and has approached you to program a Controller which takes inputs from these sensors and controls various equipment

The way the hotel equipment are organized and the requirements for the Controller are listed below.

● A Hotel can have multiple floors.

● Each Floor can have multiple main corridors and sub-corridors

● Both main corridor and sub corridor have one light each.

● Both main and sub corridor lights consume 5 units of power when ON.

● Both main and sub corridor have independently controllable ACs.

● Both main and sub corridor ACs consume 10 units of power when ON.

● If there is no movement in particular sub corridors then turn off light and turn on AC for that sub-corridor.

● If there is movement in particular sub corridors then turn on the light and turn off AC for that sub-corridor.

● Allowed Power Consumption (15 * Number of main corridors + 10 * Number of Sub Corridors) units per floor. If it is exceeding then turn off AC of Sub Corridors.

Take initial inputs:
Number of Floors: 2
Main Corridors per floor: 4
Sub Corridors per floor: 2

External inputs from the sensor:

https://github.com/abhi11210646/hotel-problem

Top comments (0)