hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Growing Bacteria
Goto page 1, 2, 3  Next
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
Growing Bacteria
Author Message
jeetee



Joined: 04 Jan 2009
Posts: 105

Post Growing Bacteria Reply with quote
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 ?
Tue Mar 24, 2009 7:10 pm View user's profile Send private message
gfoot



Joined: 05 Sep 2007
Posts: 269
Location: Brighton, UK

Post Reply with quote
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.
Tue Mar 24, 2009 10:19 pm View user's profile Send private message
bsguedes



Joined: 24 Feb 2009
Posts: 103
Location: Porto Alegre

Post Reply with quote
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.
Tue Mar 24, 2009 10:27 pm View user's profile Send private message
E2YnDlEMXiU



Joined: 17 Mar 2009
Posts: 1

Post Reply with quote
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.
Wed Mar 25, 2009 6:16 pm View user's profile Send private message
Bierdeckel



Joined: 05 Mar 2009
Posts: 7

Post Reply with quote
Its realy simple.

You could finde the answer without any coding. Math is your friend Very Happy

Even with coding its realy simple. My vb-code is just 13 lines long.
Fri Mar 27, 2009 3:15 pm View user's profile Send private message
horst



Joined: 06 Mar 2009
Posts: 24
Location: Germany

Post Reply with quote
I get 51 bacteria for day 8 Crying or Very sad

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

This challenge drives me crazy...
Mon Apr 20, 2009 10:28 am View user's profile Send private message
lukas



Joined: 26 Nov 2008
Posts: 34
Location: Germany

Post Reply with quote
horst wrote:
I get 51 bacteria for day 8 Crying or Very sad

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.
Mon Apr 20, 2009 11:41 am View user's profile Send private message
horst



Joined: 06 Mar 2009
Posts: 24
Location: Germany

Post Reply with quote
Ouch, thank you, I thought a bit too complicated. Got it now =)
Mon Apr 20, 2009 1:55 pm View user's profile Send private message
homeas



Joined: 13 Nov 2008
Posts: 10

Post Reply with quote
finally a challenge to relax,

why writing any code at all? - just use the windows (or pocket or xxx) calculator ...
Wed Apr 29, 2009 2:04 pm View user's profile Send private message
bsguedes



Joined: 24 Feb 2009
Posts: 103
Location: Porto Alegre

Post Reply with quote
homeas wrote:
finally a challenge to relax,

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


Very Happy

The main idea was to be an easy challenge =]
Wed Apr 29, 2009 2:54 pm View user's profile Send private message
contagious



Joined: 12 May 2009
Posts: 35
Location: Greece

Post Reply with quote
fibonacci sequence... again
Sun May 31, 2009 1:54 pm View user's profile Send private message
ellarso



Joined: 16 Nov 2008
Posts: 3
Location: Hamburg, Germany

Post Reply with quote
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!
Wed Jun 24, 2009 7:52 pm View user's profile Send private message
gfoot



Joined: 05 Sep 2007
Posts: 269
Location: Brighton, UK

Post Reply with quote
It is related, but discussion of exactly how should probably go in the "solved" forum...
Thu Jun 25, 2009 2:09 am View user's profile Send private message
psycore



Joined: 18 Feb 2009
Posts: 8

Post Reply with quote
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.
Wed Jul 01, 2009 5:45 pm View user's profile Send private message
Mosher



Joined: 21 Dec 2008
Posts: 3

Post Reply with quote
Found a rather simple solution via Access

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


Code:

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
Fri Jan 22, 2010 9:59 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.