Emerging Scholars Program - Week 5

Challenge from last time

Three people are standing in line and all are looking in the same direction. That is, person 3 (P3) can see person 2 (P2) and person 1 (P1). P2 can see P1, but not P3. P1 can see neither P2 nor P3. Now consider the following: all of the people know that there exist 5 hats. They know that 3 hats are black and 2 are white. They all know that each of them is wearing a hat. Assume P1, P2, and P3 are perfect logicians and hear one another speak.
First, P3 says, I don't know what color my hat is.
Then, P2 says, I don't know what color my hat is.
Now it's P1's turn. Judging by what he heard P3 and P2 say, do you think P1 knows the color of his hat? If so, what is it?

JavaScript you should know

Warm Up

Remember this formula (for equations of type ax2 + bx + c)? x = {-b + (b2 - 4ac)0.5} / 2a Each group has 5 minutes to come up with the function and write the result on the board. The user should be able to call the function in this manner: var a = 1;
var b = 2;
var c = 1;
x = calcX(a,b,c)

Simulator

One of the possible uses of software is to simulate events. This includes cases where there may be too many variables for a human to comprehend or where the actual event is very expensive to do either financially, socially, or in terms of risk. Examples: how a disease might spread in population, how the effects of high wind gusts will act on an airplane wing, airforce dogfight.

Your job is to design a part of a computer program that would act as a simulator for teaching irresponsible 15 year-olds how to drive. What functions would the program need in order to control various parts of the car (ie. mirrors, gas/break pedals, etc..). For every function you come up with, write a header for it. Come up with at least 20 functions. You will present them to the class. Below is an example of one of the functions you could have written (it doesn't count toward your 20). Think about all of the things that you do while driving. Think of what kind of information the functions need as parameters and should return as return values. function moveWindow(dPos, wNum)
// REQUIRES: dPos - Desired position of window
// wNum - Window number (1=driver, 2=front passenger,
// 3=left back, 4=right back)
// RETURNS : new position of window

A challenge for next time

Note: this is not really a logic problem. This is more an engineering/ingenuity problem.

There are 3 lightbulbs on the 4th floor. There are 2 light switches in the basement. They are connected to 2 different of the 3 lightbulbs on the 4th floor. You can only make 1 trip from the basement to the 4th floor. You start in the basement. Upon making your trip to the 4th floor, you should know which light switch goes to which lightbulb and which of the lightbulbs does not have a switch in the basement.