Farhaan Beeharry
Software Engineer
The Umbrella Challenge
About the challenge
Scenario
Cedric works at CompanyX. Every day he walks to work
and back home. During rainy days, Cedric hates to get
wet on his journey to and from work.
If it
rains in the morning and Cedric has an umbrella at
home, he takes his umbrella and keeps it at CompanyX.
If it rains in the afternoon and Cedric has an
umbrella at work, he takes the umbrella and walk back
home.
Your task is to help out Cedric to
determine the minimum number of umbrella he needs to
start with for some days so that he does not get
drenched. The known info is an array of weather
conditions for each half-day. The possible values are
"clear", "sunny", "cloudy", "rainy", "windy" or
"thunderstorms".
For example, the input is
["sunny", "rainy", "cloudy", "clear"] the first two
values represent a day which is sunny in the morning
and rainy in the afternoon. Cedric can have some
umbrellas at home and some at CompanyX. However, he
will never take an umbrella if it does not rain.
So far, it seems simple. Unfortunately,
Cedric will not understand a simple meaningless array
input and integer output if presented to him. You
should create an user friendly weather interface where
Cedric will be able to input the weather conditions
days and your page will present him the information on
the minimum number of umbrellas he will need at start.
Some test cases:
minimumUmbrellas(["rainy", "clear", "rainy",
"cloudy"]) - should return 2 because Cedric takes an
umbrella from home on the first morning. In the
afternoon since the weather is clear, he does not need
an umbrella. However, the next morning, the weather is
rainy, so Cedric needs an umbrella at home.
minimumUmbrellas(["sunny", "clear"]) -
should return 0 since it never rains.
Assessment
- Create a JS function that takes as input an array of string ("clear", "sunny", "cloudy", "rainy", "windy" or "thunderstorms") and returns the minimum number of umbrella that Cedric must start with - 30 points
- Create a weather widget that takes as input the array, parse it to the above function and present the information to Cedric - 40 points
- Create a web component that will wrap the weather widget with a good UI so that Cedric may be able to input the data and obtain the information he needs - 30 points
Solution
Run the demo (Might take some time to load. Be patient...) - Desktop ONLY
View code on Github
View UI/UX Design on Behance