-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexamples.c
77 lines (62 loc) · 2.85 KB
/
examples.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "bf.c"
#ifndef __TIMER__
#define __TIMER__
#endif
BF_FX(BF_SEQ_EAT,__TIMER__)
#if 1
// https://stackoverflow.com/questions/5165772/code-for-multiplying-two-one-digit-numbers-in-brainfuck
0xc * 0xa
BF((c,a),
G,R,G,L, // input numbers at cell #1 #2
B,
R, // go to cell #2
B,
D,R,I,R,I,L,L, // move data to cell #3 #4
E,
R,R, // go to cell #4
B,
D,L,L,I,R,R, // move data to cell #2
E,
L,L,L, // go to cell #1
D, // decrement cell #1
E,
R,R,O
) __TIMER__
#endif
#if 1
// https://esolangs.org/wiki/Brainfuck
hello world:
BF(,
I,I,I,I,I,I,I,I,B,R,I,I,I,I,B,R,I,I,R,I,I,I,R,I,I,I,R,I,L,L,L,L,D,E,R,I,R,I,R,D,R,R,I,B,L,E,L,D,E,R,R,A,R,D,D,D,A,I,I,I,I,I,I,I,A,A,I,I,I,A,R,R,A,L,D,A,L,A,I,I,I,A,D,D,D,D,D,D,A,D,D,D,D,D,D,D,D,A,R,R,I,A,R,I,I,A
) __TIMER__
#endif
#if 1
// http://brainfuck.org/isort.b
#define ISORT(...) BF((__VA_ARGS__,0), R,I,B,L,B,B,R,R,I,L,L,D,E,R,B,L,L,I,L,B,D,R,R,I,B,L,E,E,R,R,R,B,R,E,L,L,D,E,L,L,L,E,R,R,B,L,L,I,R,R,D,E,L,B,R,I,L,D,E,R,B,R,R,E,L,G,E,L,L,L,B,L,I,L,E,R,B,R,O,R,E)
insertion sort:
ISORT(3,1,1,3,1,2,2,3,2) __TIMER__
ISORT(3,1,7,9,5,2,6,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