Problem 108

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
luke
Posts: 5
Joined: Wed Jan 23, 2008 1:55 pm

Problem 108

Post by luke »

i don't know if it's correct to consider distinct two solution (x1,y1) (x2,y2)of the diophantine equation if and only if

x1!=x2 and y1!=y2 or x1!=y2 and y1!=x2

is it correct?
thanks
luke
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: problem 108

Post by daniel.is.fischer »

Identify a solution of [frac]1,x[/frac] + [frac]1,y[/frac] = [frac]1,n[/frac] with the set {x,y}. So order doesn't matter, (x,y) is the same as (y,x).
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
quilan
Posts: 182
Joined: Fri Aug 03, 2007 11:08 pm

Re: problem 108

Post by quilan »

Well, if they're the same, then it's the following logic:

(x1==x2 and y1==y2) or (x1==y2 and y1==x2)

So, take the inverse of that to test if they're distinct, and any of the following tests should work (DeMorgan's Law I think?):

!((x1==x2 and y1==y2) or (x1==y2 and y1==x2))
!(x1==x2 and y1==y2) and !(x1==y2 and y1==x2)
(x1!=x2 or y1!=y2) and (x1!=y2 or y1!=x2)


(1,2) (2,1) for example would be detected as distinct in your example (which it is not, they're the same set)
-> ((1!=2) and (2!=1)) or ((1!=1) and (2!=2))
-> (T and T) or (F and F)
-> T or F
-> T
ex ~100%'er... until the gf came along.
Image
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: problem 108

Post by daniel.is.fischer »

quilan wrote:Well, if they're the same, then it's the following logic:

(x1==x2 and y1==y2) or (x1==y2 and y1==x2)

So, take the inverse of that, and any of the following tests should work (DeMorgan's Law I think?):

!((x1==x2 and y1==y2) or (x1==y2 and y1==x2))
!(x1==x2 and y1==y2) and !(x1==y2 and y1==x2)
(x1!=x2 or y1!=y2) and (x1!=y2 or y1!=x2)


(1,2) (2,1) for example would be detected as distinct in your example (which it is not, they're the same set)
-> ((1!=2) and (2!=1)) or ((1!=1) and (2!=2))
-> (T and T) or (F and F)
-> T or F
-> T
You mean (x1,y1) == (x2,y2) [equiv] (x1 == x2 /\ y1 == y2) \/ (x1 == y2 /\ y1 == x2) ?
Yes. But in the example you gave, you swapped 'and' and 'or', the test should unfold:
(1,2) != (2,1) [equiv] (x1 != x2 \/ y1 != y2) /\ (x1 != y2 \/ y1 != x2)
[equiv] (1 != 2 \/ 2 != 1) /\ (1 != 1 \/ 2 != 2)
[equiv] (T \/ T) /\ (F \/ F) [equiv] T /\ F = F.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
quilan
Posts: 182
Joined: Fri Aug 03, 2007 11:08 pm

Re: problem 108

Post by quilan »

daniel.is.fischer wrote:You mean (x1,y1) == (x2,y2) [equiv] (x1 == x2 /\ y1 == y2) \/ (x1 == y2 /\ y1 == x2) ?
Yes. But in the example you gave, you swapped 'and' and 'or', the test should unfold:
(1,2) != (2,1) [equiv] (x1 != x2 \/ y1 != y2) /\ (x1 != y2 \/ y1 != x2)
[equiv] (1 != 2 \/ 2 != 1) /\ (1 != 1 \/ 2 != 2)
[equiv] (T \/ T) /\ (F \/ F) [equiv] T /\ F = F.
Yup. Was showing him an example where the logic he provided would fail to be the correct case (parent logic was: x1!=x2 and y1!=y2 or x1!=y2 and y1!=x2)
ex ~100%'er... until the gf came along.
Image
User avatar
daniel.is.fischer
Posts: 2400
Joined: Sun Sep 02, 2007 11:15 pm
Location: Bremen, Germany

Re: problem 108

Post by daniel.is.fischer »

Sorry, didn't link it with the first post.
Il faut respecter la montagne -- c'est pourquoi les gypaètes sont là.
luke
Posts: 5
Joined: Wed Jan 23, 2008 1:55 pm

Re: problem 108

Post by luke »

Hi,
yesterday I had a lot of thread open, I've made an error negating condition I'm use in my javaCode.
So I agree that (x1==x2 and y1==y2) or (x1==y2 and y1==x2) identify the same solution....

I've posted my question, cause my solution is wrong...so I've a bug in my code (I suppose some stuff related to float2int conversion)

thanks quilan&daniel

luca
Post Reply