45
7
Reproductive strategy of oozes can be summarized as follows:
o O 8 oo
A population of oozes at generation N is described by a string, for example:
ooooo88ooOoOo8Ooooo8OOoo8Oo8Oo8oo8oooooo8OOooO88o
To compute the population at generation N+1, take one character randomly, and replace it by the result of ooze evolution:
- If
o
, replace byO
- If
O
, replace by8
- If
8
, replace byoo
Generation 0 is the one-character string o
. Your program or function should get a positive number N, and output the population of oozes at generation N. At each generation, each ooze should have the same chance (to within 1% accuracy) to evolve.
Test cases (actual results may vary due to randomness):
1 -> O
2 -> 8
3 -> oo
4 -> Oo
5 -> OO
10 -> OO8
20 -> oo8oooo
30 -> oOoooOO8O
100 -> 8o8oO8OOooOo8OOoo88oOO8OOO
200 -> 88OOo8oooo8OOoooOoOOO8O8OO88o8Oo8oooOooooooOo8OooO888
1000 -> 8Ooooo88OO8o8O8oooOOoOOO88oOoO88OOoO8OOOooOOo8OO88O8OO8OO8ooo8oOO8OoooO88OooooooooOo8oooOO8OO8Oo8Oooo8O88oooOooO8Oo8ooOOOOo8OooOo8OoooooooO8oOooooOooOO8oOO8ooo8Ooooo8ooo8ooOOooO8OOoO8oO8oo88ooo8oO8OO8o888oO8OOoO8o8ooO8O88OOOoO8oooO8OoOoOo88O88oo88ooo8oO8o8oOooOo
If your solution has running time of O(n), please specify it explicitly!
Can an output be an array? – Corsaka – 2019-11-20T15:01:05.057
Seems reasonable... – anatolyg – 2019-11-20T15:10:37.043
1does order matter? Can different stages be separated? – frank – 2019-11-20T18:29:11.690
1Of course the order matters! Otherwise, you could output a sorted string; it would be boring. – anatolyg – 2019-11-20T18:42:43.060
I wonder, if we take away the randomness, could this be a Turing complete program? Not too disimilar to a substitution style language – KrystosTheOverlord – 2019-11-21T00:12:48.047
oozes are not aware of death? – Thomas Ayoub – 2019-11-21T11:03:53.957
@KrystosTheOverlord No; oozes don't mate. If they mated, maybe. (the cells need to interact to generate a Turning complete system) – Yakk – 2019-11-21T16:32:09.507
@Yakk Ah, I see your point. It would require an interaction between two oozes to create a dynamic system. – KrystosTheOverlord – 2019-11-21T16:40:12.333
"If your solution has running time of O(n), please specify it explicitly!" Why? – S.S. Anne – 2019-11-21T21:32:49.547
1I am interested in any such solution because I thought for some time whether it was possible, and couldn't come to a conclusion. I don't always understand solutions in bizarre languages, so I don't want to miss such a great solution if it appears. – anatolyg – 2019-11-21T21:39:41.587