-
Notifications
You must be signed in to change notification settings - Fork 0
/
bf_to_start.py
executable file
·64 lines (63 loc) · 2.6 KB
/
bf_to_start.py
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
#!/usr/bin/env python3
# e.b -- compute e (c) 2016 Daniel B. Cristofani http://www.hevanet.com/cristofd/brainfuck/
# code = """>>>>++>+>++>+>>++<+[
# [>[>>[>>>>]<<<<[[>>>>+<<<<-]<<<<]>>>>>>]+<]>-
# >>--[+[+++<<<<--]++>>>>--]+[>>>>]<<<<[<<+<+<]<<[
# >>>>>>[[<<<<+>>>>-]>>>>]<<<<<<<<[<<<<]
# >>-[<<+>>-]+<<[->>>>[-[+>>>>-]-<<-[>>>>-]++>>+[-<<<<+]+>>>>]<<<<[<<<<]]
# >[-[<+>-]]+<[->>>>[-[+>>>>-]-<<<-[>>>>-]++>>>+[-<<<<+]+>>>>]<<<<[<<<<]]<<
# ]>>>+[>>>>]-[+<<<<--]++[<<<<]>>>+[
# >-[
# >>[--[++>>+>>--]-<[-[-[+++<<<<-]+>>>>-]]++>+[-<<<<+]++>>+>>]
# <<[>[<-<<<]+<]>->>>
# ]+>[>>>>]-[+<<<<--]++<[
# [>>>>]<<<<[
# -[+>[<->-]++<[[>-<-]++[<<<<]+>>+>>-]++<<<<-]
# >-[+[<+[<<<<]>]<+>]+<[->->>>[-]]+<<<<
# ]
# ]>[<<<<]>[
# -[
# -[
# +++++[>++++++++<-]>-.>>>-[<<<----.<]<[<<]>>[-]>->>+[
# [>>>>]+[-[->>>>+>>>>>>>>-[-[+++<<<<[-]]+>>>>-]++[<<<<]]+<<<<]>>>
# ]+<+<<
# ]>[
# -[
# ->[--[++>>>>--]->[-[-[+++<<<<-]+>>>>-]]++<+[-<<<<+]++>>>>]
# <<<<[>[<<<<]+<]>->>
# ]<
# ]>>>>[--[++>>>>--]-<--[+++>>>>--]+>+[-<<<<+]++>>>>]<<<<<[<<<<]<
# ]>[>+<<++<]<
# ]>[+>[--[++>>>>--]->--[+++>>>>--]+<+[-<<<<+]++>>>>]<<<[<<<<]]>>
# ]>
# ]"""
# code = code.replace(" ", "")
# code = code.replace("\n", "")
# pi calculation program in bf by Felix Nawothnig ([email protected])
code = "[<+>>>>>>>>++++++++++<<<<<<<-]>+++++[<+++++++++>-]+>>>>>>+[<<+++[>>[-<]<[>]<-]>>[>+>]<[<]>]>[[->>>>+<<<<]>>>+++>-]<[<<<<]<<<<<<<<+[->>>>>>>>>>>>[<+[->>>>+<<<<]>>>>>]<<<<[>>>>>[<<<<+>>>>-]<<<<<-[<<++++++++++>>-]>>>[<<[<+<<+>>>-]<[>+<-]<++<<+>>>>>>-]<<[-]<<-<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+<<<-[>>+<<-]<]<<<<+>>>>>>>>[-]>[<<<+>>>-]<<++++++++++<[->>+<-[>>>]>[[<+>-]>+>>]<<<<<]>[-]>+>[<<+<+>>>-]<<<<+<+>>[-[-[-[-[-[-[-[-[-<->[-<+<->>]]]]]]]]]]<[+++++[<<<++++++++<++++++++>>>>-]<<<<+<->>>>[>+<<<+++++++++<->>>-]<<<<<[>>+<<-]+<[->-<]>[>>.<<<<[+.[-]]>>-]>[>>.<<-]>[-]>[-]>>>[>>[<<<<<<<<+>>>>>>>>-]<<-]]>>[-]<<<[-]<<<<<<<<]"
out = ""
last = "";
count = 1
for c in code:
if c == last:
count += 1
elif last:
if count > 1 and last in "<>":
out += str(count) + last
elif count > 0 and last in "+-":
out += str(count) + last
else:
out += last*count
count = 1
last = c
out += last
out = out.replace("<", "<")
out = out.replace(">", ">")
out = out.replace("-", "-")
out = out.replace("+", "+")
out = out.replace("[", "??[")
out = out.replace("]", "??]")
out = out.replace(".", " PRINT ")
out = "s1000m>4!" + out
print(out);
print(code);