Super Star Challenge 1
Before we begin, let’s start with some guidelines:
- We expect this to be your own work. We recommend that you do not web search for answers, or work with others, unless a challenge suggests it. If you do, please reference your sources. If you try to cheat and get away with it, it will become apparent later on when the challenges become more interactive.
- Please do not post answers to the web.
- You may leave answers blank if you are completely stumped on a problem.
- Please do not email us to clarify questions. If a question is vague, then answer it the best way you see fit. If a question is poor, let us know, suggest a fix to the problem, and answer the fixed problem instead.
- Please submit all answers to all the questions on each challenge page in a single email message. Do not submit one answer at a time.
- Submit written answers as a pdf file to email@example.com. Feel free to use any program you wish to generate it, but submit it as a pdf. The subject of your message should be <Your Name>: Programming Challenge Page <X>
- Submit code answers as a zipped set of .java files in the same email as the pdf attachment. Place code in the src directory and place unit tests in the test directory. Make sure to have an Eclipse project file. If you use any third party jars, have a readme with a link to them, or include the .jar files in a jars directory. Include simple instructions on how to run your program in a readme file. Make sure it is quick and easy to get from your zip file to running your software.
Challenge 01-01: Warmup:
Take the programming test at http://www.betterprogrammer.com/. Report on how well you did.
Challenge 01-02: Fifty Prisoners Logic Problem:
There are 50 prisoners in a prison. The warden tells them that they can go free if they meet his challenge. There is a meeting room. The warden will at random take a prisoner to the meeting room. The room has a light bulb on a desk. The prisoner can look at the light bulb and then turn it on or off, or not change its state, before leaving the meeting room and returning to his cell. The prisoners cannot communicate in any other way besides through the binary on-off state of the light bulb. They are all in solitary confinement, they are taken to the meeting room only one at a time, and no one can see the meeting room or the light from the light bulb in the meeting room except when they are taken to the meeting room. No one knows the warden’s random selection process or his distribution. All that is known is that each prisoner has a finite chance of being selected on each selection, and that all of the prisoners will be selected at least once each in a finite time, but no one knows how long that might be. Selections may occur frequently sometimes and infrequently at other times. The warden may even select the same prisoner a few times in a row.
When taken to the meeting room, a prisoner may elect to announce “Each prisoners has now visited the meeting room at least once.” If that prisoner is correct, then all of the prisoners become free. If that prisoner isn’t correct then the challenge is over and all the prisoners must stay in prison for the rest of their lives. Before the challenge begins, all of the prisoners get to meet and discuss a strategy. Then they are taken to their solitary rooms and the challenge begins.
Question: What strategy can the prisoners use to guarantee with 100% certainty that they will be let free?
Program: Write a Java program that demonstrates your solution. Have as one class the interface PrisonerSelector with the sole method
public int randomlySelectPrisoner(int totalNumberOfPrisoners)
This method should return an integer from 0 through totalNumberOfPrisoners – 1. Your code should work for any implementation of the PrisonerSelector interface which has a positive chance of selecting any prisoner. You should include a JUnit test that demonstrates that your solution works. Your JUnit test should be able to detect with high probability that a flawed solution is flawed. Your JUnit test should use several different implementations of the PrisonerSelector interface and pass with all of them.
Challenge 01-03: Program a Board Game:
Program a board game in Java. For example, Chess, Checkers, Chinese Checkers, Othello, Stratego, Master Mind, Chutes and Ladders, or a favorite board game of your choosing. Concentrate on the game play, the class design, and the API design. Do not write a GUI, but instead have moves made through code. Verify that the game play is correct through JUnit tests. Try to have easily readable, clean code. If you don’t know what we mean by that, read the book “Clean Code” by Robert C. Martin. If you’re rusty on Java, read “Thinking in Java” by Bruce Eckel. If you’re not too sure about unit testing, read “Test Driven Development” by Kent Beck.
Challenge 01-04: Unit Whats:
What are the benefits of good unit tests? What are key features of good unit tests? When is writing unit tests a waste of time?
Ok, so the above activities may have taken quite some time. But, unless you are the best or the worst programmer in the world, the practice was probably worth it. Email us your answers, along with a resume, and we’ll let you know our first impression, and whether we encourage you to continue the application process. If you just can’t wait to hear back from us, then jump down the rabbit hole and move on to Challenge Page 02.