Page 1 of 1

Text problems...

Posted: Sat Feb 09, 2008 12:51 pm
by Thomas Lehmann
Hi,

I assume I don't see the point also I have been of the opinion
that everything is clear: problem 93!

First of all - of course - I would try to solve the problem for
the given solution and - well - this has been no problem!

The final algorithm: The solution gets rejected:
Now - in my words - how I understood the problem and - may be -
someone could be so kind to correct this:
- collect all values for any digit combination (a, b, c, d) but each digit
can be used once!
- storing the calculated values under the key (a, b, c, d) that way
so that a < b < c < d.
- Finally I have to search for that key with a list of calculated values
to count (beginning by 1) until a hole occurs, example:
key a,b,c,d with the values = [1, 2, 4, 5, 6] --> count = 2, because 3 is missing!

Required Output (final solution): that key with biggest count!

What's wrong with it?

Re: Text problems...

Posted: Sat Feb 09, 2008 1:21 pm
by daniel.is.fischer
Nothing, that's correct. You didn't separate the digits by commata or spaces, did you?

Re: Text problems...

Posted: Sat Feb 09, 2008 1:39 pm
by Thomas Lehmann
No!

Here some data:
a) my rejected answer: 5689 (with 57 consecutive positive integers).
b) there are 11 ways of placing brackets.
c) for each b) there are 64 combinations of placing operators
between the digits.

Something wrong at b) or c) ?

kindly
Thomas

Re: Text problems...

Posted: Sat Feb 09, 2008 1:47 pm
by daniel.is.fischer
I find fewer distinct ways of placing parentheses. c) seems correct to me.
How do you create 39 with 5,6,8,9?

Re: Text problems...

Posted: Sat Feb 09, 2008 2:41 pm
by Thomas Lehmann
- It took a little to prepare some more debug outputs...
- I'm storing results under the key 5689 (a < b < c < d) for
any combinations of 5, 6, 8 and 9.
- 39 is not available for 5,6,8,9 but for (5 + 8) * (9 - 6) -> 5,8,9,6
- OK If you want to say I have to store each combination
separated I have done this as a try:
My result now: 4721 with 33 conseq. values from 1 to n but
Neither 4721 nor 1247 (a < b < c < d) has been accepted.

Re: Text problems...

Posted: Sat Feb 09, 2008 3:14 pm
by daniel.is.fischer
Drat, should've deleted my incorrect code. Found the correct, you shouldn't be able to create 40 with 5,6,8,9.

Re: Text problems...

Posted: Sat Feb 09, 2008 3:39 pm
by Thomas Lehmann
- Ok, storing each a,b,c,d combination
seperately I can not form 40 for 5689!
- When I'm trying to limit my four loops
to the condition a < b < c < d I get
3568 with 17 conseq. integer values (1..n)
and also rejected!
- Next I'm trying to do is to use float values,
because:
(5 + 6 / 9 ) * 8 = 40
(5.0 + 6.0 / 9.0) * 8.0 = 45.000000
May be I'm wrong to do so ....

Re: Text problems...

Posted: Sat Feb 09, 2008 3:48 pm
by daniel.is.fischer
Seems we found your problem, 1/2 = 0.5, ordinary arithmetics, not computer integer arithmetic.

Re: Text problems...

Posted: Sat Feb 09, 2008 4:15 pm
by Thomas Lehmann
Solved.

However - in opposite to many other euler problems
the author of this problem has avoided to say too
much (my opinion)!
It's a kind of "reading between the lines". :?

thanks for your kind help!
Thomas

Re: Text problems...

Posted: Sun Feb 10, 2008 2:50 am
by rayfil
(5.0 + 6.0 / 9.0) * 8.0 = 45.000000
I can easily see how you can go wrong using integer maths on a computer. You can also go wrong using floats but I can't figure out how you could ever get that result. Would you be kind enough to enlighten us on how your algo could produce that.

Re: Text problems...

Posted: Sun Feb 10, 2008 4:23 am
by JohnMorris
rayfil wrote:
(5.0 + 6.0 / 9.0) * 8.0 = 45.000000
I can easily see how you can go wrong using integer maths on a computer. You can also go wrong using floats but I can't figure out how you could ever get that result. Would you be kind enough to enlighten us on how your algo could produce that.
Just idle speculation:

Code: Select all

    int i = (5.0 + 6.0 / 9.0) * 8.0;
    printf ("%.6f\n", (float)i);
would do it.

Re: Text problems...

Posted: Mon Feb 11, 2008 5:55 pm
by Thomas Lehmann
Ahhh, the problem I have had was to recognize to
calculate in float arthmetic and - in addition - that not getting
an integer like result means to ignore the result. That's why I
have had some confusing output and the one you were talking
about simlpy results from an integer printed as a float value.

Now everything is fine! Thanks for help!