## Challenge from last time

As everyone knows, knights tell the truth all the time, and liars lie all the time. At least, this is what evenly behaved knights and liars do. Less known is that there are also odd knights, who on odd-numbered days lie all the time. (On even-numbered days, however, they behave evenly, and tell the truth.) Also, there are odd liars, who on odd-numbered days, tell the truth about everything, while they lie the rest of the days. Someone said: "Today's the 3rd. Trust me, I'm telling the truth. I'm odd. I'm not a knight. My eyes are brown." At first, this seemed illogical, and I thought he couldn't be either a knight or a liar, even or odd, but after a while the solution dawned on me and I found the error in my reasoning. What is he?

## JavaScript you should know

- How to perform assignment of a value or result of a function to a variable
- How to ask the user a question (using a function) and get a reply
- How to store that reply in a variable
- How to write a variable to the web-page (using a function)

## Electronic Elections

I want to die in Chicago so that I can remain politically active.--A quote I heard on NPR.

The Florida elections in 2000 gave the traditional voting system bad publicity (to put it in PG terms) and have since been replaced by electronic kiosks. However, long before the 2000 elections, people all over the world have been looking at a way to make elections better using electronic means. Some even envision an internet based voting system! They would be cheaper, might eliminate the chance of a human ballot counting error, and (judging by the popularity of on-line polls, blogs, etc.) would attract a larger body, making the election more valid. However, there are some major issues that are associated with having electronic elections.

- Get into groups and choose a cool team name
- Choose a presenter who has not presented before
- As a group, come up with possible problems that you think electronic voting systems might introduce.
- Send your presenter up to present; presentation must be no longer than 2 minutes.

**Task 1**(10 minutes):

- In your teams, think about how you would implement a voting system. Imagine a web-based voting system.
- Besides the prompt() and document.write() functions
you already know, imagine the existence of
*printErrorAndExitIfAlreadyRegistered()*,*printErrorAndExitIfNameIsntReal()*, and*updateRegistrationDB()*functions. They would be used as follows:

`printErrorAndExitIfAlreadyRegistered(userName);`

printErrorAndExitIfNameIsntReal(userName);

updateRegistrationDB(userName); - Write JavaScript to register a voter and write the results of the registration in a table format using HTML. You may use the functions provided above to check for errors. You make up your own functions to check for other types of errors (you don't have to implement them, you may just imagine that they exist and invoke them).
- Send your presenter up to present; presentation must be no longer than 2 minutes.
**You will be handing the code you wrote on 1 piece of paper. Please have all your team members' names on it and also your team name.**

**Task 2**(10 minutes):

## A challenge for next 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?