Clarifications for Assignment 2, Question 12
Posted by john in Assignments, Logistics, Announcements Add commentsAssignment 2, Question 12 is about the growth of the population of organisms in petri dishes. There was an error in one of the generation calculations for the example scenario. I replaced that bit with a somewhat longer description of the problem, with tables that show how the dishes array is calculated at each generation. I think this should be clarifying. So if you’re working on Question 12, make sure to get the newest version of the PDF.
Also, a student asked: May I alter the values in the dishes Array? The answer is: Yes. I think it can be done without overwriting the dishes Array — you would do it by duplicating the prior generation (dishes.dup) or by creating a new Array based on the old one (Array.new(dishes)). However, this might make the solution look a lot messier.
October 1st, 2007 at 7:59 am
Is this question 10 or question 12?
October 1st, 2007 at 8:22 am
12. Sorry. I’ll tweak that.
October 4th, 2007 at 2:41 am
While I can get the right output values, I don’t seem to have a ‘clean’ way of showing the dishes’ initial state.
My solution currently prints out after time 1 through n. I think I can get the output to match the handout’s if I store state in a multi dimensional array. I can try to do this but the assignment hinted that we should be able to just print.
So, to confirm: if we don’t use an array of arrays should we be able to cleanly print out the initial state as well as the next 9 states (like the handout?) or do we need to print out initial state, and then perform the computations to get/print the next 9 states?
October 4th, 2007 at 8:15 pm
It is possible to print the initial state, and the following ones, without a multidimensional array. If you can’t determine a way to do it, do use whatever works.
Regarding the initial state of dishes:
Say you have the original array in dishes.
You should be able to do something like:
something.iterator(something) { p dishes; dishes = something……. }
So try and print dishes at the start of a block. This uses a semi-colon (allowed by the rules at the very top of the assignment). If your solution requires three statements in the block (two semi-colons), do it. We would take off a 1/2 point, maybe.
Remember that this one tweaks one of the rules:
– You are allowed to change the value of dishes
My solution required two statements in the main block, but I had to embed one extra sub-iteration inside of the primary block. (If you think about what I’m saying here, and your interest in a multi-dimensional array, you may be able to guess what each of my blocks does.)
Amy’s solution managed to avoid the semi-colon altogether.
October 6th, 2007 at 9:40 am
Makes total sense - thank you!