Growing Bacteria

jeetee
Posts: 105
Joined: Sun Jan 04, 2009 5:25 pm

Growing Bacteria

Post by jeetee »

I think I don't get the description of the algorithm correctly.

When I calculate the first 8 days starting with one bacteria, I find that there are 48 bacterias after 8 days, not 47.
I wrote the algorithm in C++, but of course my answer isn't correct, which is to expect when I can't even work out the first 8 days manually...

Could anyone hint me out ?
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

I agree with the 8-day answer of 47, but that's through reasoning rather than simulation. Maybe we interpreted the rules differently, but I can't see how.
User avatar
bsguedes
Posts: 103
Joined: Tue Feb 24, 2009 12:39 am
Location: Porto Alegre

Post by bsguedes »

Each bacterium is able to generate ONLY two new bacteria, one in the next day to its birth and the second in the second day after is birth. Each one of the generated bacteria follow these rules too. It is also necessary to remove from population the dead bacteria (I think that jeetee has forgotten to kill the first bacterium to get 48 instead of 47 in the 8th day).

Cheers,
Bruno.
E2YnDlEMXiU
Posts: 1
Joined: Tue Mar 17, 2009 11:38 pm

Post by E2YnDlEMXiU »

even if your counts are slightly off for the 8 day example (mine was as well), simply execute your program and see when it reaches 10**12... you can easily figure out the answer then.
Bierdeckel
Posts: 7
Joined: Thu Mar 05, 2009 2:22 pm

Post by Bierdeckel »

Its realy simple.

You could finde the answer without any coding. Math is your friend :D

Even with coding its realy simple. My vb-code is just 13 lines long.
horst
Posts: 24
Joined: Fri Mar 06, 2009 11:07 am
Location: Germany

Post by horst »

I get 51 bacteria for day 8 :cry:

1 => 1
2 => 3
3 => 6
4 => 10
5 => 15
6 => 25
7 => 34
8 => 51

This challenge drives me crazy...
lukas
Posts: 34
Joined: Wed Nov 26, 2008 1:53 pm
Location: Germany

Post by lukas »

horst wrote:I get 51 bacteria for day 8 :cry:

1 => 1
2 => 3
3 => 6
4 => 10
5 => 15
6 => 25
7 => 34
8 => 51

This challenge drives me crazy...
If one bacteria splits at day 1 you have two on day 2 and not three.

My Ruby Code was also just 8 lines long. Although a nice challenge.
horst
Posts: 24
Joined: Fri Mar 06, 2009 11:07 am
Location: Germany

Post by horst »

Ouch, thank you, I thought a bit too complicated. Got it now =)
homeas
Posts: 10
Joined: Thu Nov 13, 2008 11:17 pm

Post by homeas »

finally a challenge to relax,

why writing any code at all? - just use the windows (or pocket or xxx) calculator ...
User avatar
bsguedes
Posts: 103
Joined: Tue Feb 24, 2009 12:39 am
Location: Porto Alegre

Post by bsguedes »

homeas wrote:finally a challenge to relax,

why writing any code at all? - just use the windows (or pocket or xxx) calculator ...
:D

The main idea was to be an easy challenge =]
contagious
Posts: 35
Joined: Tue May 12, 2009 6:08 pm
Location: Greece

Post by contagious »

fibonacci sequence... again
ellarso
Posts: 3
Joined: Sun Nov 16, 2008 4:11 pm
Location: Hamburg, Germany

Post by ellarso »

contagious wrote:fibonacci sequence... again
Not quite! In a fibonacci sequence each number is the sum of the previous two.
0,1,1,2,3,5,8,13,21,34,55,89,...
Especially, the hint for day 8 (47) does not work!
gfoot
Posts: 269
Joined: Wed Sep 05, 2007 11:34 pm
Location: Brighton, UK

Post by gfoot »

It is related, but discussion of exactly how should probably go in the "solved" forum...
psycore
Posts: 8
Joined: Wed Feb 18, 2009 5:40 am

Post by psycore »

Damn. I tried over weeks to create some java code for the bacteria cycle. I got the cycle of the new bacteria kind in code. Then I remembered the current topic of our maths lessons. Two minutes of calculator action. But hey, at least I learned a lot about coding java.

And to the guys wondering about the cycle. It says that there is that cycle for a bacteria and that scientist have found a new kind of that bacteria. But really, don't focus on the cycle so much.
Mosher
Posts: 3
Joined: Sun Dec 21, 2008 6:43 pm

Post by Mosher »

Found a rather simple solution via Access

Code excerpt as follows (don´t wonder about german words, i´m german ^^)

Code: Select all

x = 1
a = 1
b = 0
c = 0
d = 0
e = 0
...



s is the amount of bacteria after day x

a, b, c, d, and e are the amount of bacteria which are in stadium 1, 2, 3, 4, 5 accordig to challange´s description

a1, b1, c1, d1 are auxiliary variables to save the old data for preventing circle-referrence between variables
Post Reply