Anonymous user
Ramsey's theorem: Difference between revisions
m
→{{header|REXX}}: changed/added comments and whitespace, changed indentations.
(Added Elixir) |
m (→{{header|REXX}}: changed/added comments and whitespace, changed indentations.) |
||
Line 656:
=={{header|REXX}}==
Mainline programming was borrowed from '''C'''.
<lang rexx>/*REXX
/*
@.=0; #=17 /*initialize the node graph to zero. */
do d=0 for #; @.d.d=2; end /*d*/ /*set the diagonal elements to
do i=0 for # /*process each column in the array. */
j= (i+k) // # /*set a row,
@.i.j=1; @.j.i=1 /*set two array elements to unity. */
end /*i*/
k=k+k /*double the value of K for each loop*/
end /*while k≤8*/
/* [↓] display a connection grid. */
do r=0 for #; _=; do c=0 for # /*show each row, build
_=_ @.r.c /*add
end /*c*/
say left('', 9) translate(_,
end /*r*/
/*verify the sub-graphs connections. */
!.=0; ok=1 /*Ramsey's connections; OK (so far).*/
/* [↓] check
do v=0 for # /*check sub-graphs
do h=0 for # /*check column
if @.v.h==1 then !._v.v=!._v.v+1 /*if connected, then bump the counter.*/
end /*h*/ /* [↑] Note: we're counting each */
ok=ok & !._v.v==#%2 /*
end /*v*/ /*
/* [↓] check
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+1 /*if connected, then bump the counter.*/
end /*v*/ /* [↑] Note: we're counting each */
ok=ok & !._h.h==#%2 /*
end /*h*/ /*
say /* [↓] a yea─or─nay message. */
/*stick a fork in it, we're all done. */</lang>
'''output''' ('''17x17''' connectivity matrix):
<pre>
|