Ramsey's theorem: Difference between revisions

→‎{{header|PARI/GP}}: add checking code
(→‎{{header|PARI/GP}}: add checking code)
Line 310:
 
=={{header|PARI/GP}}==
{{incorrect|PARI/GP|The task has been changed to also require demonstrating that the graph is a solution.}}
This takes the [[#C|C]] solution to its logical extreme.
<lang parigp>
<lang parigp>matrix(17,17,x,y,my(t=(x-y)%17);t==2^min(valuation(t,2),3))</lang>
 
check(M)={
my(n=#M);
for(a=1,n-3,
for(b=a+1,n-2,
my(goal=!M[a,b]);
for(c=b+1,n-1,
if(M[a,c]==goal || M[b,c]==goal, next(2));
for(d=c+1,n,
if(M[a,d]==goal || M[b,d]==goal || M[c,d]==goal, next(3));
)
);
print(a" "b);
return(0)
)
);
1
};
 
<lang parigp>M=matrix(17,17,x,y,my(t=abs(x-y)%17);t==2^min(valuation(t,2),3))</lang>
check(M)</lang>
 
=={{header|Perl 6}}==