Please enable JavaScript to use CodeHS

Leprechaun Mischief

In this project, students will use loops and functions (with parameters and return values) to collect stolen gold that has been hidden throughout a grassy field.

Medium

3 Hours

High School

Project Description

Background

Hairy McGiggles Luckleaf has been up to no good, as a leprechaun is wont to do. On the eve of St. Patrick’s day, he snuck into town and managed to steal gold coins from each of the townsfolk and hide them throughout a neighboring field. They are… not happy, and have reached out to you to help retrieve their coins.

Your Task

Your task is to write a program that collects the gold coins and lays them out at the top of the field, so that the townsfolk can retrieve that which was taken from them.


For this project, we create a new world that represents the field in which Hairy has hid all of the gold coins. Every time you print the world you’ll see the current state of the field, which is a bird’s-eye view with two items: grass (w) and the gold coins (O):



As mentioned above, your program needs to collect all the gold coins and arrange them at the top of the field, like this:



With this in mind, continue on to the next two training activities to learn about the commands you can use with your field!

Project Demo

Explore this program before assigning it!