def convert(start, end, code, **kwargs): if start == CASM: if end == HBF: return ASM2HBF(code) elif end == BF: return HBF2BF(ASM2HBF(code), N, M) elif start == HBF: if end == BF: if 'n' in kwargs and 'm' in kwargs: return HBF2BF(code, N, M) else: return HBF2BF(code, N, M)
def test_set_brainfuck(): n = 8 m = 5 code = '''(set31)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_xor_brainfuck(): n = 8 m = 6 code = '''+(up)+(down)>+(up)(up)+(down)(down)< (xor)''' # xors 1100 with 1010 code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_while_not_flag_brainfuck(): n = 8 m = 6 code = '''>>>(on_flag3) <<<(while_not_flag3) > (end_while_not_flag3)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_print_ascii_brainfuck(): n = 10 m = 6 code = ''.join(''''(set{})(print_ascii)'''.format(ord(c)) for c in 'Hello World\n') code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_negate_number_brainfuck(): n = 10 m = 6 code = '''(inc)(inc)(inc) (negate_number)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_decrement_brainfuck(): n = 10 m = 6 code = '''(inc)(inc)(inc) (dec)(dec)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_printb_brainfuck(): n = 10 m = 6 code = '''(inc)(printb)(inc)(printb)(inc)(printb)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_add_next_brainfuck(): n = 8 m = 5 code = '+(up)+(up)+(up)+(up)+(up)+(up)+(down)(down)(down)(down)(down)(down)>+<(add)' # 0: 11111110, 1: 10000000 code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_copy_back_over_brainfuck(): n = 10 m = 6 code = '''(inc)(inc)(inc) > (inc) (copy_back_over1)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_and_brainfuck(): n = 8 m = 5 code = '''+(up)+(down)>+(up)(up)+(down)(down)<(and)''' # and 1100 with 1010 code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_neg_flag(): n = 10 m = 6 code = '''(up)(up)(up)(up)(up)(up)(up)+(up)+(down)(down)(down)(down)(down)(down)(down)(down)(neg_flag)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_set_flag_brainfuck(): n = 8 m = 5 code = '''(on_flag3)>(on_flag2)>(on_flag2)<(off_flag2)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_if_not_0_brainfuck(): n = 4 m = 5 code = '(up)(up)+++(down)(down)(left)(right){-}' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_if_flag_brainfuck(): n = 8 m = 5 code = '''(on_flag3) (if_flag3)${+(up)++(down)}$ (if_flag2)${+(up)++(down)}$''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_load_flag_brainfuck(): n = 8 m = 5 code = '''(on_flag3)(on_flag2)(on_flag4)(load_flag3)(load_flag2)''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_print_string_brainfuck(): n = 10 m = 6 string = 'Hello World\n' code = ''.join(''''(set{})>'''.format(ord(c)) for c in string) + '<'*len(string) + '(print_string)' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_equate_brainfuck(): n = 8 m = 6 code = '''+ (up) (up)+(down) (down) (equate5)${++++}$ ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_dist_from_flag_brainfuck(): n = 8 m = 5 code = '''(on_flag5)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>(on_flag3)<<(dist_to_flag5) +++++++++++++++++ ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_inc_brainfuck(): n = 8 m = 5 code = '''(inc)(inc)(inc)>(inc)(inc)(inc)(inc)(inc)(inc) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_advance_behind_flag_brainfuck(): n = 8 m = 5 code = '''+(on_flag3)>>>+(advance_behind_flag3) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_not_brainfuck(): n = 8 m = 5 code = '''+(up)+(up)(up)(up)+(down)(down)(down)(down)(not) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_advance_flag_brainfuck(): n = 8 m = 5 code = '''+(up)+(down)>(on_flag3)<(advance_flag3) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_copy_behind_to_flag_brainfuck(): n = 8 m = 5 code = '''(on_flag3)>>>+(up)++(down)<<<(copy_behind_to_flag3) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_go_back_to_flag(): n = 8 m = 5 code = '''(up)(up)(up)(left)(left)(left)+(down)(down)(down)(right)(right)(right) >>>>(go_back_to_flag3)+++++''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_go_to_flag_brainfuck(): n = 8 m = 5 code = '''+(up)+(up)+>(left)(left)(left)>>>>(up)+(down)<<<<(right)(right)(right)(down)(down)< (goto_flag3)++++++++++++++''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_equate_b_brainfuck(): n = 8 m = 5 code = '''+(up)+(down) (equate_b11)${-(up)-(up) +(down)(down)}$ (equate_b100)${+(up)+(up) +(down)(down)}$ ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_load_to_flag_brainfuck(): n = 8 m = 5 code = '''+(up)+(down)(save_all)>(on_flag3)< (load_to_flag3) ''' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)
def test_save_load_brainfuck(): n = 8 m = 5 code = '+(up)++(up)+++>' \ '(left)(left)(left)(left)+++(down)++++(down)+++++(right)(right)(right)(right)<' \ '(save_all)>(load_all)' code = HBF2BF(code, n, m) data = interpret(code) return transform_data(data, m, n)