A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
8
Task/Gray-code/K/gray-code-1.k
Normal file
8
Task/Gray-code/K/gray-code-1.k
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
xor: {~x=y}
|
||||
gray:{x[0],xor':x}
|
||||
|
||||
/ variant: using shift
|
||||
gray1:{(x[0],xor[1_ x;-1_ x])}
|
||||
|
||||
/ variant: iterative
|
||||
gray2:{x[0],{:[x[y-1]=1;~x[y];x[y]]}[x]'1+!(#x)-1}
|
||||
1
Task/Gray-code/K/gray-code-2.k
Normal file
1
Task/Gray-code/K/gray-code-2.k
Normal file
|
|
@ -0,0 +1 @@
|
|||
g2b:xor\
|
||||
9
Task/Gray-code/K/gray-code-3.k
Normal file
9
Task/Gray-code/K/gray-code-3.k
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
gray\1 0 0 0 0
|
||||
(1 0 0 0 0
|
||||
1 1 0 0 0
|
||||
1 0 1 0 0
|
||||
1 1 1 1 0
|
||||
1 0 0 0 1
|
||||
1 1 0 0 1
|
||||
1 0 1 0 1
|
||||
1 1 1 1 1)
|
||||
1
Task/Gray-code/K/gray-code-4.k
Normal file
1
Task/Gray-code/K/gray-code-4.k
Normal file
|
|
@ -0,0 +1 @@
|
|||
g2b1:*|{gray x}\
|
||||
1
Task/Gray-code/K/gray-code-5.k
Normal file
1
Task/Gray-code/K/gray-code-5.k
Normal file
|
|
@ -0,0 +1 @@
|
|||
g2b2:{c:#x;b:c#0;b[0]:x[0];i:1;do[#x;b[i]:xor[x[i];b[i-1]];i+:1];b}
|
||||
7
Task/Gray-code/K/gray-code-6.k
Normal file
7
Task/Gray-code/K/gray-code-6.k
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
gray:{x[0],xor':x}
|
||||
g2b:xor\
|
||||
/ using allcomb instead of 2_vs'!32 for nicer presentation
|
||||
allcomb:{+(x#y)_vs!_ y^x}
|
||||
a:(+allcomb . 5 2)
|
||||
`0:,/{n:2_sv x;gg:gray x;gb:g2b gg;n2:2_sv gb;
|
||||
,/$((2$n)," : ",$x," -> ",$gg," -> ",$gb," : ",(2$n2),"\n") }'a
|
||||
32
Task/Gray-code/K/gray-code-7.k
Normal file
32
Task/Gray-code/K/gray-code-7.k
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
0 : 00000 -> 00000 -> 00000 : 0
|
||||
1 : 00001 -> 00001 -> 00001 : 1
|
||||
2 : 00010 -> 00011 -> 00010 : 2
|
||||
3 : 00011 -> 00010 -> 00011 : 3
|
||||
4 : 00100 -> 00110 -> 00100 : 4
|
||||
5 : 00101 -> 00111 -> 00101 : 5
|
||||
6 : 00110 -> 00101 -> 00110 : 6
|
||||
7 : 00111 -> 00100 -> 00111 : 7
|
||||
8 : 01000 -> 01100 -> 01000 : 8
|
||||
9 : 01001 -> 01101 -> 01001 : 9
|
||||
10 : 01010 -> 01111 -> 01010 : 10
|
||||
11 : 01011 -> 01110 -> 01011 : 11
|
||||
12 : 01100 -> 01010 -> 01100 : 12
|
||||
13 : 01101 -> 01011 -> 01101 : 13
|
||||
14 : 01110 -> 01001 -> 01110 : 14
|
||||
15 : 01111 -> 01000 -> 01111 : 15
|
||||
16 : 10000 -> 11000 -> 10000 : 16
|
||||
17 : 10001 -> 11001 -> 10001 : 17
|
||||
18 : 10010 -> 11011 -> 10010 : 18
|
||||
19 : 10011 -> 11010 -> 10011 : 19
|
||||
20 : 10100 -> 11110 -> 10100 : 20
|
||||
21 : 10101 -> 11111 -> 10101 : 21
|
||||
22 : 10110 -> 11101 -> 10110 : 22
|
||||
23 : 10111 -> 11100 -> 10111 : 23
|
||||
24 : 11000 -> 10100 -> 11000 : 24
|
||||
25 : 11001 -> 10101 -> 11001 : 25
|
||||
26 : 11010 -> 10111 -> 11010 : 26
|
||||
27 : 11011 -> 10110 -> 11011 : 27
|
||||
28 : 11100 -> 10010 -> 11100 : 28
|
||||
29 : 11101 -> 10011 -> 11101 : 29
|
||||
30 : 11110 -> 10001 -> 11110 : 30
|
||||
31 : 11111 -> 10000 -> 11111 : 31
|
||||
Loading…
Add table
Add a link
Reference in a new issue