Problem:


Score : 300 points

Problem Statement

Sitting in a station waiting room, Joisino is gazing at her train ticket.

The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).

In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.

The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Constraints

0≤A,B,C,D≤9

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

ABCD

Output

Print the formula you made, including the part =7.

Use the signs + and -.

Do not print a space between a digit and a sign.

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

0 - 2 + 9 - 0 = 7 is also a valid solution.

Sample Input 3

3242

Sample Output 3

3+2+4-2=7



Sample input:
1222


Sample output:
1+2+2+2=7

Submission status: Wrong Answer

Solution code:
S = list(map(int, list(input())))
ans = ""
for bit in range(2**3):
    temp = S[0]

    for i in range(3):

        if bit & (1<<i):
            temp +=S[i+1]
        else:
            temp -= S[i+1]

    if temp == 7:
        for i in range(4):
            ans += str(S[i])

            if bit & (1 << i):
                ans += "+"
            else:
                ans += "-"
        ans += "=7"
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
s = input()
for bit in range(1 << 3):
    f = s[0]
    ans = int(s[0])
    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i+1])
            f += "+"
        else:
            ans -= int(s[i+1])
            f += "-"
        f += s[i+1]
    if ans == 7:
        print(f)
        break

Submission status: Wrong Answer

Solution code:
s=list(input())

for i in range(2**(len(s)-1)):
    f =['']*(len(s)-1)
    siki=''
    for j in range(len(s)-1):
        if(i>>j & 1):
            f[j] = '+'
        else:
            f[j] = '-'
    for k in range(len(s)-1):
        siki += s[k] + f[k]
    siki += s[-1]
    if eval(siki)==7:
        print(siki)

Submission status: Wrong Answer

Solution code:
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

if 7 == A+B+C+D:
    print(f'{A}+{B}+{C}+{D}=7')
elif 7 == A-B+C+D:
    print(f'{A}-{B}+{C}+{D}=7')
elif 7 == A-B-C+D:
    print(f'{A}-{B}-{C}+{D}=7')
elif 7 == A-B-C-D:
    print(f'{A}-{B}-{C}-{D}=7')
elif 7 == A+B-C+D:
    print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A+B-C-D:
    print(f'{A}+{B}-{C}-{D}=7')
elif 7 == A+B-C+D:
    print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A+B+C-D:
    print(f'{A}+{B}+{C}-{D}=7')

Submission status: Wrong Answer

Solution code:
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

if 7 == A+B+C+D:
    print(f'{A}+{B}+{C}+{D}=7')
elif 7 == A-B+C+D:
    print(f'{A}-{B}+{C}+{D}=7')
elif 7 == A-B-C+D:
    print(f'{A}-{B}-{C}+{D}=7')
elif 7 == A-B-C-D:
    print(f'{A}-{B}-{C}-{D}=7')
elif 7 == A+B-C+D:
    print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A+B-C+D:
    print(f'{A}+{B}-{C}-{D}=7')
elif 7 == A+B+C+D:
    print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A+B+C+D:
    print(f'{A}+{B}+{C}-{D}=7')

Submission status: Wrong Answer

Solution code:
from itertools import permutations, combinations_with_replacement

def calc(op, x, y):
    if op == "+":
        return x + y
    elif op == "-":
        return x - y
    elif op == "*":
        return x * y
    elif op == "/":
        return x / y
    else:
        raise Exception

def solve():
    A, B, C, D = map(int, list(input()))
    OP = combinations_with_replacement(["+", "-"], 3)
    for op in OP:
        O = permutations(op)
        s = set(O)
        for o in s:
            op1, op2, op3 = o
            tmp = 0
            try:
                tmp = calc(op3, calc(op2, calc(op1, A, B), C), D)
                if 0 <= abs(tmp - 7) <= 0.001:
                    print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
                    exit()
            except:
                continue

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from itertools import permutations, combinations_with_replacement
from decimal import Decimal

def calc(op, x, y):
    if op == "+":
        return x + y
    elif op == "-":
        return x - y
    elif op == "*":
        return x * y
    elif op == "/":
        return Decimal(x / y)
    else:
        raise Exception

def solve():
    A, B, C, D = map(int, list(input()))
    OP = combinations_with_replacement(["+", "-", "*", "/"], 3)
    for op in OP:
        O = permutations(op)
        s = set(O)
        for o in s:
            op1, op2, op3 = o
            tmp = 0
            try:
                tmp = calc(op3, calc(op2, calc(op1, A, B), C), D)
            except:
                continue
            if tmp == Decimal(7):
                print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
                exit()

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from itertools import permutations, combinations_with_replacement

def calc(op, x, y):
    if op == "+":
        return x + y
    elif op == "-":
        return x - y
    elif op == "*":
        return x * y
    elif op == "/":
        return x / y
    else:
        raise Exception

def solve():
    A, B, C, D = map(int, list(input()))
    OP = combinations_with_replacement(["+", "-", "*", "/"], 3)
    for op in OP:
        O = permutations(op)
        s = set(O)
        for o in s:
            op1, op2, op3 = o
            tmp = 0
            try:
                tmp = calc(op3, calc(op2, calc(op1, A, B), C), D)
            except:
                continue
            if tmp == 7:
                print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
                exit()

if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
n=input()

for i in range(2 ** 3):
    ans=[]

    co=["-","-","-"]

    for j in range(3):
        if ((i>>j)&1):
            co[j]="+"

        eq=n[0]+co[0]+n[1]+co[1]+n[2]+co[2]+n[3]

        if eval(eq)==7:
            ans=[].append(eq)

print(eq+"=7")

Submission status: Wrong Answer

Solution code:
X = list(map(int,list(input())))

for i in range(2**3+1):
  ans =[]
  for j in range(3):
    d = X[j+1]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    print(X[0],end="")
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Submission status: Wrong Answer

Solution code:
X = list(map(int,list(input())))

for i in range(2**4+1):
  ans =[]
  for j in range(1,4):
    d = X[j]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Submission status: Wrong Answer

Solution code:
X = list(map(int,list(input())))

for i in range(2**4+1):
  ans =[]
  for j in range(4):
    d = X[j]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Submission status: Wrong Answer

Solution code:
X = list(map(int,list(input())))

for i in range(2**4):
  ans =[]
  for j in range(4):
    d = X[j]*(-1)**((i >>j)&1)
    ans.append(d)
  if sum(ans) == 7:
    for i,a in enumerate(ans):
      if a>=0 and i>0:
        print("+",end="")
      print(a,end="")
    print("=7")
    exit()

Submission status: Wrong Answer

Solution code:
X = list(map(int,list(input())))

for i in range(2**3):
  t = X[0]
  for j in range(1,4):
    if(i >>j)&1:#1 is neg
      t -= X[j]
    else:
      t += X[j]
  if t == 7:
    ans = ""
    for k in range(4):
      ans+=str(X[k])
      if(i>>(k+1))&1:
        ans += "-"
      else:
        ans += "+"
    ans+="=7"
    print(ans)
    exit()

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement
ABCD = input()
for p in combinations_with_replacement(['-', '+'], 3):
    v = int(ABCD[0])
    ans = ABCD[0]
    for i in range(3):
        if p[i] == '-':
            v -= int(ABCD[i + 1])
            ans += '-' + ABCD[i + 1]
        else:
            v += int(ABCD[i + 1])
            ans += '+' + ABCD[i + 1]
    if v == 7:
        print(ans + '=7')
        exit()

Submission status: Wrong Answer

Solution code:
S = list(map(int, list(input())))

n = len(S)-1
for i in range(2 ** n):
    out = S[0]
    op = []
    for j in range(n):
        if (i>>j) & 1:
            out += S[j+1]
            op.append("+")
        else:
            out -= S[j+1]
            op.append("-")
    if out == 7:
        print(S[0], end='')
        for i in range(n):
            print(op[i], end='')
            print(S[i+1], end='')
        print("=7")

Submission status: Wrong Answer

Solution code:
X = str(input())

# 文字列を4つのintに分裂
# 二分検索でヒットしたらタス、そうでなければ引く、listに履歴を残しておく

for i in range(2**3):
  ans = int(X[0])
  list = []
  for j in range(3):
    if (i>>j & 1) == 1:
      ans += int(X[j+1])
      list.append("+")
    else:
      ans -= int(X[j+1])
      list.append("-")
  if ans == 7:
    break

ans = X[0]
for i in range(3):
  ans += list[i]
  ans += X[i+1]
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
p = list(map(int,s))

for x in range(2**3):
    ans = p[0]
    for y in range(3):
        if (x>>y)&1:
            ans += p[y+1]
        else:
            ans -= p[y+1]
    if ans == 7:
        kotae = format(x,"#05b")

kotae = kotae[2:]
print(kotae)
for z in range(3):
    print(str(p[z]),end="")
    if kotae[-z-1] == str(1):
        print("+",end="")
    else:
        print("-",end="")

print(str(p[3]) + "=7" )

Submission status: Wrong Answer

Solution code:
s = input()


for i in range(1 << 3):
    count = int(s[0])
    for j in range(1, 4):
        if i & (1 << j-1):
            count+=int(s[j])
        else:
            count-=int(s[j])
    
    if count == 7:
        ans = s[0] 
        for j in range(1, 4):
            if i & (1 << j):
                ans += '+'+s[j]
            else:
                ans += '-'+s[j]

        ans += '=7'
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
ABCD = list(input())

a, b, c, d = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])

if a+b+c+d == 7:
    print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))
elif a+b+c-d == 7:
    print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif a+b-c+d == 7:
    print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif a-b+c+d == 7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a-b-c+d == 7:
    print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
elif a+b-c-d == 7:
    print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif a-b+c-d == 7:
    print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a-b-c-d == 7:
    print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
#print(n)
ans=0
for bit in range(1 << (n - 1)):
    # 各場合で式 f を生成する
    #print("bit",bit,bin(bit))
    f = s[0]

    for i in range(n - 1):
        if bit & (1 << i):
            # フラグが立っているならば "+" を式の末尾に追加する
            f += "+"
        else:
          f+="-"
        f += s[i + 1]
        #print("i",i,"1 << i",bin(1 << i),"f",f)
    #print(f)
    ans=eval(f)
    if ans==7:
      f+="=7"
print(f)

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input())
p = (a+b)%7
q = (c+d)%7
r = (a-b)%7
s = (c-d)%7
if p == q:
        print('%d+%d-%d+%d=7' %(a,b,c,d))
        exit()
elif p == s:
        print('%d+%d-%d-%d=7' %(a,b,c,d))
        exit()
elif r == q:
        print('%d-%d-%d+%d=7' %(a,b,c,d))
        exit()
elif r == s:
        print('%d-%d-%d-%d=7' %(a,b,c,d))
        exit()
elif p+q ==7:
        print('%d+%d+%d+%d=7' %(a,b,c,d))
        exit()
elif p+s ==7:
        print('%d+%d+%d-%d=7' %(a,b,c,d))
        exit()
elif r+q ==7:
        print('%d-%d+%d+%d=7' %(a,b,c,d))
        exit()
elif r+s ==7:
        print('%d-%d+%d-%d=7' %(a,b,c,d))
        exit()

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input())
print('%d+%d+%d+%d=7' %(a,b,c,d))
p = (a+b)%7
q = (c+d)%7
r = (a-b)%7
s = (c-d)%7
if p == q:
        print('%d+%d-%d+%d=7' %(a,b,c,d))
        exit()
elif p == s:
        print('%d+%d-%d-%d=7' %(a,b,c,d))
        exit()
elif r == q:
        print('%d-%d-%d+%d=7' %(a,b,c,d))
        exit()
elif r == s:
        print('%d-%d-%d-%d=7' %(a,b,c,d))
        exit()
elif p+q ==7:
        print('%d+%d+%d+%d=7' %(a,b,c,d))
        exit()
elif p+s ==7:
        print('%d+%d+%d-%d=7' %(a,b,c,d))
        exit()
elif r+q ==7:
        print('%d-%d+%d+%d=7' %(a,b,c,d))
        exit()
elif r+s ==7:
        print('%d-%d+%d-%d=7' %(a,b,c,d))
        exit()

Submission status: Wrong Answer

Solution code:
n = [int(x) for x in input()]
for i in range(2 ** 3):
    a = list([str(n[0]), '-', str(n[1]), '-', str(n[2]), '-', str(n[3])])
    total = n[0]
    for j in range(3):
        if ((i >> j) & 1):
            a[int(2*j)+1] = '+'
            total = total + n[j+1]
        else:
            total = total - n[j+1]
    if total == 7:
        a.append('=7')
        print(''.join(a))

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, list(input()))
if a + b + c + d == 7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
elif a + b + c - d == 7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
if a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
if a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
if a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
if a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
if a - b + c - d == 7:
    print("{}-{}+{}-{}=7".format(a, b, c, d))
if a - b - c - d == 7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))

Submission status: Wrong Answer

Solution code:
numbers = list(map(int, list(input())))
ans = ""
for i in range(4 ** 2):
    total = 0
    formula = []
    for j in range(4):
        if (i >> j) & 1 == 1:
            formula.append("+")
            formula.append(str(numbers[j]))
            total += numbers[j]
        else:
            formula.append("-")
            formula.append(str(numbers[j]))
            total -= numbers[j]
        if total == 7 and j == 3:
            ans = "".join(formula)
            break
print(ans[1:] + "=7")

Submission status: Wrong Answer

Solution code:
numbers = list(map(int, list(input())))
ans = ""
for i in range(4 ** 2):
    total = 0
    formula = []
    for j in range(4):
        if (i >> j) & 1 == 1:
            formula.append("+")
            formula.append(str(numbers[j]))
            total += numbers[j]
        else:
            formula.append("-")
            formula.append(str(numbers[j]))
            total -= numbers[j]
        if total == 7:
            ans = "".join(formula)
            break
print(ans[1:] + "=7")

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input())
rt = str(A)
for bt in (True, False):
  for ct in (True, False):
    for dt in (True, False):
      tmp=7-A
      tmp = tmp-B if bt else tmp+B
      tmp = tmp-C if ct else tmp+C
      tmp = tmp-D if dt else tmp+D
      if tmp == 0:
        rt+="+" if bt else "-"
        rt+=str(B)
        rt+="+" if ct else "-"
        rt+=str(C)
        rt+="+" if dt else "-"
        rt+=str(D)
        rt+="=7"
        break

print(rt)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input())
rt = str(A)
for bt in (True, False):
  tmp=7-A
  for ct in (True, False):
    for dt in (True, False):
      tmp = tmp-B if bt else tmp+B
      tmp = tmp-C if ct else tmp+C
      tmp = tmp-D if dt else tmp+D
      if tmp == 0:
        rt+="+" if bt else "-"
        rt+=str(B)
        rt+="+" if ct else "-"
        rt+=str(C)
        rt+="+" if dt else "-"
        rt+=str(D)
        rt+="=7"
        break

print(rt)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,input())
rt = str(A)
for bt in (True, False):
  tmp=7-A
  for ct in (True, False):
    for dt in (True, False):
      tmp = tmp-B if bt else tmp+B
      tmp = tmp-C if ct else tmp+C
      tmp = tmp-D if dt else tmp+D
      if tmp == 0:
        rt+="+" if bt else "-"
        rt+=str(B)
        rt+="+" if ct else "-"
        rt+=str(C)
        rt+="+" if dt else "-"
        rt+=str(D)
        rt+="=7"

print(rt)

Submission status: Wrong Answer

Solution code:
L = list(input())
L = [int(L[i]) for i in range(len(L))]
n = 4

for mask in range(2**n):
    total = L[0]
    s = str(L[0])
    for i in range(1, n):
        num = L[i]
        # maskのi番目にフラグが立っているかどうか
        if mask & (1 << i):
            total += num
            s += '+' + str(num)
        else:
            total -= num
            s += '-' + str(num)
    if total == 7:
        print(s)
        exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = input()
for i in range(2**3):
    ls = ['+','+','+']
    for j in range(len(ls)):
        if (i << j) & 1:
            ls[j] = '-'
    if eval(a + ls[0] + b + ls[1] + c + ls[2] + d) == 7:
        print(a + ls[0] + b + ls[1] + c + ls[2] + d + '=7')
        exit()

Submission status: Wrong Answer

Solution code:
a = input()

for x in range(1<<3):
  s = a[0]

  print(x)
  for i in range(3):
    if x & (1<<i):
      s += '+'
    else:
      s += '-'
    s += a[i+1]

  if eval(s) == 7:
    print(s + '=7')
    exit()

Submission status: Wrong Answer

Solution code:
n=input()
l=len(n)-1
s=[n[0]]
for i in range(2**l):
    x=['-']*l
    for j in range(l):
          if ((i >> j) & 1):
              x[l - 1 - j]='+'
    for i in range(l):
        s.append(x[i])
        s.append(n[i+1])
    if eval(''.join(s))==7:
        s+='=7'
        print(''.join(s))
    s=[n[0]]

Submission status: Wrong Answer

Solution code:
s = list(input())
s = list(map(int, s))

ss = []

def numToString(s):
    if s >= 0:
        s = '+' + str(s)
    else:
        s = str(s)
    return s

for i in range(3):
    if s[0] + s[1] + s[2] + s[3] == 7:
        ss += str(s[0])
        ss += list(map(numToString, s[1:4]))
        ss = ''.join(ss)
        print(ss + '=7')
        exit()

    for j in range(2):
        if s[0] + s[1] + s[2] + s[3] == 7:
            ss += str(s[0])
            ss += list(map(numToString, s[1:4]))
            ss = ''.join(ss)
            print(ss + '=7')
            exit()

        for k in range(1):
            if s[0] + s[1] + s[2] + s[3] == 7:
                ss += str(s[0])
                ss += list(map(numToString, s[1:4]))
                ss = ''.join(ss)
                print(ss + '=7')
                exit()
            s[3] *= -1
        s[2] *= -1
    s[1] *= -1

Submission status: Wrong Answer

Solution code:
A,B,C,D = list(input())
print(A,B,C,D)

for i in range(2**3):
  argo = ["-","-","-"]
  
  for j in range(3):
    if i>>j & 1:
      argo[3-1-j] = "+"
  #print(argo)
  
  if eval(str(A)+argo[0]+str(B)+argo[1]+str(C)+argo[2]+str(D)) == 7:
    print(str(A)+argo[0]+str(B)+argo[1]+str(C)+argo[2]+str(D)+"=7")
    break

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)

for i in range(2**(l-1)):
    ans = 0
    a = s[0]
    for j in range(l-1):
        if i >> j == 0:
            a += '+' + s[j+1]
        else:
            a += '-' + s[j+1]
    ans = eval(a)
    if ans == 7:
        print(a + '=7')
        exit()

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)

for i in range(2**(l-1)):
    ans = 0
    a = s[0]
    for j in range(l-1):
        if i >> j == 0:
            a += '+' + s[j+1]
        else:
            a += '-' + s[j+1]
    ans = eval(a)
    if ans == 7:
        print(a + '=7')

Submission status: Wrong Answer

Solution code:
S = [a for a in input()]
N = [int(a) for a in S]
M = [-a for a in N]
S.insert(1, '+')
S.insert(3, '+')
S.insert(5, '+')

if sum(N) == 7:
    S = S
    print(''.join(S) + '=7')
    exit()

for i in range(1, 4):
    N[i] = -N[i]

    if sum(N) == 7:
        S[2 * i - 1] = '-'
        print(''.join(S) + '=7')
        exit()

for i in range(1, 4):
    M[i] = -M[i]
    if sum(M) == 7:
        S[2 * i - 1] = '+'
        print(''.join(S) + '=7')
        exit()

if N[0] + N[1] - N[2] - N[3] == 7:
    S[3] = '-'
    S[5] = '-'
elif N[0] - N[1] + N[2] - N[3] == 7:
    S[1] = '-'
    S[5] = '-'
elif N[0] - N[1] - N[2] + N[3] == 7:
    S[1] = '-'
    S[5] = '-'
print(''.join(S) + '=7')

Submission status: Wrong Answer

Solution code:
numbers = list(map(int, list(input())))
ans = ""
for i in range(3 ** 2):
    total = 0
    formula = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            formula.append("+")
            formula.append(str(numbers[j]))
            total += numbers[j]
        else:
            formula.append("-")
            formula.append(str(numbers[j]))
            total -= numbers[j]
    if total + numbers[3] == 7:
        formula.append("+")
        formula.append(str(numbers[3]))
        ans = "".join(formula)
        break
    elif total - numbers[3] == 7:
        formula.append("-")
        formula.append(str(numbers[3]))
        ans = "".join(formula)
        break
print(ans[1:] + "=7")

Submission status: Wrong Answer

Solution code:
numbers = list(map(int, list(input())))
ans = ""
for i in range(3 ** 2):
    total = 0
    formula = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            formula.append(str(numbers[j]))
            formula.append("+")
            total += numbers[j]
        else:
            formula.append(str(numbers[j]))
            formula.append("-")
            total -= numbers[j]
    if total + numbers[3] == 7:
        formula.append(str(numbers[3]))
        ans = "".join(formula)
        break
    elif total - numbers[3] == 7:
        formula.append(str(numbers[3]))
        ans = "".join(formula)
        break
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
numbers = list(map(int, list(input())))
ans = ""
for i in range(3 ** 2):
    total = 0
    formula = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            formula.append(str(numbers[j]))
            formula.append("+")
            total += numbers[j]
        else:
            formula.append(str(numbers[j]))
            formula.append("-")
            total -= numbers[j]
    if total + numbers[3] == 7:
        formula.append(str(numbers[3]))
        ans = "".join(formula)
    elif total - numbers[3] == 7:
        formula.append(str(numbers[3]))
        ans = "".join(formula)
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
from itertools import product

s=input()

for op in product(["+","-"],repeat=3):
  formula =""
  for i in range(3):
    formula+=s[i]+op[i]
  formula+=s[1]
  if eval(formula)==7:
    print(formula+"=7")
    exit()

Submission status: Wrong Answer

Solution code:
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
  op=["-"]*op_cnt
  for j in range(op_cnt):
    if ((i>>j)&1):
      op[j]="+"
  formula=""
  for p_n, p_o in zip(n, op + [""]): 
      formula += (p_n + p_o)
      print(formula)
  if eval(formula) == 7:
      print(formula + "=7")
      break

Submission status: Wrong Answer

Solution code:
List = [int(n) for n in input()]
ans = [List[0]] * 4
for i in range(8):
    for j in range(3):
        if i & (1<<j):
            ans[j+1]= -List[j+1]
        else:
            ans[j+1] = List[j+1]
    if sum(ans) == 7:
        break
ans = [str(ans[0])] + ['+' + str(x) if x>0 else str(x) for x in ans[1:]]
print("".join(ans) + '=7')

Submission status: Wrong Answer

Solution code:
s = input()

def dfs(i,tmp,sum):
    if i == 3:
        if sum == 7:
            print(tmp + "=7")
            exit()

    else:
        dfs(i+1, tmp +"+"+ s[i+1], sum + int(s[i+1]))
        dfs(i+1, tmp +"-"+ s[i+1], sum - int(s[i>1]))

print(dfs(0,s[0],int(s[0])))

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

A, B, C, D = map(int, list(input()))

for i in ('+', '-'):
    val = A
    for j in ('+', '-'):
        for k in ('+', '-'):
            if i=='+':
                val += B
            else:
                val -= B
            if j=='+':
                val += C
            else:
                val -= C
            if k=='+':
                val += D
            else:
                val -= D
            
            if val==7:
                print('{}{}{}{}{}{}{}=7'.format(A, i, B, j, C, k, D))
                exit()

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            if a + i*b + j*c + k*d == 7:
                op1 = ['-','+'][i==1]
                op2 = ['-','+'][j==1]
                op3 = ['-','+'][k==1]
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7')
                break

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])

for i in [-1,1]:
    for j in [-1,1]:
        for k in [-1,1]:
            if a + i*b + j*c + k*d == 7:
                op1 = ['-','+'][i==1]
                op2 = ['-','+'][j==1]
                op3 = ['-','+'][k==1]
                print(f'{a}{op1}{b}{op2}{c}{op3}{d}')
                break

Submission status: Wrong Answer

Solution code:
x = input()
a=[int(x[0]), int(x[1]), int(x[2]), int(x[3])]
op=['+', '-']
for i in range(2):
  for j in range(2):
    for k in range(2):
      ops = [op[i], op[j], op[k]]
      tmp = a[0]
      for l in range(3):
        if ops[l]=='+':
          tmp = tmp + a[l+1]
        else:
          tmp = tmp - a[l+1]
      print(ops, tmp)
      if tmp==7:
        break
    if tmp==7:
      break
  if tmp==7:
    break

print(str(a[0])+ops[0]+str(a[1])+ops[1]+str(a[2])+ops[2]+str(a[3])+'=7')

Submission status: Wrong Answer

Solution code:
s=list(input())

from itertools import product as pr

p = list(pr(['+','-'],repeat=3))

for ope in p:
    f = s[0] + ope[0] + s[1] + ope[2] + s[2] + ope[2] + s[3]

    if eval(f)==7:
        print(f+'=7')
        exit(0)

Submission status: Wrong Answer

Solution code:
import sys
import itertools


a, b, c, d = list(input())
print(a, b, c,d)

lst = ['-', '+']
for i, j, k in itertools.product(range(2), range(2), range(2)):
    ans = int(a)
    if i:
        ans += int(b)
    else:
        ans -= int(b)
    if j:
        ans += int(c)
    else:
        ans -= int(c)
    if k:
        ans += int(d)
    else:
        ans -= int(d)
        
    if ans == 7:
        print(a,lst[i],b,lst[j],c,lst[k],d,'=7',sep='')
        sys.exit()

Submission status: Wrong Answer

Solution code:
def keisan(n,m):
  global sum,S
  if n==0:
    sum += int(ABCD[m])
    S = S + '+' + str(ABCD[m])
  else:
    sum -= int(ABCD[m])
    S = S + '-' + str(ABCD[m])

ABCD = str(input())
sum = int(ABCD[0])
S = str(ABCD[0])

for i in range(2):
  sum = int(ABCD[0])
  S = str(ABCD[0])
  keisan(i,1)
  for j in range(2):
    keisan(j,2)
    for k in range(2):
      keisan(k,3)
      if sum == 7:
        print(S+'=7')

Submission status: Wrong Answer

Solution code:
import itertools
moji = str(input())
A,B,C,D = int(moji[0]),int(moji[1]),int(moji[2]),int(moji[3])

Bn = [B,B*-1]
Cn = [C,C*-1]
Dn = [D,D*-1]
flg = 0
for i,j,k in itertools.product(Bn, Cn,Dn):
    X = A + i + j + k
    if X == 7:
        break
    
print(str(A) + (str(i),"+"+str(i))[i >= 0]+ (str(j),"+"+str(j))[j >= 0]+ (str(k),"+"+str(k))[k >= 0])

Submission status: Wrong Answer

Solution code:
num = input()

ls = [0] * 3
for i in range(2 ** 3):
    make7 = int(num[0])
    for j in range(3):
        if (i >> j) & 1:
            make7 += int(num[j+1])
            ls[j] = "+"
        else:
            make7 -= int(num[j+1])
            ls[j] = "-"
    if make7 == 7:
        print(num[0] + ls[0] + num[1] + ls[1] + num[2] + ls[2] + num[3])
        exit()

Submission status: Wrong Answer

Solution code:
a=input()
A = int(a[0])

for flag in range(2**3):
	op=[]
	temp_a=A
	for i in range(3):
		if (flag>>i)&1==1:
			op.append("+")
			temp_a+=int(a[i+1])
		else:
			op.append("-")
			temp_a-=int(a[i+1])
	if temp_a==7:
		print(a[0],op[0],a[1],op[1],a[2],op[2],a[3],"=7")
		exit()

Submission status: Wrong Answer

Solution code:
n = input()
for i in range(2**3):
    ss =""
    ss +=n[0]
    for j in range(3):
        if((i >> j )&1==True):
            ss += "+"
            ss += n[j+1]
        else:
            ss += "-"
            ss += n[j+1]
    ans = eval(ss)
    if (ans == 7):
        ss += "=7"
        print(ss)

Submission status: Wrong Answer

Solution code:
abcd=str(input())
for i in range(2**4):
    list=[int(abcd[0])]
    symbol=[]
    for j in range(1,4):
        if (i>>j)&1==True:
            list.append(int(abcd[j]))
            symbol.append('+')
        else:
            list.append(int(abcd[j])*(-1))
            symbol.append('-')
    if sum(list)==7:
        print(abcd[0],symbol[0],abcd[1],symbol[1],abcd[2],symbol[2],abcd[3],"=7")
        break

Submission status: Wrong Answer

Solution code:
abcd=str(input())
for i in range(2**4):
    list=[int(abcd[0])]
    symbol=[]
    for j in range(1,4):
        if (i>>j)&1==True:
            list.append(int(abcd[j]))
            symbol.append('+')
        else:
            list.append(int(abcd[j])*(-1))
            symbol.append('')
    if sum(list)==7:
        print(list[0],symbol[0],list[1],symbol[1],list[2],symbol[2],list[3],"=7")
        break

Submission status: Wrong Answer

Solution code:
A = list(map(int,input()))    

for i in range(1<<3):
    culc = A[0]
    box = []
    for j in range(3):
        mask = 1<<j
        if mask & i != 1:
            culc += A[j+1]
            box.append('+')
        else:
            culc -= A[j+1]
            box.append('-')
    if culc == 7:
        break

ans = [0]*7
ans[::2]=[str(i) for i in A]
ans[1::2]=box
ans.append('=7')
print(''.join(ans))

Submission status: Wrong Answer

Solution code:
A,B,C,D = list(map(int, input()))

for op1 in ["+", "-"]:
    tmp1 = A+B if op1=="+" else A-B
    for op2 in ["+", "-"]:
        tmp2 = tmp1+C if op2=="+" else tmp1-C
        for op3 in ["+", "-"]:
            tmp3 = tmp2+D if op3=="+" else tmp2-D
            if tmp3==7:
                ans = str(A)+op1+str(B)+op2+str(C)+op3+str(D)+"=7"
                print(ans)
                break

Submission status: Wrong Answer

Solution code:
#
# abc079 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1222"""
        output = """1+2+2+2=7"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """0290"""
        output = """0-2+9+0=7"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """3242"""
        output = """3+2+4-2=7"""
        self.assertIO(input, output)


def resolve():
    N = input()

    for i in range(3):
        S = ""
        for j in range(3):
            S += N[j]
            bit = i >> j
            if bit == 0:
                op = "+"
            else:
                op = "-"
            S += op
        S += N[3]
        if eval(S) == 7:
            print(S+"=7")
            break


if __name__ == "__main__":
    # unittest.main()
    resolve()