Challenge Overview
Problem Description
Help Cody write a diet-planner to stay Lean and Agile without too much bloat! In this challenge, we will help Cody by creating a web-app to optimize meal-planning. Given a list of food items and some constraints, we will need to calculate a good meal plan.
Hard
In this task, we will finish the diet planner app.
The app will allow inputting food items, and sorting them over the week to fulfill calorie requirements. Cody has a particular diet, he wants to eat the yummyest possible foods on the weekends, and wants to stay approximately within a set calorie requirement.
Technical spec
- Serve a web page at port 8080 at /hard
- The page must contain the following
- A div with id "mainContainer"
- A div with id "inputContainer"
- Within inputContainer:
- an input of type text with id "foodName"
- an input of type text with id "calorieCount"
- an input of type text with id "yummy"
- an input of type button with id "addButton" and value "Add food"
- A div with id "foodsContainer"
- A div with id "planContainer"
- A div with id "monday"
- A div with id "tuesday"
- A div with id "wednesday"
- A div with id "thursday"
- A div with id "friday"
- A div with id "saturday"
- A div with id "sunday"
- an input of type text with id "calorieReq" - default value at 1000
- an input of type button with id "dietPlanner" and value "Plan diet"
- an input of type button with id "reset" and value "Reset App"
- When the user writes into the input containers and clicks the addButton:
- The food item appears on its own line within the foodsContainer
- foodsContainer lists the input lines in a sorted manner, with the yummiest first. If foods have the same yummyness, the higher calorie one is shown first.
- When the user clicks the dietPlanner button:
- The food items are displayed within the planContainer according to the meal plan in their own week day -divs.
- For example, foods for Monday are listed one per line within the "monday" div, and similarly for all other week days
- When the user clicks the reset button:
- All foods are removed from the app
Meal planning
Cody has a simple meal plan. On weekends, the yummiest possible foods should be chosen. In decreasing order of yumminess, Cody will fill out his meal plan, starting from Saturday, filling each day with foods until the chosen calorie requirement (input in "calorieReq") is reached. If two foods have the same yummy value, the higher calorie one is considered first. Once a day is over the calorie limit, the next day will be considered.
Example
Input foods
hamburger meal, 750 calories, 1000 yummyness
donuts, 500 calories, 1000 yummyness
salad, 300 calories, 300 yummyness
and calorieReq value of 1000.
Now, clicking the "Plan diet" button should make the contents of "saturday" div as
hamburger meal, 750 calories, 1000 yummyness
donuts, 500 calories, 1000 yummyness
(each on their own line)
and the contents of "sunday" div as
salad, 300 calories, 300 yummyness
Explanation: First, the hamburger meal is chosen for Saturday because it is the yummiest and has the most calories. The calorie count of 750 is less than the calorie requirement of 1000, so the next item is considered. Now donuts are added, making the total 750 + 500 = 1250. Because this is over the calorie requirement, we move to the next day and add the final food item, salad, to sunday.
Technology Stack
- Programming language: No limitation
- Docker
Sample submissions and tester
Feel free to use the sample servers in this repository as a starting point for your submission.
Submission Deliverables
Submit a zip file. Inside the zip file, there needs to be a folder name code. Inside the code folder, you need to have a Dockerfile which we will use to build the image and start your application by starting a container using the image. The code folder can contain other folders and files but it needs to contain the Dockerfile. The zip file too can contain other folders and files, but it needs to have the code folder at the ROOT.
Constraints & Guidelines
- Please use the forums to ask any questions.
- Minimal code quality is expected for the reviewer to review the submission and go through your code
- Obvious and deliberate code obfuscation will be rejected.
- Collaborating/Cheating in any way with anyone else (member or not) during a rated event is considered cheating.
- An excessive amount of unused content should be avoided.