summaryrefslogtreecommitdiff
path: root/kerstboom.bf
blob: 1db1e228dbacca5141534990f46a50eb8c97225d (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Read in two digit number:
0    1    2    3    4
N0   N   N0cp  10   N1

,------------------------------------------------[>+>+<<-]>>[<<+>>-]>>,+[-<<<[-]>>>------------------------------------------------<++++++++++ [<<<[->+>+<<]>>[-<<+>>]>-] >[-<<<+>>>] ]<<<<
#
Now at 0

[-] (Clear N0)
>[<+>-]<


Layout now: N in 0


Place 'minus' in 1:
>+++++++++++++++++++++++++++++++++++++++++++++<

Place 'star' in 2:
>>++++++++++++++++++++++++++++++++++++++++++<<


Set line counter in 7:
>>>>>>>+<<<<<<<

Move N from 0 to 9 and 10:
[>>>>>>>>>+>+<<<<<<<<<<-]
Move N from 9 to 0 (leaving N in 10):
>>>>>>>>>[<<<<<<<<<+>>>>>>>>>-]<<<<<<<<<

Loop on (decreasing) N in 10:
>>>>>>>>>>[<<<<<<<<<<

	

	Move decreasing N from 10 to 3 4 and 5:
	>>>>>>>>>>[<<<<<+<+<+>>>>>>>-]<<<<<<<<<<
	Move N from 5 to 10:
	>>>>>[>>>>>+<<<<<-]<<<<<

	Set 3 and 4 to decreasing N minus 1:
	>>>->-<<<<

	Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3:
	>>>[<<.>>-]<<<


	Move line counter from 7 to 8 and 9:
	>>>>>>>[>+>+<<-]<<<<<<<

	Add line counter from 9 onto 7 and 8:
	>>>>>>>>>[<+<+>>-]<<<<<<<<<

	Now 7 holds line counter and 8 holds 2*line counter

	Subtract 1 from 8 to let it hold 2*line counter minus 1:
	>>>>>>>>-<<<<<<<<

	Print 'star' (in 2) times in 8 (which is 2*line counter minus 1) while zeroing 8:
	>>>>>>>>[<<<<<<.>>>>>>-]<<<<<<<<

	Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4:
	>>>>[<<<.>>>-]<<<<


	Add 1 to line counter (in 7):
	>>>>>>>+<<<<<<<

	Subtract 1 from decreasing N in 10:
	>>>>>>>>>>-<<<<<<<<<<

	>>>++++++++++.[-]<<<

	

Loop on (decreasing) N in 10
>>>>>>>>>>]<<<<<<<<<<

Move N from 0 to 3 and 4:
[>>>+>+<<<<-]

Subtract 1 from 3 and 4 to let them contain N minus 1:
>>>->-<<<<

Print 'minus' (in 1) times in 3 (which is N minus 1) while zeroing 3:
>>>[<<.>>-]<<<

Print 'star' (in 2) one time:
>>.<<

Print 'minus' (in 1) times in 4 (which is N minus 1) while zeroing 4:
>>>>[<<<.>>>-]<<<<

++++++++++.