Ramsey's theorem: Difference between revisions
Content added Content deleted
(Ramsey's theorem in Yabasic) |
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
||
Line 10: | Line 10: | ||
{{trans|Python}} |
{{trans|Python}} |
||
< |
<syntaxhighlight lang="11l">V a = [[‘0’] * 17] * 17 |
||
V idx = [0] * 4 |
V idx = [0] * 4 |
||
Line 50: | Line 50: | ||
L.break |
L.break |
||
L.was_no_break |
L.was_no_break |
||
print(‘all good’)</ |
print(‘all good’)</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 76: | Line 76: | ||
=={{header|360 Assembly}}== |
=={{header|360 Assembly}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="360asm">* Ramsey's theorem 19/03/2017 |
||
RAMSEY CSECT |
RAMSEY CSECT |
||
USING RAMSEY,R13 base register |
USING RAMSEY,R13 base register |
||
Line 220: | Line 220: | ||
XDEC DS CL12 temp xdeco |
XDEC DS CL12 temp xdeco |
||
YREGS |
YREGS |
||
END RAMSEY</ |
END RAMSEY</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 244: | Line 244: | ||
=={{header|AWK}}== |
=={{header|AWK}}== |
||
<syntaxhighlight lang="awk"> |
|||
<lang AWK> |
|||
# syntax: GAWK -f RAMSEYS_THEOREM.AWK |
# syntax: GAWK -f RAMSEYS_THEOREM.AWK |
||
# converted from Ring |
# converted from Ring |
||
Line 270: | Line 270: | ||
exit(0) |
exit(0) |
||
} |
} |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 294: | Line 294: | ||
=={{header|BASIC256}}== |
=={{header|BASIC256}}== |
||
{{trans|FreeBASIC}} |
{{trans|FreeBASIC}} |
||
< |
<syntaxhighlight lang="basic256">global k, a, idx |
||
k = 1 |
k = 1 |
||
dim a(18,18) |
dim a(18,18) |
||
Line 357: | Line 357: | ||
next i |
next i |
||
return false |
return false |
||
end function</ |
end function</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |
||
Line 365: | Line 365: | ||
No issue with the code or the output, there seems to be a bug with Rosettacode's tag handlers. - aamrun |
No issue with the code or the output, there seems to be a bug with Rosettacode's tag handlers. - aamrun |
||
< |
<syntaxhighlight lang="c">#include <stdio.h> |
||
int a[17][17], idx[4]; |
int a[17][17], idx[4]; |
||
Line 426: | Line 426: | ||
puts("all good"); |
puts("all good"); |
||
return 0; |
return 0; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} (17 x 17 connectivity matrix): |
{{out}} (17 x 17 connectivity matrix): |
||
<pre> |
<pre> |
||
Line 451: | Line 451: | ||
=={{header|D}}== |
=={{header|D}}== |
||
{{trans|Tcl}} |
{{trans|Tcl}} |
||
< |
<syntaxhighlight lang="d">import std.stdio, std.string, std.algorithm, std.range; |
||
/// Generate the connectivity matrix. |
/// Generate the connectivity matrix. |
||
Line 507: | Line 507: | ||
writefln("%-(%(%c %)\n%)", mat); |
writefln("%-(%(%c %)\n%)", mat); |
||
mat.ramseyCheck.writeln; |
mat.ramseyCheck.writeln; |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
||
Line 530: | Line 530: | ||
=={{header|Elixir}}== |
=={{header|Elixir}}== |
||
{{trans|Erlang}} |
{{trans|Erlang}} |
||
< |
<syntaxhighlight lang="elixir">defmodule Ramsey do |
||
def main(n\\17) do |
def main(n\\17) do |
||
vertices = Enum.to_list(0 .. n-1) |
vertices = Enum.to_list(0 .. n-1) |
||
Line 585: | Line 585: | ||
end |
end |
||
Ramsey.main</ |
Ramsey.main</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 611: | Line 611: | ||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
{{trans|C}} {{libheader|Erlang digraph}} |
{{trans|C}} {{libheader|Erlang digraph}} |
||
< |
<syntaxhighlight lang="erlang">-module(ramsey_theorem). |
||
-export([main/0]). |
-export([main/0]). |
||
Line 683: | Line 683: | ||
++ [{wholly_connected,V1,V2,V3,V4} |
++ [{wholly_connected,V1,V2,V3,V4} |
||
|| {V1,V2,V3,V4,_,false} <- ListConditions]} |
|| {V1,V2,V3,V4,_,false} <- ListConditions]} |
||
end.</ |
end.</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
||
Line 708: | Line 708: | ||
{{trans|Ring}} |
{{trans|Ring}} |
||
{{trans|Go}} |
{{trans|Go}} |
||
< |
<syntaxhighlight lang="freebasic"> |
||
Dim Shared As Integer i, j, k = 1 |
Dim Shared As Integer i, j, k = 1 |
||
Dim Shared As Integer a(17,17), idx(4) |
Dim Shared As Integer a(17,17), idx(4) |
||
Line 771: | Line 771: | ||
Print Chr(10) & "Satisface el teorema de Ramsey." |
Print Chr(10) & "Satisface el teorema de Ramsey." |
||
End |
End |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 797: | Line 797: | ||
=={{header|Go}}== |
=={{header|Go}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="go">package main |
||
import "fmt" |
import "fmt" |
||
Line 871: | Line 871: | ||
} |
} |
||
fmt.Println("All good.") |
fmt.Println("All good.") |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 896: | Line 896: | ||
=={{header|J}}== |
=={{header|J}}== |
||
Interpreting this task as "reproduce the output of all the other examples", then here's a stroll to the goal through the J interpreter: < |
Interpreting this task as "reproduce the output of all the other examples", then here's a stroll to the goal through the J interpreter: <syntaxhighlight lang="j"> i.@<.&.(2&^.) N =: 17 NB. Count to N by powers of 2 |
||
1 2 4 8 |
1 2 4 8 |
||
1 #~ 1 j. 0 _1:} i.@<.&.(2&^.) N =: 17 NB. Turn indices into bit mask |
1 #~ 1 j. 0 _1:} i.@<.&.(2&^.) N =: 17 NB. Turn indices into bit mask |
||
Line 941: | Line 941: | ||
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 _ 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 _ 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 _</syntaxhighlight> |
||
To test if all combinations of 4 rows and columns contain both a 0 and a 1 |
To test if all combinations of 4 rows and columns contain both a 0 and a 1 |
||
<syntaxhighlight lang="j"> |
|||
<lang j> |
|||
comb=: 4 : 0 M. NB. All size x combinations of i.y |
comb=: 4 : 0 M. NB. All size x combinations of i.y |
||
if. (x>:y)+.0=x do. i.(x<:y),x else. (0,.x comb&.<: y),1+x comb y-1 end. |
if. (x>:y)+.0=x do. i.(x<:y),x else. (0,.x comb&.<: y),1+x comb y-1 end. |
||
Line 956: | Line 956: | ||
*./ (4 comb 17) checkRow ramsey 17 |
*./ (4 comb 17) checkRow ramsey 17 |
||
1 |
1 |
||
</syntaxhighlight> |
|||
</lang> |
|||
=={{header|Java}}== |
=={{header|Java}}== |
||
Translation of Tcl via D |
Translation of Tcl via D |
||
{{works with|Java|8}} |
{{works with|Java|8}} |
||
< |
<syntaxhighlight lang="java">import java.util.Arrays; |
||
import java.util.stream.IntStream; |
import java.util.stream.IntStream; |
||
Line 1,022: | Line 1,022: | ||
System.out.println(ramseyCheck(mat)); |
System.out.println(ramseyCheck(mat)); |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
<pre>[-, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1] |
<pre>[-, 1, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1] |
||
Line 1,045: | Line 1,045: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="julia">const a, idx = zeros(Int, 17, 17), zeros(Int, 4) |
||
function findgroup(typ, nmin, nmax, depth) |
function findgroup(typ, nmin, nmax, depth) |
||
Line 1,102: | Line 1,102: | ||
testnodes() |
testnodes() |
||
</ |
</syntaxhighlight>{{out}} |
||
<pre> |
<pre> |
||
- 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 |
||
Line 1,126: | Line 1,126: | ||
=={{header|Kotlin}}== |
=={{header|Kotlin}}== |
||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="scala">// version 1.1.0 |
||
val a = Array(17) { IntArray(17) } |
val a = Array(17) { IntArray(17) } |
||
Line 1,178: | Line 1,178: | ||
} |
} |
||
println("\nRamsey condition satisfied.") |
println("\nRamsey condition satisfied.") |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,204: | Line 1,204: | ||
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
< |
<syntaxhighlight lang="mathematica">g = CirculantGraph[17, {1, 2, 4, 8}] |
||
vl = VertexList[g]; |
vl = VertexList[g]; |
||
ss = Subsets[vl, {4}]; |
ss = Subsets[vl, {4}]; |
||
NoneTrue[ss, CompleteGraphQ[Subgraph[g, #]] &] |
NoneTrue[ss, CompleteGraphQ[Subgraph[g, #]] &] |
||
NoneTrue[ss, Length[ConnectedComponents[Subgraph[g, #]]] == 4 &]</ |
NoneTrue[ss, Length[ConnectedComponents[Subgraph[g, #]]] == 4 &]</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
[[File:Ramsey.png]] |
[[File:Ramsey.png]] |
||
Line 1,216: | Line 1,216: | ||
=={{header|Mathprog}}== |
=={{header|Mathprog}}== |
||
{{lines too long|Mathprog}} |
{{lines too long|Mathprog}} |
||
<lang>/*Ramsey 4 4 17 |
<syntaxhighlight lang="text">/*Ramsey 4 4 17 |
||
This model finds a graph with 17 Nodes such that no clique of 4 Nodes is either fully |
This model finds a graph with 17 Nodes such that no clique of 4 Nodes is either fully |
||
Line 1,229: | Line 1,229: | ||
clique{a in 1..(Nodes-3), b in (a+1)..(Nodes-2), c in (b+1)..(Nodes-1), d in (c+1)..Nodes} : 1 <= Arc[a,b] + Arc[a,c] + Arc[a,d] + Arc[b,c] + Arc[b,d] + Arc[c,d] <= 5; |
clique{a in 1..(Nodes-3), b in (a+1)..(Nodes-2), c in (b+1)..(Nodes-1), d in (c+1)..Nodes} : 1 <= Arc[a,b] + Arc[a,c] + Arc[a,d] + Arc[b,c] + Arc[b,d] + Arc[c,d] <= 5; |
||
end;</ |
end;</syntaxhighlight> |
||
This may be run with: |
This may be run with: |
||
< |
<syntaxhighlight lang="bash">glpsol --minisat --math R_4_4_17.mprog --output R_4_4_17.sol</syntaxhighlight> |
||
The solution may be viewed on [[Solution Ramsey Mathprog|this page]]. |
The solution may be viewed on [[Solution Ramsey Mathprog|this page]]. |
||
In the solution file, the first section identifies the number of nodes connected in this clique. In the second part of the solution, the status of each arc in the graph (connected=<tt>1</tt>, unconnected=<tt>0</tt>) is shown. |
In the solution file, the first section identifies the number of nodes connected in this clique. In the second part of the solution, the status of each arc in the graph (connected=<tt>1</tt>, unconnected=<tt>0</tt>) is shown. |
||
Line 1,238: | Line 1,238: | ||
=={{header|Nim}}== |
=={{header|Nim}}== |
||
{{trans|Kotlin}} |
{{trans|Kotlin}} |
||
< |
<syntaxhighlight lang="nim">var a: array[17, array[17, int]] |
||
var idx: array[4, int] |
var idx: array[4, int] |
||
Line 1,282: | Line 1,282: | ||
quit "\nRamsey condition not satisfied.", QuitFailure |
quit "\nRamsey condition not satisfied.", QuitFailure |
||
echo "\nRamsey condition satisfied."</ |
echo "\nRamsey condition satisfied."</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,307: | Line 1,307: | ||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |
||
This takes the [[#C|C]] solution to its logical extreme. |
This takes the [[#C|C]] solution to its logical extreme. |
||
< |
<syntaxhighlight lang="parigp"> |
||
check(M)={ |
check(M)={ |
||
Line 1,328: | Line 1,328: | ||
M=matrix(17,17,x,y,my(t=abs(x-y)%17);t==2^min(valuation(t,2),3)) |
M=matrix(17,17,x,y,my(t=abs(x-y)%17);t==2^min(valuation(t,2),3)) |
||
check(M)</ |
check(M)</syntaxhighlight> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
{{trans|Raku}} |
{{trans|Raku}} |
||
{{libheader|ntheory}} |
{{libheader|ntheory}} |
||
< |
<syntaxhighlight lang="perl">use ntheory qw(forcomb); |
||
use Math::Cartesian::Product; |
use Math::Cartesian::Product; |
||
Line 1,355: | Line 1,355: | ||
print join(' ' ,@$_) . "\n" for @a; |
print join(' ' ,@$_) . "\n" for @a; |
||
print 'OK'</ |
print 'OK'</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
||
Line 1,378: | Line 1,378: | ||
=={{header|Phix}}== |
=={{header|Phix}}== |
||
{{trans|Go}} |
{{trans|Go}} |
||
<!--< |
<!--<syntaxhighlight lang="phix">(phixonline)--> |
||
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> |
||
<span style="color: #004080;">sequence</span> <span style="color: #000000;">a</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'0'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">17</span><span style="color: #0000FF;">),</span><span style="color: #000000;">17</span><span style="color: #0000FF;">),</span> |
<span style="color: #004080;">sequence</span> <span style="color: #000000;">a</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">'0'</span><span style="color: #0000FF;">,</span><span style="color: #000000;">17</span><span style="color: #0000FF;">),</span><span style="color: #000000;">17</span><span style="color: #0000FF;">),</span> |
||
Line 1,437: | Line 1,437: | ||
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span> |
||
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">all_good</span><span style="color: #0000FF;">?</span><span style="color: #008000;">"Satisfies Ramsey condition.\n"</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"No good.\n"</span><span style="color: #0000FF;">))</span> |
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">all_good</span><span style="color: #0000FF;">?</span><span style="color: #008000;">"Satisfies Ramsey condition.\n"</span><span style="color: #0000FF;">:</span><span style="color: #008000;">"No good.\n"</span><span style="color: #0000FF;">))</span> |
||
<!--</ |
<!--</syntaxhighlight>--> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,466: | Line 1,466: | ||
{{trans|C}} |
{{trans|C}} |
||
< |
<syntaxhighlight lang="python">range17 = range(17) |
||
a = [['0'] * 17 for i in range17] |
a = [['0'] * 17 for i in range17] |
||
idx = [0] * 4 |
idx = [0] * 4 |
||
Line 1,514: | Line 1,514: | ||
exit() |
exit() |
||
print("all good")</ |
print("all good")</syntaxhighlight> |
||
{{out|Output same as C}} |
{{out|Output same as C}} |
||
Line 1,525: | Line 1,525: | ||
Kind of a translation of C (ie, reducing this problem to generating a printout of a specific matrix). |
Kind of a translation of C (ie, reducing this problem to generating a printout of a specific matrix). |
||
< |
<syntaxhighlight lang="racket">#lang racket |
||
(define N 17) |
(define N 17) |
||
Line 1,538: | Line 1,538: | ||
(λ(j) (case (dist i j) [(0) '-] [(1 2 4 8) 1] [else 0])))))) |
(λ(j) (case (dist i j) [(0) '-] [(1 2 4 8) 1] [else 0])))))) |
||
(for ([row v]) (displayln row))</ |
(for ([row v]) (displayln row))</syntaxhighlight> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |
||
(formerly Perl 6) |
(formerly Perl 6) |
||
{{Works with|rakudo|2018.08}} |
{{Works with|rakudo|2018.08}} |
||
<lang |
<syntaxhighlight lang="raku" line>my $n = 17; |
||
my @a = [ 0 xx $n ] xx $n; |
my @a = [ 0 xx $n ] xx $n; |
||
@a[$_;$_] = '-' for ^$n; |
@a[$_;$_] = '-' for ^$n; |
||
Line 1,557: | Line 1,557: | ||
die "Bogus!" unless 0 < $links < 6; |
die "Bogus!" unless 0 < $links < 6; |
||
} |
} |
||
say "OK";</ |
say "OK";</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
<pre>- 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
||
Line 1,580: | Line 1,580: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
Mainline programming was borrowed from '''C'''. |
Mainline programming was borrowed from '''C'''. |
||
< |
<syntaxhighlight lang="rexx">/*REXX program finds & displays a 17 node graph such that any four nodes are neither ···*/ |
||
/*────────────────────────────────────────── totally connected nor totally unconnected. */ |
/*────────────────────────────────────────── totally connected nor totally unconnected. */ |
||
@.=0; #=17 /*initialize the node graph to zero. */ |
@.=0; #=17 /*initialize the node graph to zero. */ |
||
Line 1,615: | Line 1,615: | ||
end /*h*/ /* divide the total by two. */ |
end /*h*/ /* divide the total by two. */ |
||
say /*stick a fork in it, we're all done. */ |
say /*stick a fork in it, we're all done. */ |
||
say space("Ramsey's condition is"word("'nt", 1+ok) 'satisfied.') /*show yea─or─nay.*/</ |
say space("Ramsey's condition is"word("'nt", 1+ok) 'satisfied.') /*show yea─or─nay.*/</syntaxhighlight> |
||
{{out|output|text= ('''17x17''' connectivity matrix):}} |
{{out|output|text= ('''17x17''' connectivity matrix):}} |
||
<pre> |
<pre> |
||
Line 1,640: | Line 1,640: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
< |
<syntaxhighlight lang="ring"> |
||
# Project : Ramsey's theorem |
# Project : Ramsey's theorem |
||
Line 1,666: | Line 1,666: | ||
see nl |
see nl |
||
next |
next |
||
</syntaxhighlight> |
|||
</lang> |
|||
Output: |
Output: |
||
<pre> |
<pre> |
||
Line 1,689: | Line 1,689: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
< |
<syntaxhighlight lang="ruby">a = Array.new(17){['0'] * 17} |
||
17.times{|i| a[i][i] = '-'} |
17.times{|i| a[i][i] = '-'} |
||
4.times do |k| |
4.times do |k| |
||
Line 1,704: | Line 1,704: | ||
end |
end |
||
puts "Ok" |
puts "Ok" |
||
</syntaxhighlight> |
|||
</lang> |
|||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,729: | Line 1,729: | ||
=={{header|Run BASIC}}== |
=={{header|Run BASIC}}== |
||
{{incorrect|Run BASIC|The task has been changed to also require demonstrating that the graph is a solution.}} |
{{incorrect|Run BASIC|The task has been changed to also require demonstrating that the graph is a solution.}} |
||
< |
<syntaxhighlight lang="runbasic">dim a(17,17) |
||
for i = 1 to 17: a(i,i) = -1: next i |
for i = 1 to 17: a(i,i) = -1: next i |
||
k = 1 |
k = 1 |
||
Line 1,745: | Line 1,745: | ||
next j |
next j |
||
print |
print |
||
next i</ |
next i</syntaxhighlight> |
||
<pre>-1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
<pre>-1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 |
||
1 -1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 |
1 -1 1 1 0 1 0 0 0 1 1 0 0 0 1 0 1 |
||
Line 1,766: | Line 1,766: | ||
=={{header|Sidef}}== |
=={{header|Sidef}}== |
||
{{trans|Ruby}} |
{{trans|Ruby}} |
||
< |
<syntaxhighlight lang="ruby">var a = 17.of { 17.of(0) } |
||
17.times {|i| a[i][i] = '-' } |
17.times {|i| a[i][i] = '-' } |
||
Line 1,782: | Line 1,782: | ||
((0 < links) && (links < 6)) || die "Bogus!" |
((0 < links) && (links < 6)) || die "Bogus!" |
||
}) |
}) |
||
say "Ok"</ |
say "Ok"</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,807: | Line 1,807: | ||
=={{header|Tcl}}== |
=={{header|Tcl}}== |
||
{{works with|Tcl|8.6}} |
{{works with|Tcl|8.6}} |
||
< |
<syntaxhighlight lang="tcl">package require Tcl 8.6 |
||
# Generate the connectivity matrix |
# Generate the connectivity matrix |
||
Line 1,851: | Line 1,851: | ||
puts [join $matrix \n] |
puts [join $matrix \n] |
||
ramseyCheck4 $matrix</ |
ramseyCheck4 $matrix</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |
||
Line 1,877: | Line 1,877: | ||
{{trans|C}} |
{{trans|C}} |
||
{{libheader|Wren-fmt}} |
{{libheader|Wren-fmt}} |
||
< |
<syntaxhighlight lang="ecmascript">import "/fmt" for Fmt |
||
var a = List.filled(17, null) |
var a = List.filled(17, null) |
||
Line 1,937: | Line 1,937: | ||
} |
} |
||
} |
} |
||
System.print("All good.")</ |
System.print("All good.")</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
Line 1,962: | Line 1,962: | ||
=={{header|Yabasic}}== |
=={{header|Yabasic}}== |
||
< |
<syntaxhighlight lang="yabasic">// Rosetta Code problem: https://www.rosettacode.org/wiki/Ramsey%27s_theorem |
||
// by Jjuanhdez, 06/2022 |
// by Jjuanhdez, 06/2022 |
||
Line 2,027: | Line 2,027: | ||
next i |
next i |
||
print color("gre") "\nSatisface el teorema de Ramsey.\n" |
print color("gre") "\nSatisface el teorema de Ramsey.\n" |
||
end</ |
end</syntaxhighlight> |
||
{{out}} |
{{out}} |
||
<pre>Same as FreeBASIC entry.</pre> |
<pre>Same as FreeBASIC entry.</pre> |