I'm making a project to automate the solving of a homework problem. It's due on Tuesday, 10/9/12. The project is giving me a slightly lower answer than others who have completed the problem already, and I don't know what's wrong. It really would be so great if you helped, given the deadline.
Here are the parameters of the problem:
-Two rats, male and female, have landed on an island full of food and good rat things. They start multiplying. We need to know how many rats there are at the end of one year; for our purposes, 360 days.
-I am considering every pair of rats to be one, since the males aren't important, and then multiplying by two at the very end.
-The original female rat gives birth to 6 rats (3 pairs) on the first day. She then produces another litter of 3 every 40 days.
-Every other rat must wait for 120 days for its first litter, then have another every 40 days after.
-No rats die.
when gf clicked set (Time) to [0] delete [all] of [Kid Rats] delete [all] of [Adult Rats] //for a blank slate, of course add [0] to [Adult Rats] //the original pair repeat [9] //9 * 40=360 days set (Total) to < [2] * <(length of "Kid Rats" ) + (length of "Adult Rats" )> > //* change (Time) by [40] //40 days passes, the only important unit of time repeat (length of [Kid Rats] ) //age each kid rat if ("80" = (item "1" of "Kid Rats" )) //** add (Time) to [Adult Rats] //New adult rat (the name of the item in the... else //...list doesn't really matter, so I made it show what date the rat... add <[40] + (item 1 of "Kid Rats" )> to [Kid Rats] //...reached adulthood.) delete [1] of [Kid Rats] //if not adult, age and cycle to the bottom of... repeat (length of [Adult Rats] ) //...the kid stack. repeat [3] add [0] to [Kid Rats] //add three 0-age kids for each adult. end*to update the total as we go.
Last edited by weaselnut (2012-10-08 10:47:11)
Offline
weaselnut wrote:
I'm making a project to automate the solving of a homework problem. It's due on Tuesday, 10/9/12. The project is giving me a slightly lower answer than others who have completed the problem already, and I don't know what's wrong. It really would be so great if you helped, given the deadline.
Here are the parameters of the problem:
-Two rats, male and female, have landed on an island full of food and good rat things. They start multiplying. We need to know how many rats there are at the end of one year; for our purposes, 360 days.
-I am considering every pair of rats to be one, since the males aren't important, and then multiplying by two at the very end.
-The original female rat gives birth to 6 rats (3 pairs) on the first day. She then produces another litter of 3 every 40 days.
-Every other rat must wait for 120 days for its first litter, then have another every 40 days after.
-No rats die.when gf clicked set [Time v] to [0] delete [all v] of [Kid Rats v] delete [all v] of [Adult Rats v] //for a blank slate, of course add [0] to [Adult Rats v] //the original pair repeat [9] //9 * 40=360 days set [Total v] to < [2] * <(length of [Kid Rats v] ) + (length of [Adult Rats v])> > //* change [Time v] by [40] //40 days passes, the only important unit of time repeat (length of [Kid Rats v] ) //age each kid rat if <[80] = (item (1) of [Kid Rats v] )> //** add (Time) to [Adult Rats v] //New adult rat (the name of the item in the... else //...list doesn't really matter, so I made it show what date the rat... add <[40] + (item (1) of [Kid Rats v] )> to [Kid Rats v] //...reached adulthood.) delete [1] of [Kid Rats v] //if not adult, age and cycle to the bottom of... repeat (length of [Adult Rats v] ) //...the kid stack. repeat [3] add [0] to [Kid Rats v] //add three 0-age kids for each adult. end end end end end*to update the total as we go.
**80, not 120, because it checks for adulthood BEFORE aging for the turn.
I fixed some of your code.
Last edited by ErnieParke (2012-10-08 15:40:06)
Offline