DEV Community

Abhishek singh
Abhishek singh

Posted on

2 2

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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

The only thing worse than downtime? No Answers.

If you’re sometimes frustrated with opaque infrastructure, sluggish support, and mysterious outages, we prepared a webinar just for you

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️