I solved all cases of this puzzle except ‘05 Complex Out’. I have no idea why the answer should be 124 (instead my code gets 275 as solution). Any hint is appreciated.

Debug print your result at each step and see if there are any parsing/calculation errors. If you can’t find any, you may list out your results (f0, f1, f2…) here and we’ll see what else may be the issues.

This are my results for 120 < i < 130. The answer should be 124, but i have no idea why. All other cases work perfect.

step is 121

Re is -0.4529522

Im is -0.2372207

abs value is 0.511311409928747

step is 122

Re is -0.4529543

Im is -0.2370997

abs value is 0.511257125033862

step is 123

Re is -0.4529524

Im is -0.2372103

abs value is 0.511306727836043

step is 124

Re is -0.4529541

Im is -0.2371093

abs value is 0.511261417068481

step is 125

Re is -0.4529525

Im is -0.2372015

abs value is 0.51130279500562

step is 126

Re is -0.452954

Im is -0.2371173

abs value is 0.511264996177762

step is 127

Re is -0.4529527

Im is -0.2371942

abs value is 0.511299532827035

step is 128

Re is -0.4529538

Im is -0.237124

abs value is 0.511267993612557

step is 129

Re is -0.4529528

Im is -0.2371881

abs value is 0.511296797335672

I think your calculation may have gone wrong much earlier? Check from the beginning.

1 -0.65812 -0.452

2 -0.42930206559999995 0.1429404800000001

3 -0.4942517172942038 -0.574729286643711

4 -0.7441489928777194 0.11612187380585376

5 -0.11784656597525855 -0.6248239508873994

etc

I also have an error in the complex out case (complex in passes fine). However i get 123 and the answer is 124 i even checked and it seems that 123 is a good answer since the radius is 2.09, however there might be a chance that the calculations are wrong well before that.

Here is the pastebin link of all steps https://pastebin.com/cn9NBSfi

Daniel_Saranovic, not sure if there are some rounding errors in your parsing or calculating process? Your results are close to mine at the beginning but then begin to deviate more and more.

Thanks, that’s probably it, will have a look at it tomorrow.

I used the stof function to parse the float and used the c++11 complex class for complex multiplication so basically i did no rounding on my own .

Try doubles instead of floats, you probably just have a precision issue.

Double helped, also norm in c++11 doesn’t mean the norm in a mathematical sence (radius) so i needed to change that to abs. All tests now pass ok, thanks

I solved it, I made a mistake somewhere. Thanks for your help anyway.

I think there is something wrong about this puzzle. I tried not only my own algorithm but not less than four others I googled off the internet. All have the same issue, they solve all tasks but “05 Complex Out”. What could be so wrong about

```
int i;
double complex z = c;
for (i = 1; i < Limit; i++)
{
if (cabs(z) > 2.0) break;
z = cpow(z, 2.0) + c;
}
return(i);
```

My code worked in the end, so the puzzle is not wrong.

And around 200 others work too.

Well, how many did *not* work? The few that *do* work might satisfy the puzzle, but may be wrong (not however, but *especially* because of that). It’s not that I care too much, but again, as I said, I used a set of **five** iterator functions that all stem from actual working Mandelbrot renderers, all of them being rejected by the puzzle, so I conclude that either the puzzle is wrong or **all** of those functions. Also, I think the code I posted yesterday should be close to any reference implementation of the iterators function.

Do me a favor, would you? Try any one of the functions from here and give me one that satisfies “05 Complex Out” in terms of providing 124 instead of 123. I challenge you!

124 is plain incorrect here. For god’s sake, have the puzzle accept 123 *and* 124, why not?

The code you’ve pasted gives 124 for me, so I think you must have an error in how you are converting the input into the complex types?

The way the puzzle system works you can only have one correct answer.

For C/C++, the 123 instead of 124 can come from using stof instead of stod.

I passed all the test cases but when I submit the code it failed for last test case. What is wrong with my code?

Link: https://ideone.com/566Ymq

I switched from float to double but it did not solve.

In python you need to use a j and not a i. How can i change it ?

I had same problem as others, you have to use double.Parse, my mistake was I used float.Parse and then cast to double and got rounding errors many decimals down, which was why it worked for all cases except the one that was supposed to go for 124 iterations. Parsing the text “-0.65812” as a float and then casting to double will give the value -0.658119976520538. So you have to parse it as a double from the start.