Anonymous user
Ramsey's theorem: Difference between revisions
m
→{{header|REXX}}: added whitespace, change comments, used a better method of showing a negative result.
m (→{{header|REXX}}: added whitespace, change comments, used a better method of showing a negative result.) |
|||
Line 1,501:
=={{header|REXX}}==
Mainline programming was borrowed from '''C'''.
<lang rexx>/*REXX program finds
/*
@.=0; #=17 /*initialize the node graph to zero. */
do d=0 for #; @.d.d= 2
end /*d*/
do k=1 by 0 while k<=8 /*K is doubled each time through loop.*/
do i=0 for #;
@.i.j= 1;
end /*i*/
k= k + k
end /*k*/
/* [↓] display a connection grid. */
do r=0 for #; _=; do c=0 for # /*build rows; build column by column. */
_= _ @.r.c
end /*c*/
say left('', 9) translate(_, "
end /*r*/
!.=
do v=0 for
do h=0 for # /*check column connections to the rows.*/
if @.v.h==1 then !._v.v= !._v.v + 1 /*if connected, then bump the counter.*/
end /*h*/ /* [↑]
ok= ok & !._v.v==# % 2
end /*v*/ /* divide the total by two.
/* [↓] check col. with row connections*/
do h=0 for # /*check the
do v=0 for # /*check the row connection to a column.*/
if @.h.v==1 then !._h.h= !._h.h + 1 /*if connected, then bump the counter.*/
end /*v*/ /* [↑]
ok= ok & !._h.h==# % 2
end /*h*/ /* divide the total by two.
say /*stick a fork in it, we're all done. */
say space("Ramsey's condition is"
{{out|output|text= ('''17x17''' connectivity matrix):}}
<pre>
1
1 1
0 1 1
1 0 1 1
0 1 0 1 1
0 0 1 0 1 1
0 0 0 1 0 1 1
1 0 0 0 1 0 1 1
1 1 0 0 0 1 0 1 1
0 1 1 0 0 0 1 0 1 1
0 0 1 1 0 0 0 1 0 1 1
0 0 0 1 1 0 0 0 1 0 1 1
1 0 0 0 1 1 0 0 0 1 0 1 1
0 1 0 0 0 1 1 0 0 0 1 0 1 1
1 0 1 0 0 0 1 1 0 0 0 1 0 1 1
1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1
Ramsey's condition is satisfied.
|