Ramsey's theorem: Difference between revisions

Added 11l
(Added Wren)
(Added 11l)
Line 6:
A specially-nominated solution may be used, but if so it '''must''' be checked to see if if there are any sub-graphs that are totally connected or totally unconnected.
<br><br>
 
=={{header|11l}}==
{{trans|Python}}
 
<lang 11l>V a = (0.<17).map(i -> [‘0’] * 17)
V idx = [0] * 4
 
F find_group(mark, min_n, max_n, depth = 1)
I depth == 4
V prefix = I mark == ‘1’ {‘’} E ‘un’
print(‘Fail, found totally #.connected group:’.format(prefix))
L(i) 4
print(:idx[i])
R 1B
 
L(i) min_n .< max_n
V n = 0
L n < depth
I :a[:idx[n]][i] != mark
L.break
n++
 
I n == depth
:idx[n] = i
I find_group(mark, 1, max_n, depth + 1)
R 1B
R 0B
 
L(i) 17
a[i][i] = ‘-’
L(k) 4
L(i) 17
V j = (i + pow(2, k)) % 17
a[i][j] = a[j][i] = ‘1’
 
L(row) a
print(row.join(‘ ’))
 
L(i) 17
idx[0] = i
I find_group(‘1’, i + 1, 17) | find_group(‘0’, i + 1, 17)
print(‘no good’)
L.break
L.was_no_break
print(‘all good’)</lang>
 
{{out}}
<pre>
- 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 1 0 1 0 0 0 1 1 0 0 0 1 0
0 1 1 - 1 1 0 1 0 0 0 1 1 0 0 0 1
1 0 1 1 - 1 1 0 1 0 0 0 1 1 0 0 0
0 1 0 1 1 - 1 1 0 1 0 0 0 1 1 0 0
0 0 1 0 1 1 - 1 1 0 1 0 0 0 1 1 0
0 0 0 1 0 1 1 - 1 1 0 1 0 0 0 1 1
1 0 0 0 1 0 1 1 - 1 1 0 1 0 0 0 1
1 1 0 0 0 1 0 1 1 - 1 1 0 1 0 0 0
0 1 1 0 0 0 1 0 1 1 - 1 1 0 1 0 0
0 0 1 1 0 0 0 1 0 1 1 - 1 1 0 1 0
0 0 0 1 1 0 0 0 1 0 1 1 - 1 1 0 1
1 0 0 0 1 1 0 0 0 1 0 1 1 - 1 1 0
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 1 0 1 0 0 0 1 1 0 0 0 1 0 1 1 -
all good
</pre>
 
=={{header|360 Assembly}}==
1,480

edits