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(input())
A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

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))
elif 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))
elif 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))
elif 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))
else:
  print('none')

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(A+B+C+D == 7):
  print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  exit()
if(A-B+C+D == 7):
  print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B-C+D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B+C-D == 7):
  print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
  exit()
if(A-B-C+D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
  exit()
if(A+B-C-D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
  exit()
if(A-B-C-D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
  exit()

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(A+B+C+D == 7):
  print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
if(A-B+C+D == 7):
  print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
if(A+B-C+D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
if(A+B+C-D == 7):
  print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
if(A-B-C+D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
if(A+B-C-D == 7):
  print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
if(A-B-C-D == 7):
  print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")

Submission status: Wrong Answer

Solution code:
n=[int(x) for x in input()]
for i in range((len(n)-1)**2):
    result=n[0]
    a=["-"]*len(n)
    for j in range(len(n)-1):
        if (i>>j &1)==1:
            result+=n[1]
            a[j]="+"
        else:
            result-=0
    if result==7:
        print(n[0],a[0],n[1],a[1],n[2],a[2],n[3],"=7")
        break

Submission status: Wrong Answer

Solution code:
n=[int(x) for x in input()]
for i in range((len(n)-1)**2):
    result=n[0]
    a=["-"]*len(n)
    for j in range(len(n)-1):
        if (i>>j &1)==1:
            result+=n[1]
            a[j]="+"
        else:
            result-=0
    if result==7:
        print(n[0],a[0],n[1],a[1],n[2],a[2],n[3],"=7")

Submission status: Wrong Answer

Solution code:
ABCD=list(map(int,list(input())))
for i in range(2**3):
    op=[0]*3
    for j in range(3):
        op[j]=i%2
        i//=2
    val=ABCD[0]
    for j in range(3):
        if op[j]==1:
            val+=ABCD[j+1]
        else:
            val-=ABCD[j+1]
    if val==7:
        ans=str(ABCD[0])
        for j in range(3):
            if op[j]==1:
                ans+="+"
            else:
                ans+="-"
            ans+=str(ABCD[j+1])
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
a,*x=list(map(int,input()))
for i in range(8):
    k=a
    ans=str(a)
    for j in range(3):
        if i>>j&1:
            k+=x[j]
            ans+="+"+str(x[j])
        else:
            k-=x[j]
            ans+="-"+str(x[j])
    if k==7:
        print(ans+"=7")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
cnt = len(n) -1
for i in range(2 ** cnt):
    op = ["-"] * cnt
    for j in range(cnt):
        if ((i >> j) & 1):
            op[cnt - 1 - 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:
s=input()
for bit in range(1<<3):
  ans=int(s[0])
  f=s[0]
  for i in range(3):
    if bit & (1<<i):
      ans+=int(s[i+1])
      f+="+s[i+1]"
    else:
      ans-=int(s[i+1])
      f+="-s[i+1]"
  if ans==7:
    print(f+"=7")
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,d = map(int,input())
op1,op2,op3 = "","",""
if a+b+c+d==7:
  op1,op2,op3 = "+","+","+"
elif a+b+c-d==7:
  op1,op2,op3 = "+","+","-"
elif a+b-c+d==7:
  op1,op2,op3 = "+","-","+"
elif a+b-c-d==7:
  op1,op2,op3 = "+","-","-"
elif a-b-c-d==7:
  op1,op2,op3 = "-","-","-"
elif a-b-c+d==7:
  op1,op2,op3 = "-","-","+"
elif a-b+c-d==7:
  op1,op2,op3 = "-","+","-"
elif a-b+c+d==7:
  op1,op2,op3 = "+","+","-"
print("%d%s%d%s%d%s%d=7" % (a,op1,b,op2,c,op3,d))

Submission status: Wrong Answer

Solution code:
# coding:utf-8
number = input()
# ABCD 隙間の数は3
n = 3

for bit in range(2 ** n):
    ope = ['-'] * n
    for i in range(n):
        if ((bit >> i) & 1):
            ope[n - 1 - i] = '+'
    # print(ope)
    ans = ''

    for num, op in zip(number, ope):
        ans += num + op
    # 最後の数だけ後ろにつける
    ans += number[-1]
    if eval(ans) == 7:
        print(ans + '==7')
        # パターンは1つだけでいいので、1つ出したら強制終了
        exit()

Submission status: Wrong Answer

Solution code:
A = list(input())
B = list(map(int, A))
for i in range(2**3):
  ans = B[0]
  for j in range(3):
    if ((i>>j) and 1):
      ans += B[j+1]
    else:
      ans -= B[j+1]
  if ans == 7:
    for k in range(3):
      print(B[k], end = "")
      if ((i>>k) and 1):
        print("+", end = "")
      else:
        print("-", end = "")
    print(B[3], end = "")
    print("=7")

Submission status: Wrong Answer

Solution code:
ABCD=input()
dic={}
dic[1]="+"
dic[0]="-"
for i in range(8):
  result=int(ABCD[0])
  kigou=[]
  for j in range(3):
    if ((i >> j) & 1):
      kigou+=[dic[1]]
      result+=int(ABCD[3-j])
    else:
      kigou+=[dic[0]]
      result-=int(ABCD[3-j])
  if result==7:
    print(ABCD[0]+kigou[0]+ABCD[1]+kigou[1]+ABCD[2]+kigou[2]+ABCD[3]+"=7")
    break

Submission status: Wrong Answer

Solution code:
ABCD = input()
ans = ''
def dfs(i, s):
    global ans
    s += ABCD[i]
    if i == 3:
        if eval(s) == 7:
            ans = s
        return
    i += 1
    dfs(i, s+'+')
    dfs(i, s+'-')
dfs(0, '')
print(ans+'+7')

Submission status: Wrong Answer

Solution code:
x=[int(k) for k in input()]
for i in range(2*3):
  total=x[0]
  bag=[""]*3
  for j in range(3):
    if (i>>j)&1:
      bag[j]="+"
      total+=x[j+1]
    else:
      bag[j]="-"
      total-=x[j+1]
  if total==7:
    print("{}{}{}{}{}{}{}=7".format(x[0],bag[0],x[1],bag[1],x[2],bag[2],x[3]))
    break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

num = [int(i) for i in input()]
print(num)

for s in range(2**3):
    total = num[0]
    op = [""] * 3
    for i in range(3):
        if (s >> i & 1):
            total += num[i+1]
            op[i] = "+"
        else:
            total -= num[i+1]
            op[i] = "-"
    if (total == 7):
        print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
        break

Submission status: Wrong Answer

Solution code:
S = input()
num = [int(S[i]) for i in range(4)]

for i in range(2 ** 3):
    ans = ''
    total = 0
    k = 3
    for j in range(3):
        if (i >> j) & 1:
            total += num[k]
            ans += ('+' + str(num[k]))
        else:
            total -= num[k]
            ans += ('-' + str(num[k]))
        k -= 1
    
    if total + num[0] == 7:
        print(str(num[0]) + ans + '=7')
        break

Submission status: Wrong Answer

Solution code:
from itertools import product

a = list(str(input()))


for bit in product([0,1],repeat=3): # 01の組み合わせ
    x = ["+","+","+"]
    for i,j in enumerate(bit): 
        #print(bit,i,j)
        print(j)
        if j == 1:
            x[i] = "-"
    if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7:
        print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+"=7")
        break

Submission status: Wrong Answer

Solution code:
from itertools import product

s = str(input())
a = list(s)

for i in product([0,1],repeat=3):# 01 に関する直積
    for j,k in enumerate(i): #jが添え字 kがbit
        x = ["+","+","+"]
        #print(i,j,k)
        if k == 1:
            x[j] == "-"
    if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7:
        print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+"=7")
        break

Submission status: Wrong Answer

Solution code:
s = input()
ls = ['+','+','+']
for i in range(2**len(ls)):
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = '-'
    if eval(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]) == 7:
        print(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]+"=7")
        break

Submission status: Wrong Answer

Solution code:
s = input()
ls = ['+','+','+']
for i in range(2**len(ls)):
    for j in range(len(ls)):
        if (i >> j) & 1 == 1:
            ls[j] = '-'
    if eval(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]) == 7:
        print(s[0]+ls[0]+s[1]+ls[1]+s[2]+ls[2]+s[3]+"=7")
        break

Submission status: Wrong Answer

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

for bit in range(1<<(n-1)):
  f=s[0]
  a=int(s[0])
  for i in range(n-1):
    if bit & (1<<i):
      f+="+"+s[i+1]
      a+=int(s[i+1])
    else:
      f+="-"+s[i+1]
      a-=int(s[i+1])
  if a==7:
    print(f+"=7")

Submission status: Wrong Answer

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

for bit in range(1<<(n-1)):
  f=s[0]
  a=int(s[0])
  for i in range(n-1):
    if bit & (1<<i):
      f+="+"+s[i+1]
      a+=int(s[i+1])
    else:
      f+="+"+s[i+1]
      a+=int(s[i+1])
  if a==7:
    print(f+"=7")

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
a=int(s[0])
for bit in range(1<<(n-1)):
  f=s[0]

  for i in range(n-1):
    if bit & (1<<i):
      f+="+"+s[i+1]
      a+=int(s[i+1])
    else:
      f+="+"+s[i+1]
      a+=int(s[i+1])
  if a==7:
    print(f+"=7")

Submission status: Wrong Answer

Solution code:
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    if sum ==7:
      return print(f+"=7")
      exit()
      
  else:
    dfs(i + 1, f + "+" + s[i + 1], sum+int(s[i+1]))
    dfs(i + 1, f + "-" + s[i + 1], sum-int(s[i+1]))



s=input()
n=len(s)
dfs(0, s[0],int(s[0]))

Submission status: Wrong Answer

Solution code:
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    if sum ==7:
      return print(f,"=7")
      exit()
      
  else:
    dfs(i + 1, f + "+" + s[i + 1], sum+int(s[i+1]))
    dfs(i + 1, f + "-" + s[i + 1], sum-int(s[i+1]))



s=input()
n=len(s)
dfs(0, s[0],int(s[0]))

Submission status: Wrong Answer

Solution code:
def dfs(i,f,sum):
  if i == n-1:
    if sum ==7:
      return print(f,"=7")
      exit()
      
  else:
    dfs(i + 1, f + "+" + s[i + 1], sum+int(s[i+1]))
    dfs(i + 1, f + "-" + s[i + 1], sum-int(s[i+1]))



s=input()
n=len(s)
dfs(0, s[0],int(s[0]))

Submission status: Wrong Answer

Solution code:
a,b,c,d = list(input())

ls = ["+"] * 3

print(ls)

for i in range(2**3):
    ls = ["+"] * 3
    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")

Submission status: Wrong Answer

Solution code:
a,b,c,d = list(input())

ls = ["+"] * 3

print(ls)

for i in range(2**3):
    ls = ["+"] * 3
    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")
        break

Submission status: Wrong Answer

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

ans = 7

for bit in range(2**(n-1)):
    tmp = s[0]
    total = int(tmp)
    for i in range(n-1):
        if (1<<i)&bit:
            total += int(s[i+1])
        else:
            total -= int(s[i+1])
    if total == ans:
        break
        
out_put = ''
for i in range(3):
    out_put += s[i]
    if (bit>>(2-i)) & 1:
        out_put += '+'
    else:
        out_put += '-'

out_put = out_put + s[3] + '=7'
print(out_put)

Submission status: Wrong Answer

Solution code:
s = input()
length = 4 # fixed

for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  ans = 0
  f = s[0]  
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f.replace('_','')+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
length = 4 # fixed

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  f = s[0]
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  # print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f.replace('_','')+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
length = 4 # fixed

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  f = s[0]
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      f += "-"
    else:
      f += "+"
    f += s[i + 1]
  print('d:',f)
  ans = eval(f)
  
  if ans == 7:
    print(f.replace('_','')+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
length = 4 # fixed

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  p = []
  f = s[0]
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      p.append(i)
      f += "_-"
    else:
      f += "_+"
    f += s[i + 1]
  # print('d:',f)
  ans = sum(map(int, f.split("_")))
  
  if ans == 7:
    print(f.replace('_','')+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
length = 4 # fixed

ans = 0
for bit in range(1<<(length-1)):  # for bit in range(2 ** (length-1)):
  p = []
  f = s[0]
  for i in range(length-1): 
    if bit & (1 << i):   # 0はプラス、1はマイナス
      p.append(i)
      f += "_-"
    else:
      f += "_+"      
    f += s[i + 1]
  # print('d:',f)  
  ans = sum(map(int, f.split("_")))
  
  if ans == 7:
    print(f.replace('_','')+'=7')

Submission status: Wrong Answer

Solution code:
abcd = input()
answers =[]

for i in range(2**3):
    a = int(abcd[0])
    b = int(abcd[1])
    c = int(abcd[2])
    d = int(abcd[3])
    plus_minus = [1,1,1]
    for j in range(3):
        if (i >> j)& 1:
            plus_minus[j] = -1
    ans = a + b*plus_minus[0] + c*plus_minus[1] + d*plus_minus[2]
    if ans == 7:
        pmw =[]
        for j in range(3):
            if plus_minus[j] == -1:
                pmw.append("-")
            else:
                pmw.append("+")
        print(str(a)+pmw[0]+str(b)+pmw[1]+str(c)+pmw[2]+str(d))
        break

Submission status: Wrong Answer

Solution code:
ABCD = str(input())
n = len(ABCD)-1
ABCD_ = ''
output = ''
for i in range(2**n):
  ABCD_ = ABCD[0]
  for j in range(n):
    if ((i  >> j)&1) == 1:
      ABCD_ = ABCD_ + '+' + ABCD[j+1]
    else:
      ABCD_ = ABCD_ + '-' + ABCD[j+1]
  if eval(ABCD_) == 7:
    output = ABCD_
print(output)

Submission status: Wrong Answer

Solution code:
S = input()
 
def ticket_sum(i, s, num):
    if i == len(S):
        if num == 7:
            print(s+"=7")
            return True
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)
 
    # "+"を入れる場合
    s1 = s[:pos]+"+"+s[pos:]
    num1 = num+int(s[pos])
    # "-"を入れる場合
    s2 = s[:pos]+"-"+s[pos:]
    num2 = num-int(s[pos])
    
    if ticket_sum(i+1, s1, num1):
        return
    elif ticket_sum(i+1, s2, num2):
        return

ticket_sum(1, S, int(S[0]))

Submission status: Wrong Answer

Solution code:

S=input()
num = len(S) - 1

for i in range(2**num):
    l = ['-']*num
    for j in range(num):
        if(i>>j)&1:
            l[num-j-1] = "+"

    formula=""
    for l_num,l_m in zip(S,l+[""]):
        formula = l_num+l_m

    if eval(formula)==7:
        print(formula+'=7')
        break

Submission status: Wrong Answer

Solution code:
import sys

S = input()

def ticket_sum(i, s, num, memo):
    if i == len(S):
        if num == 7:
            memo.append(s+"=7")
            return memo
        else:
            return
    
    # 数字を分ける場所
    pos = i - len(S)

    # "+"を入れる場合
    ticket_sum(i+1, s[:pos]+"+"+s[pos:], num+int(s[pos]), memo)
    # "-"を入れる場合
    ticket_sum(i+1, s[:pos]+"-"+s[pos:], num-int(s[pos]), memo)

    return memo

memo = []
ticket_sum(1, S, int(S[0]), memo)[0]

Submission status: Wrong Answer

Solution code:
S = list(input())
ops = []
lst = []

for i in range(8):
    ops.append(bin(i))
    ops[i] = ops[i][2:].zfill(3)
    print(ops[i])

for i in range(8):
    res = S[0]
    for j in range(3):
        if ops[i][j] == "0":
            res = res + "+" + S[j+1]
        else:
            res = res + "-" + S[j+1]
    if eval(res) == 7:
        res = res + "=7"
        lst.append(res)
        break

print(lst[0])

Submission status: Wrong Answer

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

ops = None
for i in range((n-1)**2):
  tmp = int(s[0])
  for j in range(0, n-1):

    if (i>>j)&1:
      tmp += int(s[j+1])
    else:
      tmp -= int(s[j+1])

  if tmp == 7:
    ops = i
    break

res = ""
for i in range(n):
  res += s[i]
  if i < n:
    if (ops>>i)&1:
      res += "+"
    else:
      res += "-"

print(res+"=7")

Submission status: Wrong Answer

Solution code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+s[i]+b+s[j]+c+s[k]+d)==7:
                print(str(a+s[i]+b+s[j]+c+s[k]+d)+"=7")
                break

Submission status: Wrong Answer

Solution code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+s[i]+b+s[j]+c+s[k]+d)==7:
                print(str(a+s[i]+b+s[j]+c+s[k]+d)+"=7")

Submission status: Wrong Answer

Solution code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+s[i]+b+s[j]+c+s[k]+d)==7:
                print(eval(a+s[i]+b+s[j]+c+s[k]+d))

Submission status: Wrong Answer

Solution code:
#ABC 079 C
a,b,c,d=list(input())
s="+-"

for i in range(2):
    for j in range(2):
        for k in range(2):
            if a+s[i]+b+s[j]+c+s[k]+d==7:
                print(eval(a+s[i]+b+s[j]+c+s[k]+d))

Submission status: Wrong Answer

Solution code:
ABCD = input()
if int(ABCD[0]) + int(ABCD[1]) + int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "+" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) + int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "+" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) - int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "-" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) + int(ABCD[1]) - int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "+" + ABCD[1] + "-" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) + int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "+" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) + int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "+" + ABCD[2] + "-" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) - int(ABCD[2]) + int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "-" + ABCD[2] + "+" + ABCD[3] + "=7")
elif int(ABCD[0]) - int(ABCD[1]) - int(ABCD[2]) - int(ABCD[3]) == 7: print(ABCD[0] + "-" + ABCD[1] + "-" + ABCD[2] + "-" + ABCD[3] + "=7")

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
import math

s=input()
t=[]
for i in range(4):
    t.append(int(s[i]))
temp=0
for i in range(2):
    temp+=(t[0]+t[1] if i==0 else t[0]-t[1])
    for j in range(2):
        temp+=(t[2] if j==0 else -t[2])
        for k in range(2):
            temp+=(t[3] if k==0 else -t[3])
            if temp==7:
                print(s[0]+('+' if i==0 else '-')+s[1]+('+' if j==0 else '-')+s[2]+('+' if k==0 else '-')+s[3]+'=7')
                sys.exit()
            else:
                temp=0

Submission status: Wrong Answer

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

if a + b + c + d == 7:
    print('%d+%d+%d+%d=7' % (a, b, c, d))
elif a - b + c + d == 7:
    print('%d-%d+%d+%d=7' % (a, b, c, d))
elif a + b - c + d == 7:
    print('%d+%d-%d+%d=7' % (a, b, c, d))
elif a + b + c - d == 7:
    print('%d+%d+%d-%d=7' % (a, b, c, d))
elif a - b - c + d == 7:
    print('%d-%d-%d+%d=7' % (a, b, c, d))
elif a - b + c - d == 7:
    print('%d-%d+%d-%d=7' % (a, b, c, d))
elif a - b - c - d == 7:
    print('%d-%d-%d-%d=7' % (a, b, c, d))

Submission status: Wrong Answer

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

if a + b + c + d == 7:
    print('%d+%d+%d+%d=7' % (a, b, c, d))
elif a - b + c + d == 7:
    print('%d-%d+%d+%d=7' % (a, b, c, d))
elif a + b - c + d == 7:
    print('%d+%d-%d+%d=7' % (a, b, c, d))
elif a + b + c - d == 7:
    print('%d+%d+%d-%d=7' % (a, b, c, d))
elif a - b - c + d == 7:
    print('%d-%d-%d+%d=7' % (a, b, c, d))
elif a - b + c - d == 7:
    print('%d-%d+%d-%d=7' % (a, b, c, d))
elif a - b - c - d == 7:
    print('%d-%d+%d-%d=7' % (a, b, c, d))

Submission status: Wrong Answer

Solution code:
li = []
s = input()
li2 = []
for i in range(4):
  li.append(int(s[i]))
n1 = 4
def func(n, t):
  if n == 1:
    if t == li[0]:
      return True
    else:
      return False
  if func(n-1, t+li[n-1]):
    li2.append('-')
    return True
  elif func(n-1, t-li[n-1]):
    li2.append('+')
    return True
  else:
    return False
if func(n1, 7):
  print("{0}{4}{1}{5}{2}{6}{3}=7".format(li[0], li[1], li[2], li[3], li2[0], li2[1], li2[2]))
  print(li2)

Submission status: Wrong Answer

Solution code:
li = []
s = input()
li2 = []
for i in range(4):
  li.append(int(s[i]))
n1 = 4
def func(n, t):
  if n == 0:
    if t == 0:
      return True
    else:
      return False
  elif func(n-1, t+li[n-1]):
    li2.append('-')
    return True
  elif func(n-1, t-li[n-1]):
    li2.append('+')
    return True
  else:
    return False
if func(n1, 7):
  print("{0}{4}{1}{5}{2}{6}{3}=7".format(li[0], li[1], li[2], li[3], li2[0], li2[1], li2[2]))

Submission status: Wrong Answer

Solution code:
li = []
s = input()
li2 = []
for i in range(4):
  li.append(int(s[i]))
n1 = 4
def func(n, t):
  if t < 0:
    return False
  elif n == 0:
    if t == 0:
      return True
    else:
      return False
  elif func(n-1, t+li[n-1]):
    li2.append('-')
    return True
  elif func(n-1, t-li[n-1]):
    li2.append('+')
    return True
  else:
    return False
if func(n1, 7):
  print("{0}{4}{1}{5}{2}{6}{3}=7".format(li[0], li[1], li[2], li[3], li2[0], li2[1], li2[2]))

Submission status: Wrong Answer

Solution code:
s = input()

for i in range(8): #全部で2**3=8通りの入れ方がある。
    s_temp = s[0]
    for j in range(3): #調べるのは数と数の間３つ
        if i >> j & 1: #もし２進法で右からj+1番目が1なら
            s_temp += "+" + s[j+1] #左からj+1番目の間に+を入れて
        else: #そうでなければ
            s_temp += "-" + s[j+1] #そこに-を入れる
    #+と-を入れ終わったら計算結果をチェックして
    if eval(s_temp) == 7: #もし合っているなら
        ans = s_temp + "=7"
        print(ans) #答えを表示する

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == 4:
        sum_list = []
        T = S
        text = ''
        for j, p in enumerate(p_list):
            if p == 1:
                sum_list.append(int(T[:1]))
            elif p == -1:
                sum_list.append(int(T[:1]) * -1)

            if len(text) == 0:
                text += T[:1]
            else:
                if p == 1:
                    text += '+' + T[:1]
                elif p == -1:
                    text += '-' + T[:1]
            T = T[1:]
        print(p_list, sum_list)
        ans = sum(sum_list)
        if ans == 7:
            text += '=7'
            print(text)
            exit()

        return

    for i in [1, -1]:
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (4)
    dfs(0, p_list)


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
import itertools


def sr(): return sys.stdin.readline().rstrip()


def ir(): return int(sr())


def lr(): return list(map(int, sr().split()))


S = sr()
ans = 0


def dfs(depth, p_list):
    global ans

    if depth == 4:
        sum_list = []
        T = S
        text = ''
        for j, p in enumerate(p_list):
            if p == 1:
                sum_list.append(int(T[:1]))
                text += T[:1] + '+'
            elif p == -1:
                sum_list.append(int(T[:1]) * -1)
                text += T[:1] + '-'
            T = T[1:]
        # print(p_list, sum_list, T)
        ans = sum(sum_list)
        if ans == 7:
            text = text[:-1]
            text += '=7'
            print(text)
            exit()

        return

    for i in range(2):
        p_list[depth] = i
        dfs(depth + 1, p_list)


def main():

    p_list = [0] * (4)
    dfs(0, p_list)

    print(ans)


main()

Submission status: Wrong Answer

Solution code:
s = str(input())
l = list(s)

for i in range(1 << len(s)-1):
    li = ''
    
    for j in range(len(s)):
        li += l[j]
        if j == len(s)-1:
            continue
        if i & (1 << j):
            li += '+'
        else:
            li += '-'
#     print(li)
    r = eval(li)
    if r == 7:
        break
        
print(li)

Submission status: Wrong Answer

Solution code:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            c = k + '=7'
            return c
        return
    ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]), 
    ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

    
    
n = input()

ans(0, int(n[0]), n[0])

Submission status: Wrong Answer

Solution code:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            c = k + '=7'
            return c
    else: 
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]), 
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])
        
        
n = input()

ans(0, int(n[0]), n[0])

Submission status: Wrong Answer

Solution code:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            print(k + '=7')
            exit()
    else:      #return ではなぜかけない？
        ans(i+1, j-int(n[i+1]), k+'-'+n[i+1]),
        ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

Submission status: Wrong Answer

Solution code:
A, B, C, D = list(input())
for n in range(4):
    formula = "{}{}{}{}{}{}{}".format(A, ["+", "-"][n & 1], B, ["+", "-"][(n >> 1) & 1], C, ["+", "-"][(n >> 2) & 1], D)
    if eval(formula) == 7:
        print(formula + "=7")
        quit()

Submission status: Wrong Answer

Solution code:
A, B, C, D = list(input())
for n in range(4):
    formula = "{}{}{}{}{}{}{}".format(A, ["+", "-"][n & 1], B, ["+", "-"][n >> 1 & 1], C, ["+", "-"][n >> 2 & 1], D)
    if eval(formula) == 7:
        print(formula + "=7")
        quit()

Submission status: Wrong Answer

Solution code:
def ans(i, j, k):
    if i == 3:
        if j == 7:
            return print(k + '=7')
        return 
    ans(i+1, j-int(n[i+1]), k+'-'+n[i+1])
    ans(i+1, j+int(n[i+1]), k+'+'+n[i+1])

n = input()

ans(0, int(n[0]), n[0])

Submission status: Wrong Answer

Solution code:
num = [int(i) for i in input()]
a, b, c, d = num[0], num[1], num[2], num[3]

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))
elif 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))
elif 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))
elif a - b - c - d == 7:
    print('{}-{}-{}-{}=7'.format(a, b, c, d))

Submission status: Wrong Answer

Solution code:
N = input()

op = ['+', '-']

for i in op:
    num = [int(n) for n in N]
    if i == '-':
        num[1] = num[1] * -1
    for j in op:
        if j == '-':
            num[2] = num[2] * -1
        for k in op:
            if k == '-':
                num[3] = num[3] * -1
                
            if num[0] + num[1] + num[2] + num[3] == 7:
                output_op = [i,j,k]
                
output = ''
for _ in range(3):
    output += N[_] + output_op[_]

output += N[3] + '=7'

print(output)

Submission status: Wrong Answer

Solution code:
s=input()

list_num=[]

Ans=['+'+i for i in s]
Ans[0]=s[0]
Ans.append('=7')

for i in s:
    list_num.append(int(i))
    
list_sum=sum(list_num)

if list_sum==7:
    print(''.join(Ans))
    
else:
    for i in range(3):
        if list_sum-2*list_num[i+1]==7:
            Ans[i+1]='-'+s[i+1]
            print(''.join(Ans))
            
        
        else:
            Ans=['-'+i for i in s]
            Ans[0]=s[0]
            Ans.append('=7')
            list_num=[-i for i in list_num]
            list_num[0]=-(list_num[0])
            list_sum=sum(list_num)
            for j in range(3):
                if list_sum-2*list_num[j+1]==7:
                    Ans[j+1]='+'+s[i+1]
                    print(''.join(Ans))