You are currently browsing the archives for the assignments category


More on game of life

I prepared a small modification to the code that is able to track the percentage of cells that changed their state from the previous time step (shown as the last column). The modifications are not significant, you should look at “num_changed” throughout the code to track them. A link:

http://ideone.com/BVRez

I’d like to see some variants of the code with rule modifications by Monday morning. The most challenging but also interesting one would involve more types of living cells, e.g. 2. This would create an opportunity for all kinds of new rules and behaviors, but would also require you to modify the code to track not only the number of living and dead cells, but also the number of cells of each type (or percentage in terms of the number of living cells). The code modification will also require the neighbors to be not only counted, but the system needs to make a count of the different neighbor types.

Assignment 4

This assignment is due by the next learning session on Wednesday, June 20, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

Program A8:
Solve problem 5 from projecteuler.net. Submit the solution directly on the projeuler.net site so that you get it verified, and send me the link to the program you used to compute the solution (just like for previous problems).

Program A9:
Solve problem 6 from projecteuler.net. Submit the solution directly on the projeuler.net site so that you get it verified, and send me the link to the program you used to compute the solution (just like for previous problems).

Technical Writing for Fun and Profit

David E. Goldberg was my Ph.D. advisor, and was excellent at writing. He wrote a short article Technical Writing for Fun and Profit on technical writing, please read this, it should be helpful in writing a good report. The article can be found at

http://ise.illinois.edu/ge494/technl-writing-fun.pdf

Assignment 3

This assignment is due by the next learning session on Monday, June 18, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

Program A5:
Solve problem 1 on projecteuler.net. You can verify the solution directly on projecteuler.net (once you create a login). There is no penalty for a wrong answer, so once you are done with the programming go ahead and try to submit the answer. If the answer does not match, try to correct your code and submit again. On a side, this problem can be solved using a paper and pencil, but I want you to actually implement it in C++, so that your program gives you the answer.

Program A6:
Find the largest number in the Fibonacci sequence that is smaller than 100,000 (one hundred thousand). That means, print out the number in the Fibonacci sequence that is smaller than 100,000 and at the same time the next number in the sequence is definitely at least equal to 100,000. Print the number out. (Hint: You should keep generating new terms in Fibonacci sequence until you hit 100,000 (or more), and then output the previous number before hitting 100,000).

Program A7:
Solve problem 2 on projecteuler.net. You can verify the solution directly on projecteuler.net (once you create a login). There is no penalty for a wrong answer, so once you are done with the programming go ahead and try to submit the answer. If the answer does not match, try to correct your code and submit again. Once you have solved A6, this should be a piece of cake.

Let me know if you have any questions as soon as you have them.

Assignment 2

This assignment is due by the next learning session on Friday, June 15, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

Program A3:
Implement a program that counts the number of all natural numbers up to 10000 (including 10000) that are divisible by at least one of the following three numbers: 5, 8, and 12. For example, numbers 25, 75 and 130 are counted, because they are divisible by 5. Similarly, 16, 32 and 40 are counted because they are divisible by 8. In the end, the program should print out the number of all such natural numbers.

Program A4:
Modify the program A3 to print out also the sum of all the numbers that were counted in the previous problem A3. Therefore, the two outputs should be: (1) the number of all natural numbers up to 10000 divisible by any of 5, 8 and 12, and (2) their sum.

Assignment 1

This assignment is due by the next learning session on Wednesday, June 13, 2012. Please complete the programs on ideone.com, and send me the links to your programs via email at martin@martinpelikan.net.

If you are having problems or questions, please email me so that we can address these before it’s too late.

Program A1:
Implement a simple program that prints out your first name, one letter at a time. That is, you will write a separate “cout” statement to print out every single letter of your name. The output should include the entire name though (you should not put end of lines after each character, the name should look intact).

Program A2:
Implement a program that reads 3 integers from the user (let’s call them i, j, and k). You may assume that the numbers are unique (each number is different from the other two numbers), and that they are all positive. Your program should then check whether any of these numbers is divisible by any other of these numbers, and report all such situations (by printing out each pair of numbers for which this holds). If none of the numbers is divisible by one of the other numbers, there are going to be no outputs.

Examples:

  1. input:
    5 10 15

    output:
    10 is divisible by 5
    15 is divisible by 5
  2. input:
    7 3 21

    output:
    21 is divisible by 7
    21 is divisible by 3
  3. input:
    13 17 3

    output:
  4. input:
    80 16 8

    output:
    80 is divisible by 16
    80 is divisible by 8
    16 is divisible by 8