예제 #1
0
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)
예제 #2
0
def test_set_brainfuck():
    n = 8
    m = 5
    code = '''(set31)'''
    code = HBF2BF(code, n, m)
    data = interpret(code)
    return transform_data(data, m, n)
예제 #3
0
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)
예제 #4
0
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)
예제 #5
0
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)
예제 #6
0
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)
예제 #7
0
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)
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
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)
예제 #12
0
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)
예제 #13
0
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)
예제 #14
0
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)
예제 #15
0
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)
예제 #16
0
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)
예제 #17
0
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)
예제 #18
0
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)
예제 #19
0
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)
예제 #20
0
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)
예제 #21
0
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)
예제 #22
0
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)
예제 #23
0
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)
예제 #24
0
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)
예제 #25
0
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)
예제 #26
0
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)
예제 #27
0
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)
예제 #28
0
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)
예제 #29
0
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)