Growing Bacteria

AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post by AMindForeverVoyaging »

CodeX wrote:I think the page you get after solving a challenge points you to the Challenges form instead of the Challenges Solved one
Quite certainly not in every case, but for some challenges this seems to be what is happening.
meis
Posts: 16
Joined: Tue Aug 28, 2012 5:22 pm
Location: Italy

Post by meis »

I'm sorry, but I can't get how could in 8 days be 47 population. I have written a script which gives:
day: 1 - bacts: 0,1,0,0,0 - sum: 1
day: 2 - bacts: 1,0,1,0,0 - sum: 2
day: 3 - bacts: 1,1,0,1,0 - sum: 3
day: 4 - bacts: 1,1,1,0,1 - sum: 4
day: 5 - bacts: 2,1,1,1,0 - sum: 5
day: 6 - bacts: 2,2,1,1,1 - sum: 7
day: 7 - bacts: 3,2,2,1,1 - sum: 9
day: 8 - bacts: 4,3,2,2,1 - sum: 12
day: 9 - bacts: 5,4,3,2,2 - sum: 16

the array of bacts is the succession of days (batters at 1st day of life, batters at 2nd etc...)

What have I done wrong?

p.s. day 0 is 1,0,0,0,0
meis
Posts: 16
Joined: Tue Aug 28, 2012 5:22 pm
Location: Italy

Post by meis »

Oh, now I get it, I've made a mistake in the understanding of the moment of the reproduction. Done :D
Luk.Online
Posts: 3
Joined: Sun Oct 17, 2010 6:00 pm

Post by Luk.Online »

I think I've programmed the correct algorithm, but is the only way to figure out the answer by iterate

Code: Select all

while (amount < 1000000000000);
???
User avatar
CodeX
Posts: 350
Joined: Fri Oct 17, 2008 5:28 pm

Post by CodeX »

Luk.Online wrote:I think I've programmed the correct algorithm, but is the only way to figure out the answer by iterate

Code: Select all

while (amount < 1000000000000);
???
I'm not going to Fib, Lucas can solve it with a closed-form equation.
Luk.Online
Posts: 3
Joined: Sun Oct 17, 2010 6:00 pm

Post by Luk.Online »

I've got an equation for the growth but not for the death...

But when I've got one for the death, can I subtract them?
FrostyHacks
Posts: 1
Joined: Mon Jun 29, 2015 7:50 am

Post by FrostyHacks »

My solution to this was simply to write a C# app and keep track of the number of bacteria on each specific day.

So each day iteration would basically be the number of day 5 bacteria (those dead) increased by the amount from the previous day, so day 4 become day 5, day 3 become day 4, day 2 become day 3, day 1 become day 2, and day 1 is the addition of day 2+3 since those days result in new bacteria.

The total alive is just day 1+2+3+4 and the total dead is just the size of day 5

The code looks like this, you can simply hit enter to generate each new day and you'll see the totals and then skip through the days until you reach one high enough, or you could modify the code to just keep looping until the total count condition is met, I made this more general, you can put a different starting number in for example.
AMindForeverVoyaging
Forum Admin
Posts: 496
Joined: Sat May 28, 2011 9:14 am
Location: Germany

Post by AMindForeverVoyaging »

FrostyHacks, you are not supposed to post a complete solution in this section of the forum. That's what the "Challenges Solved" section is for. There, only the people who have solved a challenge can read the thread for that challenge. So it's perfectly fine to post all of your solutions there.
Bwill
Posts: 1
Joined: Tue Sep 08, 2015 3:37 pm

Post by Bwill »

So I just solved this using

Code: Select all

while (population < 1000000000000)
    growBacteria()
...
Yet I am curious about the "simple algebraic" and Fibonacci solutions, anyone mind PMing me those solutions?
eulerscheZahl
Posts: 58
Joined: Thu Nov 29, 2012 7:45 pm
Location: Germany

Post by eulerscheZahl »

As soon as you solved the challenge, you have access to the solution forum: http://www.hacker.org/forum/viewtopic.p ... c&start=15
Post Reply