def arithm_expr_target(x, target):
    """ Create arithmetic expression approaching target value
    :param x: allowed constants
    :param target: target value
    :returns: string in form 'expression=value'
    :complexity: huge
    """
    n = len(x)
    expr = [{} for _ in range(1 << n)]
    for i in range(n):
        expr[1 << i] = {x[i]: str(x[i])}
    all_ = (1 << n) - 1
    for S in range(3, all_ + 1):
        if expr[S] != {}:
            continue
        for L in range(1, S):
            if L & S == L:
                R = S ^ L
                for vL in expr[L]:
                    for vR in expr[R]:
                        eL = expr[L][vL]
                        eR = expr[R][vR]
                        expr[S][vL] = eL
                        if vL > vR:
                            expr[S][vL - vR] = '(%s-%s)' % (eL, eR)
                        if L < R:
                            expr[S][vL + vR] = '(%s+%s)' % (eL, eR)
                            expr[S][vL * vR] = '(%s*%s)' % (eL, eR)
                        if vR != 0 and vL % vR == 0:
                            expr[S][vL // vR] = '(%s/%s)' % (eL, eR)
    for dist in range(target + 1):
        for sign in [-1, +1]:
            val = target + sign * dist
            if val in expr[all_]:
                return '%s=%i' % (expr[all_][val], val)
    pass
