| Integrating Empirical Methods into Computer Science | |
|
Project Goals Required Skills Lab Repository Related Papers Collaborators Feedback |
||
Empirical Lab RepositoryTitle: Simulation and the Marble Jar Puzzle Author: Dave Reed, Creighton University, davereed@creighton.edu Possible Courses: CS1 Empirical Concepts Introduced: simulation, data analysis Computer Science Concepts Used: class use, data abstraction, loops, conditionals Summary:
This assignment involves writing a program to help solve a puzzle. The puzzle
involves repeatedly drawing marbles out of a jar and selectively replacing
marbles based on the combination drawn. While some students may be able to
predict the outcome of the puzzle sequence by logic alone, most require
additional data to see the pattern. To complete the assignment, the student
will write a program that simulates repeated marble drawings, using a provided
MarbleJar class that abstracts out the operations on a jar (drawing a marble,
replacing a marble, and determining if empty). Using only these operations,
the simulation program must perform and display the sequence of steps leading
to a solution. Students are then asked to permorm repeated simulations and
analyze the data in order to see the overall pattern and solve the puzzle.
Variations: Numerous other puzzle can be similarly assigned using the MarbleJar class. For example, a simpler puzzle is the following: Given a jar with N marbles of each color (for arbitrary N), what are the odds of reaching into the jar and pulling out two marbles of the same color? Is it 50%? More than 50%? Less than 50%.
|