Anonymous user
Ramsey's theorem: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed wording of the output verification.
(Added Kotlin) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed wording of the output verification.) |
||
Line 740:
=={{header|REXX}}==
Mainline programming was borrowed from '''C'''.
<lang rexx>/*REXX program finds and displays a 17 node graph such that any four nodes are neither */
/*─────────────────────────────────────────── totally connected nor totally unconnected.*/
Line 747:
do k=1 by 0 while k<=8 /*K is doubled each time through loop.*/
do i=0 for #; j= (i+k) // # /*set a row,column and
@.i.j=
end /*i*/
k=k+k /*double the value of K for each loop*/
end /*
/* [↓] display a connection grid. */
do r=0 for #; _=; do c=0 for #
_=_ @.r.c
end /*c*/
say left('', 9) translate(_, "-", 2) /*display the constructed row. */
end /*r*/
/*verify the sub-graphs connections. */
!.=0;
/* [↓] check col. with row connections*/
do v=0 for # /*check the sub-graphs
do h=0 for # /*check column connections to the rows.*/
if @.v.h==1 then !._v.v= !._v.v +
end /*h*/ /* [↑] Note: we're counting each */
ok=ok & !._v.v==# %
end /*v*/ /* the total by two. */
/* [↓] check col. with row connections*/
do h=0 for # /*check the sub-graphs # of connections*/
do v=0 for # /*check the row connection to a column.*/
if @.h.v==1 then !._h.h= !._h.h +
end /*v*/ /* [↑] Note: we're counting each */
ok=ok & !._h.h==# %
end /*h*/ /* the total by two. */
say /*stick
say space("Ramsey's condition is"
▲'''output''' ('''17x17''' connectivity matrix):
<pre>
- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1
Line 799 ⟶ 797:
1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 -
Ramsey's condition is satisfied.
</pre>
|