Lab 07

Project Euler
Due by 10pm on Tuesday, October 25th.

The purpose of this lab is to:

Getting Started

Before you begin, please create a folder called lab07 inside your cs150 folder. This is where you should put all files made for this lab.


On this lab, you are encouraged to work in pairs. Some of the problems are tricky, and two heads are often better than one. As with previous labs, if you do work with a partner, only one member of each pair should submit solutions. Both partners should indicate who they worked with in their README files. Do not simply split the problems between yourself and your partner and then work independently. You must collaborate on all the problems.

You have two weeks to work on this lab, but since there is no scheduled lab time (due to Yom Kippur) and this assignment spans fall break, we strongly suggest starting early (collaboration during the break itself is often logistically infeasible). To avoid a grading nightmare, working with a partner is an all-or-nothing affair: you should either do all problems with a partner (and the same partner for all problems), or work entirely solo.

Part 1 - Project Euler

10 programs, total 38 points, partner allowed.

As mentioned in class, in this lab you're going to be working on problems from a database called Project Euler. At the top of this page you'll see a button to register. Once you've signed up, you'll be able to not only see the problems (which you can do without registering), but also submit solutions and have them checked.

The problems in Project Euler are both mathematical and computational in nature. You'll be writing programs to solve these problems, but a brute-force approach won't always work. To get full credit, your programs must solve the problem in under 60 seconds; if your program takes longer than a minute (which is possible, as some of the problems deal with very large numbers), you'll have to rethink your approach. Once you have a program that runs in under a minute and spits out an answer, enter your answer on the website and they'll tell you whether you got it or not.

Your task is to solve any 10 of the problems. If you're solving problem 23, say, your program that produces the correct answer should be named The lower the index of a problem, the more people have solved it, so the number roughly corresponds to the difficulty. Of course, sometimes a problem you think is easy may be challenging for others, and vice-versa. So feel free to check out problems beyond the first 10. If you're feeling adventurous, see if you can solve some of the problems that haven't been solved by many other people. And naturally, if you're having fun, feel free to try more than 10.

As a side note, some problems that appear to be tough are actually much tougher in other languages. A common reason is that in most languages, there is a limit to the maximum value that can be stored as an integer, so if you start dealing with huge numbers, you need to work around this. This isn't an issue with Python, and as such, some of the problems that are listed as being tougher on project Euler aren't actually that tough with Python.

A few useful tips:

Part 2 - Wrap Up

README: 2 points, individual.

As with every lab, your last job prior to submission is to complete a brief write-up in a README file. If you haven't already done so, please create a new README file in your lab07 folder.

In this file, write a sentence or two about what you learned in this lab. Also give an estimate of the amount of time you spent on the lab. If you have further thoughts about the lab (e.g. parts that were confusing, helpful, annoying, fun, or challenging), please let us know.


If you followed the Honor Code in this assignment, insert a paragraph attesting to the fact within one of your .py files.

I affirm that I have adhered to the Honor Code in this assignment.

You now just need to electronically handin all your files. As a reminder

     % cd             # changes to your home directory
     % cd cs150       # goes to your cs150 folder
     % handin         # starts the handin program
                      # class is 150
                      # assignment is 7
                      # file/directory is lab07
     % lshand         # should show that you've handed in something

You can also specify the options to handin from the command line

     % cd ~/cs150     # goes to your cs150 folder
     % handin -c 150 -a 7 lab07

File Checklist

Again, if you are working in a pair for the Project Euler questions, only one of you should submit programs for the 10 problems you solved, using the labeling described above.

Both partners should submit a README file.