## Unit 3 Summary Task

Due Date Given in Class - Pay Attention!

## Unit 3 Summary Project (found in our Replit Team)

These instructions below are also in the task in Replit.

### To be completed solo or in pairs. Read carefully:

All functions should be documented as required (don't go overboard). Code should be easy to read and properly spaced. Use proper variable names.
You might need a refresher on functions, parameters, returns, Strings or Arrays before you begin. Ask your teacher for any refreshers
now because after today it's too late.

1. Brain Warm-up: The Simple Hero

A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded by some powerful dragons! Each dragon takes 2 bullets to be defeated and our hero has no idea how many bullets he should carry...

Write the hero(bullets, dragons) function that returns true if the hero lives and false if he dies. Hint: no strings, loops, or arrays here...
Examples:

hero(10, 5); => true

hero(7, 4); => false

hero(0, 1); => false

hero(1000, 501); => false

hero(100, 40); => true

For a bonus mark (ie. respect), can you complete the hero function in one line of code? It's ok if you don't!

2. The Hero - Revised

Our hero has appeared on the battlefield unprepared - no bullets! There are dragons all about and bullets strewn on the ground. The hero must run around and pick up the bullets, killing dragons when he has enough bullets to do so (again, 2 per dragon).

Here's how it works. The input to the heroRevised(input) function is a string of b and d characters. For example "bbbdbdbbbbdd". Starting at the first character, the hero will pick up every bullet he finds and attempt to kill every dragon that he finds. However, if the hero encounters a dragon and does not have enough bullets to kill it - our hero dies a horrible death. Return true if the hero survives and false should he fall in battle.
Examples:

heroRevised("bbbdbdbbbbdd"); => true (with 0 bullets left)

heroRevised("bdbbdbdbbbbdd"); => false (2nd char == dragon!)

heroRevised("bbdbbbbbddbbbd"); => true

heroRevised("dbbbbbbbbbbbbb"); => false

heroRevised("bbbdbdbd"); => false

3. Get to the meaning of it...

It's getting close to the end of the year at Hogwarts. You are tasked with writing a program for Dumbledore that will calculate the final score for a given student - computers are kind of like magic.

Write the function overallMean(scores, denoms) that takes a list of scores on tests (an array of length N containing positive whole numbers) and the denominator for each score in denoms (also an array of length N, all positive whole values). The function will convert each score to its percentage value using the matching denominator (no rounding) and then return an overall average as a positive number, rounded to the nearest whole number.
Examples:

let ron = [10, 12, 8, 16, 45];

let hermione = [15, 17, 13, 16, 54];

let tests = [15, 18, 13, 16, 55];

overallMean(ron, tests); // returns 75

overallMean(hermione, tests); // returns 99

Explanation: Ron scored 66.6666, 66.6666, 61.53846, 100, and 81.818181 on his respective tests. This averages to 75.337995 or 75 as a final score.

4. The Wave!

Humans love to do the wave at sporting events. Turns out, words are pretty jealous and would love to do the wave as well! If we consider a lowercase letter to be sitting and an uppercase letter to be standing, you can create a function wave(word) that returns the word in various stages of the wave! (Remember - the first step in any wave is for everyone to sit down)
Examples:

wave("hello") => ["Hello", "hEllo", "heLlo", "helLo", "hellO"];

wave("GoodBYE") => ["Goodbye", "gOodbye", "goOdbye", "gooDbye", "goodBye", "goodbYe", "goodbyE"]

The input will always be a single word of letters only.

5. Extra Crispy (I mean credit)

This task is optional and meant to separate the 4+'s from the 3+'s.

Some new cashiers started to work at your restaurant. They are good at taking orders, but they don't know how to capitalize words, or use a space bar! All the orders they create look something like this: "milkshakepizzachickenfriessodaburgerpizzasandwichmilkshakepizza"

The kitchen staff are threatening to quit, because of how difficult it is to read the orders. Their preference is to receive the orders as a nice clean array of strings with proper capitalization like so:

["Burger", "Fries", "Chicken", "Pizza", "Pizza", "Pizza", "Sandwich", "Milkshake", "Milkshake", "Soda"]

The kitchen staff ALSO expect the items to be in the same order as they appear in the menu. Ya - they're that fussy. The menu items are fairly simple, there is no overlap in the names of the items:

1. Burger
2. Fries
3. Chicken
4. Pizza
5. Sandwich
6. Onionrings
7. Milkshake
8. Soda

Create the function getOrder(input) that converts the ugly string from the cashiers to a nice ordered array for the kitchen staff.

Another Example:

getOrder("pizzaonionringschickenfriesburgersodamilkshakefriessandwichfries")

=> ["Burger", "Fries", "Fries", "Fries", "Chicken", "Pizza", "Sandwich", "Onionrings", "Milkshake", "Soda"]