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:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: 
                ans=ans[:-2]
                ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: 
                    ans=ans[:-2]
                    ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()
                else: ans=ans[:-2]


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: 
            ans=ans[:-2]
            ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: 
                ans=ans[:-2]
                ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: 
                    ans=ans[:-2]
                    ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

def main():
    a,b,c,d=map(int,list(input()))
    for i in range(2):
        ans=str(a)
        if i: ans+='-'
        else: ans+='+'
        ans+=str(b)
        for j in range(2):
            if j: ans+='-'
            else: ans+='+'
            ans+=str(c)
            for k in range(2):
                if k: ans+='-'
                else: ans+='+'
                ans+=str(d)
                if eval(ans)==7:
                    print(ans+'=7')
                    exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
abcd = list(str(input()))
for k in range(4):
    abcd[k] = int(abcd[k])
#print(abcd)

for i in range(1 << 3):
    memo = abcd
    info = [str(abcd[0])]
    for j in range(3):
        if (i >> j) & 1:
            memo[j + 1] *= -1
            info.append(str(memo[j + 1]))
        else:
            info.append("+"+str(memo[j + 1]))
    if sum(memo) == 7:
        info = "".join(info)
        print(info+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
abcd = list(str(input()))
for k in range(4):
    abcd[k] = int(abcd[k])
#print(abcd)

for i in range(1 << 3):
    memo = abcd
    info = [str(abcd[0])]
    for j in range(3):
        if (i >> j) & 1:
            memo[j + 1] *= -1
            info.append(str(abcd[j + 1]))
        else:
            info.append("+"+str(abcd[j + 1]))
    if sum(memo) == 7:
        info = "".join(info)
        print(info+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
abcd = list(str(input()))
for k in range(4):
    abcd[k] = int(abcd[k])
#print(abcd)

for i in range(1 << 3):
    memo = abcd
    info = [str(abcd[0])]
    for j in range(3):
        if (i >> j) & 1:
            memo[j + 1] *= -1
            info.append(str(abcd[j + 1]))
        else:
            info.append("+"+str(abcd[j + 1]))
    if sum(abcd) == 7:
        info = "".join(info)
        print(info+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
abcd = list(str(input()))
for k in range(4):
    abcd[k] = int(abcd[k])
#print(abcd)

for i in range(1 << 3):
    info = [str(abcd[0])]
    for j in range(3):
        if (i >> j) & 1:
            abcd[j + 1] *= -1
            info.append(str(abcd[j + 1]))
        else:
            info.append("+"+str(abcd[j + 1]))
    if sum(abcd) == 7:
        info = "".join(info)
        print(info+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product

n = input()
ops = product('+-', repeat=3)

for op in ops:
    fm = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(fm) == 7:
        print(fm + '=7')

Submission status: Wrong Answer

Solution code:

import sys
s = input()
a = []

for i in range(len(s)):
    num = int(s[i])
    a.append(num)


op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp = 0
            if op[i] == '+':
                temp = a[0] + a[1]
            else:
                temp = a[0] - a[1]
            if op[j] == '+':
                temp += a[2]
            else:
                temp -= a[2]
            if op[k] == '+':
                temp += a[3]
            else:
                temp -= a[3]

            if temp == 7:
                n1, n2, n3, n4 = map(str, [a[0], a[1], a[2], a[3]])
                #n1, n2, n3, n4 = a[0], a[1], a[2], a[3]
                print(n1 + op[i] + n2 + op[j] + n3 + op[k] + n4 + '=7')

Submission status: Wrong Answer

Solution code:

import sys
s = input()
a = []

for i in range(len(s)):
    num = int(s[i])
    a.append(num)

print(a)
op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp = 0
            if op[i] == '+':
                temp = a[0] + a[1]
            else:
                temp = a[0] - a[1]
            if op[j] == '+':
                temp += a[2]
            else:
                temp -= a[2]
            if op[k] == '+':
                temp += a[3]
            else:
                temp -= a[3]

            if temp == 7:
                n1, n2, n3, n4 = map(str, [a[0], a[1], a[2], a[3]])
                #n1, n2, n3, n4 = a[0], a[1], a[2], a[3]
                print(n1 + op[i] + n2 + op[j] + n3 + op[k] + n4 + '=7')
                sys.exit()

Submission status: Wrong Answer

Solution code:
s = input()
a = []

for i in range(len(s)):
    num = int(s[i])
    a.append(num)

print(a)
op = ['+', '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            temp = 0
            if op[i] == '+':
                temp = a[0] + a[1]
            else:
                temp = a[0] - a[1]
            if op[j] == '+':
                temp += a[2]
            else:
                temp -= a[2]
            if op[k] == '+':
                temp += a[3]
            else:
                temp -= a[3]

            if temp == 7:
                n1, n2, n3, n4 = map(str, [a[0], a[1], a[2], a[3]])
                #n1, n2, n3, n4 = a[0], a[1], a[2], a[3]
                print(n1 + op[i] + n2 + op[j] + n3 + op[k] + n4 + '=7')
                break

Submission status: Wrong Answer

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


import itertools
li = list(itertools.product({0, 1}, repeat=n))
for i in range(len(li)):
    total = int(s[0])
    shiki = s[0]
    for j in range(n):
        if li[i][j] == 0:
            total += int(s[j+1])
            shiki += "+"+s[j+1]
        else:
            total -= int(s[j+1])
            shiki += "-"+s[j+1]
    if total == 7:
        shiki += "="+str(7)
        print(shiki)
    else:
        pass

Submission status: Wrong Answer

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


import itertools
li = list(itertools.product({0, 1}, repeat=n))
for i in range(len(li)):
    total = int(s[0])
    shiki = s[0]
    for j in range(n):
        if li[i][j] == 0:
            total += int(s[j+1])
            shiki += "+"+s[j+1]
        else:
            total -= int(s[j+1])
            shiki += "-"+s[j+1]
    if total == 7:
        print(shiki)
    else:
        pass

Submission status: Wrong Answer

Solution code:
N = list(input())
N = [int(i) for i in N]
for i in range(2**3):
    cur = bin(i)[2::].zfill(3)
    c = N[0]
    n = []
    for i in range(3):
        if cur[i]=='0':
            n.append('+')
            c += N[i+1]
        else:
            n.append('-')
            c -= N[i+1]
    if c==7:
        m = '='
        print(N[0],n[0],N[1],n[1],N[2],n[2],N[3],m,c,sep=(''))

Submission status: Wrong Answer

Solution code:
abcd = input()

op = ['+', '-']

for op1 in op:
    for op2 in op:
        for op3 in op:
            tmp_ans = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
            if eval(tmp_ans) == 7:
                print(tmp_ans)

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1 << 3):
  answer = int(s[0])
  f = s[0] 
  
  for i in range(3):
    if bit & (1 << i):
      f+='+'
      answer+=int(s[i+1])
    else:
      f+='-'
      answer-=int(s[i+1])
    f+=s[i+1]

if answer==7:
  print(f + '=7')
  exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, list(input()))
for i in range(8):
    ans = a
    tb = b
    tc = c
    td = d
    op = format(i, "b").zfill(3)
    if op[0] == "1":
        tb = -tb
    elif op[1] == "1":
        tc = -tc
    elif op[2] == "1":
        td = -td
    ans += tb + tc + td
    if ans == 7:
        break
op = op.replace("0", "+").replace("1", "-") + "_"
s = ""
for n, o in zip([a, b, c, d], op):
    s += str(n) + o
print(s[:-1] + "=7")

Submission status: Wrong Answer

Solution code:
#ABC079C - Train Ticket
s = list(str(input()))
def dfs(i,f,wa):
    if i == 3:
        if wa == 7:
            print(f+"=7")
    else:
        dfs(i+1,f+"-"+s[i+1],wa-int(s[i+1]))
        dfs(i+1,f+"+"+s[i+1],wa+int(s[i+1]))

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

Submission status: Wrong Answer

Solution code:
s = str(input())
flag = 0

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 += "+"
        else:
            ans -= int(s[i+1])
            f += "-"
        f += s[i+1]
    
        if ans == 7:
            print(f + "=7")
            flag = 1
            break

    if flag:
        break

Submission status: Wrong Answer

Solution code:
s = str(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 += "+"
        else:
            ans -= int(s[i+1])
            f += "-"
        f += s[i+1]
    
        if ans == 7:
            print(f + "=7")
            exit()

Submission status: Wrong Answer

Solution code:
S = input().strip()
op = ["+","-"]
for op1 in op:
    for op2 in op:
        for op3 in op:
            if eval(S[0]+op1+S[1]+op2+S[2]+op3+S[3])==7:
                print(S[0]+op1+S[1]+op2+S[2]+op3+S[3]+"=7")
                break

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) - 1 #隙間の数

for i in range(2**3):
    tmp = s[0]
    for j in range(n):
        if (i >> j) & 1:
            tmp += "+"

        tmp += s[j+1]

    # print(tmp)

    list_tmp = tmp.split("+")

    res = 0
    for j in list_tmp:
        res += int(j)

    if res == 7:

        print(tmp + "=7")

Submission status: Wrong Answer

Solution code:
import sys
df = list(map(int, list(str(input()))))
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
df = list(map(int, list(str(input()))))
print(df)
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        print(j, counter)
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
df = list(map(int, list(str(input()))))
print(df)
counter = 0
for i in range(2**3):
    bin_i = format(i, '03b')
    counter += df[0]
    for j in range(3):
        print(j, counter)
        if bin_i[j] == '1':
            counter -= df[j+1]
        else:
            counter += df[j+1]
    if counter == 7:
        result = str(df[0])
        for j in range(3):
            if bin_i[j] =='0':
                result += '+' + str(df[j+1])
            else:
                result += '-' + str(df[j+1])
        result += '=7'
        print(result)
        sys.exit()
    else:
        print(counter)
        counter = 0

Submission status: Wrong Answer

Solution code:
n=input().split()
a=int(n[0][0])
b=int(n[0][1])
c=int(n[0][2])
d=int(n[0][3])
if a+b+c+d==7:
  print('a+b+c+d=7')
if a+b+c-d==7:
  print('a+b+c-d=7')
if a+b-c+d==7:
  print('a+b-c+d=7')
if a-b+c+d==7:
  print('a-b+c+d=7')
if a+b-c-d==7:
  print('a+b-c-d=7')
if a-b+c-d==7:
  print('a-b+c-d=7')
if a-b-c+d==7:
  print('a-b-c+d=7')
if a-b-c-d==7:
  print('a-b-c-d=7')

Submission status: Wrong Answer

Solution code:
def main():
    t = [int(i) for i in input()]
    op = ["+", "+", "+"]
    t_sum = sum(t)
    if t_sum == 7:
        print("{}+{}+{}+{}=7".format(t[0], t[1], t[2], t[3]))
    else:
        for i in range(1,4):
            if t_sum - 2*t[i] == 7:
                op[i-1] = "-"
                print("{}{}{}{}{}{}{}=7".format(t[0], op[0], t[1], op[1], t[2], op[2], t[3]))
                return
            elif t_sum - 2*i >7:
                for j in range(1, 2):
                    if t_sum - t[1:][i-j]*2 == 7:
                        op[i-1] = "-"
                        op[i-1-j] = "-"
                        print("{}{}{}{}{}{}{}=7".format(t[0], op[0], t[1], op[1], t[2], op[2], t[3]))
                        return

main()

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s) - 1  # スキマの数
for i in range(2**n):  # +, -の組み合わせ数
    p_or_m = ["-"] * n
    for j in range(n):
        if ((i >> j) & 1) == 1:
            p_or_m[n - 1 - j] = "+"

        formula = ""
        for k in range(n):
            formula += s[k] + p_or_m[k]
        formula += s[3]
        if eval(formula) == 7:
            print(formula+"=7")
            break

Submission status: Wrong Answer

Solution code:
import sys
from collections import defaultdict
a = input()
alst = [0, 1]
blst = [0, 1]
clst = [0, 1]
ans = ''
for i in alst:
    for j in blst:
        for k in clst:
            tmp = 0
            ans = ''
            if i == 0:
                tmp = int(a[0]) + int(a[1])
                ans = a[0] + '+' + a[1]
            else:
                tmp = int(a[0]) - int(a[1])
                ans = a[0] + '-' + a[1]
            if j == 0:
                tmp = tmp + int(a[2])
                ans = ans + '+' + a[2]
            else:
                tmp = tmp - int(a[2])
                ans = ans + '-' + a[2]
            if k == 0:
                tmp = tmp + int(a[3])
                ans = ans + '+' + a[3]
            else:
                tmp = tmp - int(a[3])
                ans = ans + '-' + a[3]
            if tmp == 7:
                print(ans)
                sys.exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = input()
kigou = ["+", "-"]
for i in range(8):
    bin_str = str(format(i, 'b').rjust(10, '0'))
    soeji_01 = int(bin_str[-1])
    soeji_02 = int(bin_str[-2])
    soeji_03 = int(bin_str[-3])
    shiki = "" + a + kigou[soeji_01] + b + \
        kigou[soeji_02] + c + kigou[soeji_03] + d
    if eval(shiki) == 7:
        print(shiki+"=7")

Submission status: Wrong Answer

Solution code:
calcNum = [1, -1]
calcSign = ["+", "-"]
n = list(input())
for a in range(2):
    for b in range(2):
        for c in range(2):
            if int(n[0]) + calcNum[a] * int(n[1]) + calcNum[b] * int(n[2]) + calcNum[c] * int(n[3]) == 7:
                string = n[0] + calcSign[a] + n[1] + \
                    calcSign[b] + n[2] + calcSign[c] + n[3]

print(string)

Submission status: Wrong Answer

Solution code:
s=str(input())

ans=int(s[0])
for i in range(2):
    if i==0:
        ans+=int(s[1])
        i='+'
    else:
        ans-=int(s[1])
        i='-'
    for j in range(2):
        if j==0:
            ans+=int(s[2])
            j='+'
        else:
            ans-=int(s[2])
            j='-'
        for k in range(2):
            if k==0:
                ans+=int(s[3])
                k='+'
            else:
                ans-=int(s[3])
                k='-'
            if ans==int(7):
                print(s[0]+str(i)+s[1]+str(j)+s[2]+str(k)+s[3]+'=7')
                break
            if ans!=int(7):
                ans=int(s[0])
        else:
            continue
        break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
s=str(input())

ans=int(s[0])
for i in range(2):
    if i==0:
        ans+=int(s[1])
        i='+'
    else:
        ans-=int(s[1])
        i='-'
    for j in range(2):
        if j==0:
            ans+=int(s[2])
            j='+'
        else:
            ans-=int(s[2])
            j='-'
        for k in range(2):
            if k==0:
                ans+=int(s[3])
                k='+'
            else:
                ans-=int(s[3])
                k='-'
            if ans==int(7):
                print(s[0]+str(i)+s[1]+str(j)+s[2]+str(k)+s[3]+'=7')
                break
            else:
                ans=int(s[0])
        else:
            continue
        break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
import sys
s = input()
a = int(s[0])
b=[]
for i in range(3):
    b.append(int(s[i+1]))

for i in range(8):
    tmp = a
    for j in range(3):
        if (i>>j) & 1 == 0:
            tmp += b[j]
            
        else:
            tmp -= b[j]
        if tmp ==7:
            ans = [str(a)]
            for k in range(3):
                if (i>>k) & 1 == 0:
                    ans.append("+")
                else:
                    ans.append("-")
                ans.append(str(b[k]))
            print(''.join(ans),end="")
            print("=7")
            sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
s = input()
a = int(s[0])
b=[]
for i in range(3):
    b.append(int(s[i+1]))
print(a,*b)
for i in range(8):
    tmp = a
    for j in range(3):
        if (i>>j) & 1 == 0:
            tmp += b[j]
            
        else:
            tmp -= b[j]
        if tmp ==7:
            ans = [str(a)]
            for k in range(3):
                if (i>>k) & 1 == 0:
                    ans.append("+")
                else:
                    ans.append("-")
                ans.append(str(b[k]))
            print(''.join(ans),end="")
            print("=7")
            sys.exit()

Submission status: Wrong Answer

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

for b in [B, -B]:
  for c in [C, -C]:
    for d in [D, -D]:
      if A+b+c+d==7:
        output=str(A)
        
        if b<0:
          output+=str(b)
        else:
          output+='+'+str(b)
          
        if c<0:
          output+=str(c)
        else:
          output+='+'+str(c)
          
        if d<0:
          output+=str(d)
        else:
          output+='+'+str(d)
          
print(output)

Submission status: Wrong Answer

Solution code:
s=list(input())
hs=[0]*4
for i in range(4):
    s[i]=int(s[i])
    hs[i]=s[i]

op=[[0],[1]]

for i in range(2):
    tmp=[]
    for j in op:
        tmp.append(j+[0])
        tmp.append(j+[1])
    op=tmp

for i in op:
    s=hs
    for j in range(3):
        if i[j]==0:
            s[j+1]=-s[j+1]
    if sum(s)==7:
        break

ans=str(s[0])
for i in range(3):
    if s[i+1]<0:
        ans+="-"
    else:
        ans+="+"
    ans+=str(abs(s[i+1]))
print(ans+"=7")

Submission status: Wrong Answer

Solution code:
s=input()
op=["+","-"]
for i in range(2):
    for j in range(2):
        for k in range(2):
            formula=s[0]+op[i]+s[1]+op[j]+s[2]+op[k]+s[3]
            if eval(formula)==7:
                print(formula+"==7")
                exit(0)

Submission status: Wrong Answer

Solution code:
x = input()
#print(x)
y = [int(c) for c in x]
#print(y)
a = y[0]
b = y[1]
c = y[2]
d = y[3]
if a+b+c+d == 7:
  print("a+b+c+d=7")
  exit()
if a+b+c-d == 7:
  print("a+b+c-d=7")
  exit()
if a+b-c+d == 7:
  print("a+b-c+d=7")
  exit()
if a-b+c+d == 7:
  print("a-b+c+d=7")
  exit()
if a-b-c+d == 7:
  print("a-b-c+d=7")
  exit()
if a-b+c-d == 7:
  print("a-b+c-d=7")
  exit()
if a-b-c-d == 7:
  print("a-b-c-d=7")
  exit()
if a+b-c-d == 7:
  print("a+b-c-d=7")
  exit()

Submission status: Wrong Answer

Solution code:
x = input()
#print(x)
y = [int(c) for c in x]
#print(y)
a = y[0]
b = y[1]
c = y[2]
d = y[3]
if a+b+c+d == 7:
  print("a+b+c+d=",a+b+c+d,sep='')
  exit()
if a+b+c-d == 7:
  print("a+b+c-d=",a+b+c-d,sep='')
  exit()
if a+b-c+d == 7:
  print("a+b-c+d=",a+b-c+d,sep='')
  exit()
if a-b+c+d == 7:
  print("a-b+c+d=",a-b+c+d,sep='')
  exit()
if a-b-c+d == 7:
  print("a-b-c+d=",a-b-c+d,sep='')
  exit()
if a-b+c-d == 7:
  print("a-b+c-d=",a-b+c-d,sep='')
  exit()
if a-b-c-d == 7:
  print("a-b-c-d=",a-b-c-d,sep='')
  exit()
if a+b-c-d == 7:
  print("a+b-c-d=",a+b-c-d,sep='')
  exit()

Submission status: Wrong Answer

Solution code:
A, B, C, D = list(map(int, input()))
for i in range(8):
  if i & 1 == 0:
    tb = B
  else:
    tb = -B
  if i & 2 == 0:
    tc = C
  else:
    tc = -C
  if i & 4 == 0:
    td = D
  else:
    tc = -D
  if sum([A, tb, tc, td]) == 7:
    break
print("%d%+d%+d%+d=7" % (A, tb, tc, td))

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,input())
if a+b+c+d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b+c-d==7:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a+b-c+d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b+c-+d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
elif a+b-c-d==7:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
elif a-b+c-d==7:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
elif a-b-c+d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
elif a-b-c-d==7:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
s=list(input())
n=len(s)
insert=0
ans=0
for i in range(2**(3)):
    f=(s[0])
    for j in range(3):
        if i&(1<<j):
            f=f+"+"
        else:
            f=f+"-"
        f=f+s[j+1]
      
   
    if eval(f)==7:
        print(f+"=7")

Submission status: Wrong Answer

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

for i in range(6):  
  if i==0 and a+b+c+d==7:
    print('%d+%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==1 and a+b+c-d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==2 and a+b-c+d==7:
    print('%d+%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==3 and a+b-c-d==7:
    print('%d+%d-%d-%d=7' %(a,b,c,d))
    exit()
  elif i==4 and a-b+c+d==7:
    print('%d-%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==5 and a-b+c-d==7:
    print('%d-%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==6 and a-b-c-d==7:
    print('%d-%d-%d-%d=7' %(a,b,c,d))
    exit()

Submission status: Wrong Answer

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

for i in range(6):  
  if i==0 and a+b+c+d==7:
    print('%d+%d+%d+%d=7' %(a,b,c,d))
    exit()
  elif i==1 and a+b+c-d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==2 and a+b-c+d==7:
    print('%d+%d-%d+%d=7' %(a,b,c,d))
    exit()
  elif i==3 and a+b-c-d==7:
    print('%d+%d-%d-%d=7' %(a,b,c,d))
    exit()
  elif i==4 and a-b+c+d==7:
    print('%d+%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==5 and a-b+c-d==7:
    print('%d-%d+%d-%d=7' %(a,b,c,d))
    exit()
  elif i==6 and a-b-c-d==7:
    print('%d-%d-%d-%d=7' %(a,b,c,d))
    exit()

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int, input()))
print(ABCD)

for i in range(8) :
    ret = ABCD[0]
    for j in range(3) :
        if (i >> j) & 1 :
            ret += ABCD[j+1]
        else :
            ret -= ABCD[j+1]
    
    if ret == 7 :
        op1 = '+' if (i >> 0) & 1 else '-'
        op2 = '+' if (i >> 1) & 1 else '-'
        op3 = '+' if (i >> 2) & 1 else '-'
        print('{}{}{}{}{}{}{}=7'.format(ABCD[0], op1, ABCD[1], op2, ABCD[2], op3, ABCD[3]))
        break

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int, input()))
print(ABCD)

for i in range(8) :
    ret = ABCD[0]
    for j in range(3) :
        if (i >> j) & 1 :
            ret += ABCD[j+1]
        else :
            ret -= ABCD[j+1]
    
    if ret == 7 :
        op1 = '+' if (i >> 0) & 1 else '-'
        op2 = '+' if (i >> 1) & 1 else '-'
        op3 = '+' if (i >> 2) & 1 else '-'
        print('{}{}{}{}{}{}{}'.format(ABCD[0], op1, ABCD[1], op2, ABCD[2], op3, ABCD[3]))
        break

Submission status: Wrong Answer

Solution code:
s=input()

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

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, list(input()))
if a+b+c+d == 7: print(a,"+", b, "+", c, "+", d, sep="")
elif a+b+c-d == 7: print(a,"+", b, "+", c, "-", d, sep="")
elif a+b-c+d == 7: print(a,"+", b, "-", c, "+", d, sep="")
elif a-b+c+d == 7: print(a,"-", b, "+", c, "+", d, sep="")
elif a+b-c-d == 7: print(a,"+", b, "-", c, "-", d, sep="")
elif a-b-c+d == 7: print(a,"-", b, "-", c, "+", d, sep="")
elif a-b+c-d == 7: print(a,"-", b, "+", c, "-", d, sep="")
else: print(a,"-", b, "-", c, "-", d, sep="")

Submission status: Wrong Answer

Solution code:
import sys
import  math
from statistics import *
from collections import *
from operator import itemgetter
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

a, b, c, d = input()
li = ["+", "-"]
def calc(a, b, c, d):
    s = 0
    for i in range(2):
        if i == 0:
            s = a + b
        else:
            s = a - b
        for j in range(2):
            if j == 0:
                s += c
            else:
                s -= c
            for k in range(2):
                if k == 0:
                    s += d
                else:
                    s -= d
                if s == 7:
                    print(str(a) + li[i] + str(b) + li[j] + str(c) + li[k] + str(d) + "=7")
                    return
calc(int(a),int(b), int(c), int(d))

Submission status: Wrong Answer

Solution code:
l = list(input())

for i in range(1<<(len(l)-1)):
  s = l[0]
  for j in range(len(l)-1):
    if (i>>j) & 1:
      s += "+"
    else:
      s += "-"
    s += l[j+1]
  print(s)
  if eval(s) == 7:
    print(s+"=7")
    quit()

print("wrong input.")

Submission status: Wrong Answer

Solution code:
nums = list(map(int,input()))
import sys
ary = ["a","a","a"]
sum = nums[0]

for i in range(2):
    if i == 0:
        sum += nums[1]
        ary[0] = "+"
    else:
        sum -= nums[i]
        ary[0] = "-"

    for x in range(2):
        if x ==0:
            sum += nums[2]
            ary[1] = "+"
        else:
            sum -= nums[2]
            ary[1] = "-"

        for y in range(2):
            if y == 0:
                sum += nums[3]
                ary[2] ="+"
            else:
                sum -= nums[3]
                ary[2] ="-"

            if sum == 7:
                print(str(nums[0])+ary[0]+str(nums[1])+ary[1]+str(nums[2])+ary[2]+str(nums[3])+"="+str(sum))
                sys.exit()
    sum = nums[0]
    strings = str(nums[0])

Submission status: Wrong Answer

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

if n[0] + n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] - n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] + n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] - n[3] == 7:
    print("{}+{}+{}+{}=7".format(n[0],n[1],n[2],n[3]))
else:
    print("error")

Submission status: Wrong Answer

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

if n[0] + n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] + n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] + n[1] - n[2] - n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] + n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] + n[2] - n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] + n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
elif n[0] - n[1] - n[2] - n[3] == 7:
    print("{}+{}+{}+{}".format(n[0],n[1],n[2],n[3]))
else:
    print("error")

Submission status: Wrong Answer

Solution code:
x = input().split()
x = [int(i) for i in x]
xCount = len(x)

aaa = 0
for i in range(2**(xCount -1)):
    binaryNumber = format(i,'b')
    binaryNumber = binaryNumber.zfill(xCount-1)
    binaryNumber = list(binaryNumber)
    binaryNumber = [int(i) for i in binaryNumber]
    
    for i in range(xCount-1):
        if binaryNumber[i] == 1 :
            binaryNumber[i] = '+' 
        
        if binaryNumber[i] == 0 :
            binaryNumber[i] = '-'
            
    
    result = [None]*(len(x)+len(binaryNumber))
    result[::2] = x
    result[1::2] = binaryNumber
    
    result = map(str, result)
    resultStr = ''.join(result)
    
    a = eval(resultStr)    
    if (a == 7) :
        print(str(resultStr) + '=7')
        break