CMU 15-190 Spring 2017: Topics in Intermediate Programming
Homework 2 (Due Wednesday 1-Feb, at 11:59pm)
- This hw is optional. It is for students who want to get a bit more out of the optional/advanced talk last week, and in particular for those who may wish to get 3 units of pass/fail credit for 15-190 (for whom it is required). We hope that's quite a few of you!
- Work Solo or in Groups of 2-5 (and groups are strongly recommended) Have fun!
- We will grade the hw, but loosely, and chiefly based on effort. You should expect to invest 1-2 hours on it and you'll be fine. This is not about the grade, of course, but about the learning. So take your time, discuss issues with your groupmates, have fun, and enjoy.
- Please track when you start and stop working on this, and with whom you collaborate. You'll need that for your submission. And again, have fun.
- Understand and comment the code
Working together as a group, discuss the code we wrote. It's just 149 lines, including all the comments and the test code (such as we wrote any test code). Be sure to understand what each function is doing and how it is doing it. Then, make minor improvements. In particular, add some brief but clear comments at the top of each function explaining what that function is doing and how it is doing it. Don't go overboard here, just enough comments to show that you clearly understand the code. Include this commented code in your PDF file you submit. - Better variable names
In several cases, we had trouble finding good variable names. Find at least two such cases. List the line numbers on which they occur, include the code as we wrote it, describe why we may have had a problem coming up with a good variable name in that case, and then suggest another perhaps better alternative approach than the one we took in lecture. Your two examples should be distinctive, so not just two cases of the same issue. - Manually solve for the sum-of-squares
This is not a programming problem. Working without a computer or calculator, following our algorithm closely, compute the solution to find the coefficients of the polynomial solution to 12 + 22 + ... + n2. You may format this how you wish, including writing it by hand and scanning that into your PDF file. Note that there are numerous ways to solve this, but you have to closely follow the algorithm we used in lecture, and the one that is used by our code. Include the intermediate results as you go, and not just the final answer. - What to Submit
Each member of the group should submit their own PDF file, 15-190-hw2.pdf, containing this information:- Your name and andrew id
- The names and andrew id's of your groupmates
- The start/stop times you worked, and the total time you worked.
- Your thoughts about this exercise -- useful, interesting, etc? This will help us improve the 15-190 experience as we go.
- The solutions from above. Note: one way to create a PDF is to first make a Word file, then export that to PDF.
Have fun!