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:
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(resultStr + '=' + str(a))
        break

Submission status: Wrong Answer

Solution code:
a,b,c,d= list(input())
op = ['+','-']
for i in op:
    for j in op:
        for k in op:
            if eval(a+i+b+j+c+k+d) == 7:
                print(str(a+i+b+j+c+k+d)+'=7')

Submission status: Wrong Answer

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

def calc(n, op, m):
  if(type(n) is not int):
    return False
  if(op == "+"):
    return n + m
  elif(op == "-"):
    return n - m
  elif(op == "*"):
    return n * m
  elif(m != 0):
    return n / m
  else:
    return False

ops1 = ["/", "+", "-", "*"]
ops2 = ["/", "+", "-", "*" ]
ops3 = ["/", "+", "-", "*" ]
for op1 in ops1:
  for op2 in ops2:
    for op3 in ops3:
      if(calc(calc(calc(a,op1,b),op2,c),op3,d) == 7):
        print(a,op1,b,op2,c,op3,d,sep="")
        exit()

Submission status: Wrong Answer

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

if a+b+c+d==7:
  print(a,end=''),print('+',end=''),print(b,end=''),print('+',end=''),print(c,end=''),print('+',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a+b-c+d==7:
  print(a,end=''),print('+',end=''),print(b,end=''),print('+',end=''),print(c,end=''),print('+',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a+b+c-d==7:
  print(a,end=''),print('+',end=''),print(b,end=''),print('-',end=''),print(c,end=''),print('-',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a+b-c-d==7:
  print(a,end=''),print('+',end=''),print(b,end=''),print('-',end=''),print(c,end=''),print('-',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a-b+c+d==7:
  print(a,end=''),print('-',end=''),print(b,end=''),print('+',end=''),print(c,end=''),print('+',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a-b+c-d==7:
  print(a,end=''),print('-',end=''),print(b,end=''),print('+',end=''),print(c,end=''),print('-',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a-b-c+d==7:
  print(a,end=''),print('-',end=''),print(b,end=''),print('-',end=''),print(c,end=''),print('+',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()
if a-b-c-d==7:
  print(a,end=''),print('-',end=''),print(b,end=''),print('-',end=''),print(c,end=''),print('-',end=''),print(d,end=''),print('=',end=''),print(7)
  exit()

Submission status: Wrong Answer

Solution code:
inp=input()
a,b,c,d=[int(i) for i in inp]

for i in range(8):
    calc=a
    B=bin(i)[2:].zfill(3)
    print(B)
    calc=calc+b if B[0]=="0" else calc-b
    calc=calc+c if B[1]=="0" else calc-c
    calc=calc+d if B[2]=="0" else calc-d
    if calc==7:
        break

Operator=["+" if i=="0" else "-" for i in B]
Operator.append("=7")
ans=""
for num, op in zip([a,b,c,d], Operator):
    ans+=str(num)
    ans+=op
print(ans)

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
op = ['+', '-', '*', '/']
for op1 in op:
    for op2 in op:
        for op3 in op:
            res = 0
            try:
                func = S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]
                res = eval(func)
            except:
                pass
            if res == 7:
                print(func + '=7')
                exit()

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
op = ['+', '-', '*', '/']
for op1 in op:
    for op2 in op:
        for op3 in op:
            func = S[0] + op1 + S[1] + op2 + S[2] + op3 + S[3]
            res = 0
            try:
                res = eval(func)
            except:
                pass
            if res == 7:
                print(func + '=7')
                exit()

Submission status: Wrong Answer

Solution code:
# # ABCD = input()
# # fill = 0000
# # for i in range(1 << 4):
# #     print( i )


# S = input()
# result = 0

# for i in range(1 << len(S)-1):
#     #最初の値を代入　最後も固定だから-1か 
#     output = S[0]
#     for j in range(len(S) - 1):
#         if ((i >> j) & 1):
#             output += '+'
#         output += S[j+1]
#     result += eval(output)
# print(result)

ABCD = input()
result = 0

output=[]
#+を加えていく代入する
for i in range(4):
    output += "+"
    output += ABCD[i]
output = ''.join(output)
# print(eval(output))

#4*4ループ
for i in range(16): 
    result = output 
    for j in range (4):
        if( (i>>j) & 1 ):
            result = list(result)
            result[j*2] = "-"
            result = ''.join(result)
    # print("-------")
    # print(result)
    if eval(result)==7:
        if(result[0]=="+"):
            print(result[1:]+"=7")
        else:
            print(result+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
# # ABCD = input()
# # fill = 0000
# # for i in range(1 << 4):
# #     print( i )


# S = input()
# result = 0

# for i in range(1 << len(S)-1):
#     #最初の値を代入　最後も固定だから-1か 
#     output = S[0]
#     for j in range(len(S) - 1):
#         if ((i >> j) & 1):
#             output += '+'
#         output += S[j+1]
#     result += eval(output)
# print(result)

ABCD = input()
result = 0

output=[]
#+を加えていく代入する
for i in range(4):
    output += "+"
    output += ABCD[i]
output = ''.join(output)
print(eval(output))

#4*4ループ
for i in range(16): 
    result = output 
    for j in range (4):
        if( (i>>j) & 1 ):
            result = list(result)
            result[j*2] = "-"
            result = ''.join(result)
    # print("-------")
    # print(result)
    if eval(result)==7:
        if(result[0]=="+"):
            print(result[1:]+"=7")
        else:
            print(result+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
A = [int(v) for v in input()]

flag = False
for i in range(2):
  if flag:
    break
  total = A[0]
  if i == 0:
    total += A[1]
  else:
    total -= A[1]
  for j in range(2):
    if flag:
      break
    if j == 0:
      total += A[2]
    else:
      total -= A[2]
    for k in range(2):      
      if k == 0:
        total += A[3]
      else:
        total -= A[3]
      if total == 7:
        print(A[0], end='')
        if i == 0:
          print('+{}'.format(A[1]), end='')
        else:
          print('-{}'.format(A[1]), end='')
        if j == 0:
          print('+{}'.format(A[2]), end='')
        else:
          print('-{}'.format(A[2]), end='')
        if k == 0:
          print('+{}=7'.format(A[3]))
        else:
          print('-{}=7'.format(A[3]))
        flag = True
        break

Submission status: Wrong Answer

Solution code:
import sys
s=input()
opt = ["+","-"]
for opt1 in opt:
    for opt2 in opt:
        for opt3 in opt:
            equation = s[0]+opt1+s[1]+opt2+s[2]+opt3+s[3]
            if  eval(equation) == 7:
                print(equation)
                sys.exit()

Submission status: Wrong Answer

Solution code:
ABCD = input()

for i in range(1,2**3):
    X = ABCD[0]
    for j in range(3):
        if 1 << j & i:
            X += '+'
        else:
            X += '-'
        X += ABCD[j+1]
    # print('eval: ',X)
    if eval(X) == 7:
        print(X)
        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 range(8):
	if bin(i)[-1]=="1":
		x="+"
		p=a+b
	else: 
		x="-"
		p=a-b
	if bin(i)[-2]=="1":
		y="+"
		p+=c
	else:
		y="-"
		p-=c
	if bin(i)[-3]=="1":
		z="+"
		p+=d
	else:
		z="-"
		p-=d
	if p==7:
		print(str(a)+x+str(b)+y+\
			str(c)+z+str(d)+"="+str(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])

o1 = '+'
o2 = '+'
o3 = '+'
for j in range(2) :
    if j % 2 == 0 :
        B2 = -B
        o2 = '-'
    else :
        B2 = B
        o2 = '+'
    for k in range(2) :
        if k % 2 == 0 :
            C2 = -C
            o3 = '-'
        else :
            C2 = C
            o3 = '+'
        for l in range(2) :
            if l % 2 == 0 :
                D2 = -D
                o4 = '-'
            else :
                D2 = D
                o4 = '+'
            if A+B2+C2+D2 == 7 :
                break
ans = str(A) + o2 + str(B) + o3 + str(C) + o4 + str(D) + '=7'
print(ans)

Submission status: Wrong Answer

Solution code:
n = list(raw_input())
operators = ["+", "-"]
total = None
for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            total = n[0] + op1 + n[1] + op2 + n[2] + op3 + n[3]
            if eval(total) == 7:
                total = total + "=7"
            break
        break
    break
print(total)

Submission status: Wrong Answer

Solution code:
n = list(raw_input())
operators = ["+", "-"]
total = None
for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            total = n[0] + op1 + n[1] + op2 + n[2] + op3 + n[3]
            if eval(total) == 7:
                print(total + "=7")
            break
        break
    break

Submission status: Wrong Answer

Solution code:
n = list(raw_input())
operators = ["+", "-"]
total = None
for op1 in operators:
    for op2 in operators:
        for op3 in operators:
            total = n[0] + op1 + n[1] + op2 + n[2] + op3 + n[3]
            if eval(total) == 7:
                print(total + "=7")

Submission status: Wrong Answer

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

count = a
for i in range(8):
    a = int(s[0])
    for j in range(3):
        if i>>j&1 == 1:
            a += int(s[j+1])
        else:
            a -= int(s[j+1])
    if a == 7:
        ans = (str(bin(i))[2:]).zfill(3)
        print(bin(i),ans)
        ans = ans.replace("0","-")
        ans = ans.replace("1","+")
        print(str(s[0])+ans[2]+str(b)+ans[1]+str(c)+ans[0]+str(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])

count = a
for i in range(8):
    a = int(s[0])
    for j in range(3):
        if i>>j&1 == 1:
            a += int(s[j+1])
        else:
            a -= int(s[j+1])
    if a == 7:
        ans = (str(bin(i))[2:]).zfill(3)
        ans = ans.replace("0","-")
        ans = ans.replace("1","+")
        print(str(s[0])+ans[0]+str(b)+ans[1]+str(c)+ans[2]+str(d)+"=7")
        break

Submission status: Wrong Answer

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

result = a
output = ""

def ope(i):
    if i == 0:
        return "+"
    else:
        return "-"

for i in range(2):
    if output != "":
        break
    for j in range(2):
        if output != "":
            break
        for k in range(2):
            if i == 0:
                result += b
            else:
                result -= b
            if j == 0:
                result += c
            else:
                result -= c
            if k == 0:
                result += d
            else:
                result -= d
            if result == 7:
                output = "{}{}{}{}{}{}{}=7".format(a, ope(i), b, ope(j), c, ope(k), d)
                break

print(output)

Submission status: Wrong Answer

Solution code:
S = input()
sumS = int(S[0]) + int(S[1]) + int(S[2]) + int(S[3])
def minus(a, sumS):
    sS = sumS
    ba = bin(a)
    for ia,aa in enumerate(ba[::-1]):
        if aa == 'b':
            break
        elif aa == '1':
            sS -=  2 * int(S[ia+1:ia+2])
    if sS == 7:
        print(ba)
        T = ['+', '+', '+', '=7']
        for ia,aa in enumerate(ba[::-1]):
            if aa == '1':
                T[ia] = '-'

        result = ''
        for i in range(len(S)):
            result += S[i] + T[i]
        return result
    else:

        return minus(a+1,sumS)
print(minus(0,sumS))

Submission status: Wrong Answer

Solution code:

abcd = input()
num = [int(i) for i in abcd]
def solve(i,a,seven,ans):
    if i == 3:
        if seven == 7:
            return ans
            
        else:
            return False

    if solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1])):
        return solve(i+1,a,seven+a[i+1],ans+'+'+str(a[i+1]))
    
    if solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1])):
        return solve(i+1,a,seven-a[i+1],ans+'-'+str(a[i+1]))

print(solve(0,num,num[0],str(num[0])))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

S = input()
length = len(S) - 1
S = list(S)
for i in range(2**length):
	sum=int(S[0])
	MP = []
	if i & 2**0:
		sum += int(S[1])
		MP.append("+")
	else:
		sum -= int(S[1])
		MP.append("-")
	if i & 2**1:
		sum += int(S[2])
		MP.append("+")
	else:
		sum -= int(S[2])
		MP.append("-")
	if i & 2**2:
		sum += int(S[3])
		MP.append("+")
	else:
		sum -= int(S[3])
		MP.append("-")
	if sum == 7:
		print("{0}{1}{2}{3}{4}{5}{6}=7".format(S[0], MP[0], S[1], MP[1], S[2], MP[2], S[3]))

Submission status: Wrong Answer

Solution code:
s = input()
li = [i for i in s]
global ans
def cal(left, count, remaining):
    global ans
    if len(remaining) > 0:
        cal(left + "+" + remaining[0], count + int(remaining[0]), remaining[1:])
        cal(left + "-" + remaining[0], count - int(remaining[0]), remaining[1:])
    elif count == 7:
        ans = left


cal(li[0], int(li[0]), li[1:])
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
B = ["-"]*3


for i in range(8):
    f = ""
    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    if (eval(f) == 7):
        print(f+"=7")
        break

Submission status: Wrong Answer

Solution code:
S = input()
B = ["-"]*3


for i in range(8):
    f = ""
    for j in range(3):
        if ((i>>j)&1):
            B[j] = "+"
    for a,b in zip(S, B+[""]):
        f += (a+b)
    if eval(f) == 7:
        print(f+"=7")
        break

Submission status: Wrong Answer

Solution code:
N = input()
A, B, C, D = int(N[0]), int(N[1]), int(N[2]), int(N[3])
opes = ['-', '+']
for op1 in opes:
  for op2 in opes:
    for op3 in opes:
      result = 0
      if op1 == '-':
        result += A-B
      else:
        result += A+B
      if op2 == '-':
        result -= C
      else:
        result += C
      if op3 == '-':
        result -= D
      else:
        result += D
      if result == 7:
        print(str(A)+op1+str(B)+op2+str(C)+op3+str(D))
        exit()

Submission status: Wrong Answer

Solution code:
import sys
N = list(map(int, input()))
op = ['+','-']
for i in op:
    tmp = 0 
    ans = []
    for j in op:
        for k in op:
            if i == '+':
                tmp = N[0] + N[1]
                ans.append('+')
            else:
                tmp = N[0] - N[1]
                ans.append('-')

            if j == '+':
                tmp += N[2]
                ans.append('+')
            else:
                tmp -= N[2]    
                ans.append('-')

            print(k)
            if k == '+':
                tmp += N[3]
                ans.append('+')
            else:
                tmp -= N[3]
                ans.append('-')

            if tmp == 7:
                print(str(N[0])+ans[0]+str(N[1])+ans[1]+str(N[2])+ans[2]+str(N[3])+"=7")
                sys.exit()
            else:
                tmp = 0
                ans = []

Submission status: Wrong Answer

Solution code:
print("{}".format(123))

Submission status: Wrong Answer

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

n = int(input())

tmp=[]
tmp.append(n//1000)
n=n%1000
tmp.append(n//100)
n=n%100
tmp.append(n//10)
n=n%10
tmp.append(n)

for i in range(-1,2,2):
	for j in range(-1,2,2):
		for k in range(-1,2,2):
			sum= tmp[0]+i*tmp[1]+j*tmp[2]+k*tmp[3]
			if(sum == 7):
				break
			#print("{} {} {}:{}".format(i,j,k,sum))
res=""
res+=str(tmp[0])
if(i==-1):res+="-"
else:res+="+"
res+=str(tmp[1])
if(j==-1):res+="-"
else:res+="+"
res+=str(tmp[2])
if(k==-1):res+="-"
else:res+="+"
res+=str(tmp[3])
res+="=7"


print(res)

Submission status: Wrong Answer

Solution code:
def main():
	n = [int(i) for i in input()]
	for i in range(7):
		x2 = base_10_to_n(i,2)
		for _ in range(3-len(x2)):	
			x2 = '0' + x2
		ans = n[0]
		for j in range(3):
			if(x2[j] == '0'):
				ans += n[j+1]
			else:
				ans -= n[j+1]
		if(ans == 7):
			text = str(n[0])
			for j in range(3):
				if(x2[j] == '0'):
					text = text + '+' + str(n[j+1])
				else:
					text = text + '-' + str(n[j+1])
			print(text+'=0')
			return 0

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Submission status: Wrong Answer

Solution code:
S=input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])

op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      if eval("A {} B {} C {} D".format(i, j, k)) == 7:
        print("{}{}{}{}{}{}{}".format(A, i, B, j, C, k, D))
        exit()

Submission status: Wrong Answer

Solution code:
s=input()
l=2**3

for i in range(l):
    j=i
    c=int(s[0])
    n=1
    while(i):
        if i & 1 ==1:
            c+=int(s[n])
        else:
            c-=int(s[n])
        i=i>>1
        n+=1
    if c==7:
        break

ss=[s[0]]
for i in range(3):
    if j & 1 ==1:
        ss.append('+')
    else:
        ss.append('-')
    ss.append(s[i+1])
    j=j>>1
print(''.join(ss)+'=7')

Submission status: Wrong Answer

Solution code:
S = input()
S_list = list(S)
n = len(S) 
a = []

list_0or1 = [0] * (n-1)
check = []

def f(i):
    if i == n-1 :
        check.append(list_0or1.copy())
    if i != n-1:
        list_0or1[i] = 0
        f(i+1)
    if i != n-1:
        list_0or1[i] = 1
        f(i+1)
f(0)

sum_list = []
s_list = []
for i in range(len(check)):
    S_list_copy = S_list.copy()
    for j in range(n-1) :
        if check[i][j] == 1 :
            S_list_copy[j+1] = '+' + S_list_copy[j+1]
        if check[i][j] == 0 :
            S_list_copy[j+1] = '-' + S_list_copy[j+1]
    S_list_copy = ''.join(S_list_copy)
    sum_list.append(S_list_copy)
    S_list_copy = [int(S_list_copy[0]), int(S_list_copy[2]), int(S_list_copy[4]), int(S_list_copy[6])]
    s = S_list_copy[0]
    for j in range(n-1) :
        if check[i][j] == 1 :
            s = s + S_list_copy[j+1]
        if check[i][j] == 0 :
            s = s - S_list_copy[j+1]
    s_list.append(s) 
if 7 in s_list:
    print(sum_list[s_list.index(7)])

Submission status: Wrong Answer

Solution code:
num = list(input())
print(num)
ans = 7
for i in range(2 ** len(num)):
    total = 0
    ans_num = []
    ans_op = []
    for j in range(len(num)):
        if((i >> j) & 1):
            ans_num.append(num[j])
            if(j >= 1):
                ans_op.append('+')
            total += int(num[j])
        else:
            ans_num.append(num[j])
            if (j >= 1):
                ans_op.append('-')
            total -= int(num[j])
    print(total)
    print(ans_op)
    if(total == ans):
        print(ans_num[0]+ans_op[0]+ans_num[1]+ans_op[1]+ans_num[2]+ans_op[2]+ans_num[3]+'=7')
        break

Submission status: Wrong Answer

Solution code:
def MI():
    return map(int,input().split())
def I():
    return int(input())
s=input()
ans=''
def dfs(s,t):
    if t=='':
        if eval(s)==7:
            global ans
            ans=s+'='+str(eval(s))
        else:
            pass
        #print(s+'='+str(eval(s)))
        return
    else:
        dfs(s+'+'+t[0],t[1:])
        dfs(s+'-'+t[0],t[1:])

dfs('',s)
print(ans[1:])

Submission status: Wrong Answer

Solution code:
S = input()
count = len(S)-1
for i in range(2**count):
  sign=['-']*count
  for j in range(count):
    if ((i>>j)&1):
      sign[j]='+'
  formula=''
  for k in range(count):
    formula += S[k] + sign[k]
  formula += S[count]
  if eval(formula)==7:
    print(formula)
    break

Submission status: Wrong Answer

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

for i in range(2):
    sum = row[0]
    if i == 0:
        op1 = "+"
        sum += row[1]
    else:
        op1 = "-"
        sum -= row[1]
    for j in range(2):
        if j == 0:
            op2 = "+"
            sum += row[2]
        else:
            op2 = "-"
            sum -= row[2]       
        for k in range(2):
            if j == 0:
                op3 = "+"
                sum += row[3]
            else:
                op3 = "-"
                sum -= row[3]  
            if sum == 7:
                break

print(row[0],op1,row[1],op2,row[2],op3,row[3],"=7", sep="")

Submission status: Wrong Answer

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

for i in range(2):
    sum = row[0]
    if i == 0:
        op1 = "+"
        sum += row[1]
    else:
        op1 = "-"
        sum -= row[1]
    for j in range(1):
        if j == 0:
            op2 = "+"
            sum += row[2]
        else:
            op2 = "-"
            sum -= row[2]       
        for k in range(1):
            if j == 0:
                op3 = "+"
                sum += row[3]
            else:
                op3 = "-"
                sum -= row[3]  
            if sum == 7:
                break

print(row[0],op1,row[1],op2,row[2],op3,row[3],"=7", sep="")

Submission status: Wrong Answer

Solution code:
S = input()

for i in range(1 << len(S)-1):
    f = ''
    for j in range(len(S)-1):
        f += S[j]
        if (i >> j) & 1 == 1:
            f += '+'
        else:
            f += '-'
    f += S[-1]
    if eval(f) == 7:
        ans = f + '=7'
        print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

for i in range(1 << len(S)-1):
    f = ''
    for j in range(len(S)-1):
        f += S[j]
        if (i >> j) & 1 == 1:
            f += '+'
        else:
            f += '-'
    f += S[-1]
    if eval(f) == 7:
        print(f)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline
I = list(input())
I.pop()
*ABCD, = map(int, I)

ans = ["+" for _ in range(3)]
S = sum(ABCD)

for i in range(1, len(ABCD)):
    if S - 2*ABCD[i] == 7:
        ans[i-1] = "-"
        break

ANS = str(ABCD[0])
for i in range(3):
    ANS += str(ans[i])
    ANS += str(ABCD[i+1])
print(ANS + "=7")

Submission status: Wrong Answer

Solution code:
n = input()
for i in range(2**3):
    sign = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):
            sign[j] = "+"

    formula = n[0] + sign[0] + n[1] + sign[1] + n[2] + sign[2] + n[3]
    if eval(formula) == 7:
        print(formula)
        break

Submission status: Wrong Answer

Solution code:
N = [int(el) for el in list(input())]

def result(N):
    if N[0]+N[1]+N[2]+N[3]:
        print('{}+{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]+N[3]:
        print('{}-{}+{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]+N[3]:
        print('{}+{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]+N[2]-N[3]:
        print('{}+{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]+N[3]:
        print('{}-{}-{}+{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]+N[2]-N[3]:
        print('{}-{}+{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]+N[1]-N[2]-N[3]:
        print('{}+{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
    if N[0]-N[1]-N[2]-N[3]:
        print('{}-{}-{}-{}=7'.format(N[0],N[1],N[2],N[3]))
        return
result(N)

Submission status: Wrong Answer

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


for i in range(2**3):
    count=int(ABCD[0])
    ans=ABCD[0]
    for j in range(3):
        if i^(1<<j):
            count+=int(ABCD[j+1])
            ans+="+"
        else:
            count-=int(ABCD[j+1])
            ans+="-"
        ans+=ABCD[j+1]
    if count==7:
        ans+="=7"
        print(ans)
        quit()

Submission status: Wrong Answer

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

a, b, c, d = map(str, input())

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

Submission status: Wrong Answer

Solution code:
s = input()
abcd = [int(s[0]),int(s[1]),int(s[2]),int(s[3])]
mark = ['-','+']
for i in range(1 << 3):
    alla = abcd[0]
    i2 = format(i,'03b')
    for j in range(3):
        if i2[2 - j] == '0':#0 = -
            alla -= abcd[3 - j]
        else:
            alla += abcd[3 - j]
    if alla == 7:
        print(int(s[0]),mark[int(i2[0])],int(s[1]),mark[int(i2[1])],int(s[2]),mark[int(i2[2])],int(s[3]),'=7')
        exit()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

ABCD = S()

for i in range(1<<3):
    tmp = 0
    bit = i

    for j in range(3):
        if (bit & 1):
            tmp += int(ABCD[-j-1])
        else:
            tmp -= int(ABCD[-j-1])
        bit >>= 1
        
    tmp += int(ABCD[0])
    if (tmp == 7):
        ans = i
        break


operands = []
for i in range(3):
    if (ans & 1):
        operands.append("+")
    else:
        operands.append("-")
    ans >>= 1

for i, ope in enumerate(operands):
    print(ABCD[i], end="")
    print(ope, end="")
print(ABCD[3], end="")
print("=7")

Submission status: Wrong Answer

Solution code:
# bit全探索ver
s=list(input())
n=len(s)-1

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

Submission status: Wrong Answer

Solution code:
s = input()
n = 3
t=[]
for i in range(1<<n):
    ans = int(s[0])
    k=1
    for j in range(n):
        if 1&(i>>j):
            ans += int(s[k:(j+2)])
            t.append("+")
        else: 
            ans -= int(s[k:(j+2)]) 
            t.append("-")
        k=j+2
    if ans==7:
        print(s[0]+t[0]+s[1]+t[1]+s[2]+t[2]+s[3]+"=7")
        break;
    ans = int(s[0])
    t=[]
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import operator
import itertools

def op(op_str):
    funcs = {
            "+":operator.add,
            "-":operator.sub
            }
    return funcs[op_str]

def solve(A,B,C,D):
    for o in itertools.product(["+","-"], repeat = 3):
        ret = op(o[0])(A,B)
        ret = op(o[1])(C,ret)
        ret = op(o[2])(D,ret)
        if ret == 7:
            print("{0}{1}{2}{3}{4}{5}{6}=7".format(A,o[0],B,o[1],C,o[2],D))
            return


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    S = input()
    L = [int(c) for c in S]
    
    solve(*L)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a = [int(x) for x in list(input())]
op = 3
ops = [0] * op
for i in range(2 ** op):
    result = a[0]
    bry = list(format(i, "0{}b".format(op)))
    for index, value in enumerate(bry):
        if value == "1":
            result += a[index + 1]
            ops[index] = "+"
        else:
            result -= a[index + 1]
            ops[index] = "-"
    if result == 7:
        ans = str(a[0])
        for j in range(3):
            ans += "{}{}".format(ops[j], a[j+1])
        print(ans)
        break

Submission status: Wrong Answer

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

import itertools
Bit = list(itertools.combinations_with_replacement(['-', '+'], 3))

for l in Bit:
    seven = In[0]
    for i, bit in enumerate(l):
        if bit == '+':
            seven += In[i+1]
        else:
            seven -= In[i+1]
    if seven == 7:
        print("{}{}{}{}{}{}{}=7".format(In[0],l[0],In[1],l[1],In[2],l[2],In[3]))
        break

Submission status: Wrong Answer

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

import itertools
Bit = list(itertools.combinations_with_replacement(['-', '+'], 3))

for l in Bit:
    seven = In[0]
    for i, bit in enumerate(l):
        if bit == '+':
            seven += In[i+1]
        else:
            seven -= In[i+1]
    if seven == 7:
        print("{}{}{}{}{}{}{}=7".format(In[0],l[0],In[1],l[1],In[2],l[2],In[3]))

Submission status: Wrong Answer

Solution code:
ABCD = input()
for i in range(2**3):
    bi = bin(i)[2:].zfill(3)
    tmp = int(ABCD[0])
    ops = []
    for j in range(3):
        if bi[j]=='1':
            tmp += int(ABCD[j+1])
            ops.append('+')
        else:
            tmp -= int(ABCD[j+1])
            ops.append('-')
    if tmp==7:
        print(ABCD[0]+ops[0]+ABCD[1]+ops[1]+ABCD[2]+ops[2]+ABCD[3] + '=7')

Submission status: Wrong Answer

Solution code:
s = input()
a,b,c,d = int(s[0]), int(s[1]), int(s[2]), int(s[3])
if a+b+c+d == 7:
    print("{0}+{1}+{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b+c-d == 7:
    print("{0}+{1}+{2}-{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b-c+d == 7:
    print("{0}+{1}-{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a-b+c+d == 7:
    print("{0}-{1}+{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a+b-c-d == 7:
    print("{0}+{1}-{2}-{3}=7".format(str(a),str(b),str(c),str(d)))
elif a-b-c+d == 7:
    print("{0}-{1}-{2}+{3}=7".format(str(a),str(b),str(c),str(d)))
elif a-b-c-d == 7:
    print("{0}-{1}-{2}-{3}=7".format(str(a),str(b),str(c),str(d)))