mini programming course - summary & demos

click here to skip to project demos

This year we tried a small Java class at my community center - we've had Python and Scratch in the past. I worked with a group of middle & high schoolers. Our goal is to provide basic exposure to programming. I loosely followed the same topic order as UW's CSE 142, which I grew familiar with in college. We only have an hour on Sundays and therefore ignored many concepts (large program decomposition, stylistic best practices, objects/inheritance). Everyone seemed to have fun - and they've all added computer science to their planned coursework.


Our room had a whiteboard and I hooked up my laptop to a TV monitor. Students occasionally brought their laptops in for lab-type days, but mostly stuck to paper and pencil. An average Sunday looked like this:

We assigned homework (small practice problems) some weeks. The prompts came with starter code to play with. Here are some examples:

We had two assessments. Some of the classes at the center (such as foreign language) have more formal tests that factor into placement. We leveraged these exam dates and asked students to do homework-sized problems on paper to see how well we were teaching the content. The first assessment was in class. Results varied widely, and we allowed students to do the second assessment at home. This felt better to us given our relaxed goals & freed up a day for a new topic. In both cases we spent the following week reviewing answers and working with students to revise their work.

Occasionally, we reused UW examples - these seemed to transfer well. For example, we explored a "party" example (password required at the door) to explore Scanner and String methods. After completing the program, my students decided to blacklist me from the party (regardless of whether I have the password). I was a bit sad about that, but it led to some fun student-directed adjustments:

public class Example {
    public static void main(String[] args) {
        System.out.println("Welcome to our birthday party!");
        Scanner console = new Scanner(System.in);
        String firstName = getFirstName(console);
        if (firstName.equalsIgnoreCase("Karan")) {
            System.out.println("Get lost!!!");
        } else {
            String secret = "coolbeans";
            String password = askForPassword(console);
            if (password.equalsIgnoreCase(secret)) {
                System.out.println("you're invited. the party is at 8pm");
            } else {
                System.out.println("911 is on their way to your location.");
    public static String getFirstName(Scanner console) { ... }
    public static String askForPassword(Scanner console) { ... }


When a few weeks remained, my co-teacher and I decided to try class projects. By this point we had made it through basic array concepts. We split students into 3 pairs and explained & assigned projects. Students did some work on their own in pairs and checked in with us each week to get some help. Afterwards, students gave presentations at a end-of-year project fair. Other students from the Python/Scratch groups went through a similar process.

We hoped to find project ideas that were interesting, self-contained (e.g. no external libraries), and could be completed in a few weeks. Here are the three projects we chose:

Stick game

This program implements a game where players alternate between picking up 1-3 sticks from a pile, and the player to pick up the last stick loses. Try playing the game to see if you can beat their code:

diagram showing whether the program can win if there are N sticks left

Here's a picture from a brainstorming session. If it is your turn with n sticks left, the program is guaranteed to win if there is a checkmark at n. For example, you must lose if there is one stick left on your turn - so there is a checkmark next to the number one.

Try beginning a game with fifteen sticks. The closest checkmark below fifteen is at thirteen, so the program chooses two sticks. No matter what you choose next (1, 2, or 3), the program can force you to another checkmark. This pattern repeats and the student pair was able to incorporate it into their program.

The original project idea comes from a SIGCSE resource. In that implementation, the program simulates hundreds of games to build up success counts per choice (1, 2, or 3) at each possible game state. This was more complex than we wanted - so we began with a human vs. human implementation. Then the students replaced one side with a random number generator. Lastly, the random chooser was replaced with the method described above.

Authorship stats

Given text from books by Mark Twain and Jane Austen, the program comes up with similarity scores between various books. It does this by comparing word usage - for example, perhaps one author/book uses "am" more often, and a different author/book uses "I'm" instead. The program counts how often popular words are used by each author, converts these counts to percentages of total word count, and compares percentage arrays to find a resulting difference. We found that this project was more difficult than intended - it required some new content (more complex array wrangling) and a level of abstraction / decomposition beyond what we had practiced in homeworks. At the end, we took the student code and ran it between all sets of books to come up with the matrix in the last slide below. Smaller numbers (like 0) demonstrate that the two books had similar word usage. Large numbers illustrate the relative word usage varied.

Trump & Obama speech generator

This program recycles old quotes from President Trump & President Obama to generate new speeches. We used subsets of text files like this and this. This process is similar to a Markov chain. Given the first word W1 of a new speech, we search through old speeches for all the words following W1. We choose one at random to print, and repeat the process with W2.

Compared to the authorship project, this program didn't demand as much decomposition. Instead, the students faced challenges with end-of-file parsing issues and using new constructs (e.g. ArrayList to build up the word list). The students expanded the original idea to include speeches from Obama & function with multi-word speech beginnings (a speech can start with 'I went' instead of just 'I').

For example, here's a quote from Donald Trump:

"You know I've always said it's very, very hard for a person who is very successful. I have done so many deals. Almost all of them have been tremendously successful. You'll see that when I file my statements. I mean you will see; you will be very proud of me, okay."

Let's say you decide to generate a new speech starting with the word I. The program searches through the quote for the word "I" and builds up a list of the words succeeding "I" - in this case [have, file, mean]. Then the program picks one of these words at random and prints it out. So now we have I have.

The program repeats this process with the word "have". It finds all the words after "have" - [done, been] and prints one at random. So now we have I have been. And so on...try it for yourself:

the student projects (originally in Java) were ported to JS for the console-like demos above

thank you to my co-instructor who suggested we start the course, the students, and to many maintainers of UW curriculum & tools