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:
def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string =+ num
    string += "="
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])

    print(result)

Submission status: Wrong Answer

Solution code:
s = input()
abcd = [int(a) for a in s]
for i in range(2**3):
    bin_i = format(i, '03b')
    ops = [int(a)*2-1 for a in bin_i]
    sum = abcd[0]
    for j in range(3):
        sum += ops[j]*abcd[j+1]
        if sum==7:
            break

ans = s[0]
for j in range(3):
    if ops[j]==1:
        a = '+'
    else:
        a = '-'
    ans += a+s[j+1]
print(ans+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
abcd = [int(a) for a in s]
for i in range(2**3):
    bin_i = format(i, '03b')
    ops = [int(a)*2-1 for a in bin_i]
    sum = abcd[0]
    for j in range(3):
        sum += ops[j]*abcd[j+1]
        if sum==7:
            break

ans = s[0]
for j in range(3):
    if ops[j]==1:
        a = '+'
    else:
        a = '-'
    ans += a+s[j+1]
print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
#A, B, C, D = list(map(int, input().strip().split()))
A = int(N[0])
B = int(N[1])
C = int(N[2])
D = int(N[3])
ans1 = A+B+C+D
ans2 = A+B+C-D
ans3 = A+B-C+D
ans4 = A+B-C-D
ans5 = A-B+C+D
ans6 = A-B+C-D
ans7 = A-B-C+D
ans8 = A-B-C-D

if ans1 == 7:
	print('%d+%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d+%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d-%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d+%d-%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d+%d+%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d+%d-%d=7' % (A, B, C, D))
elif ans2 == 7:
	print('%d-%d-%d+%d=7' % (A, B, C, D))
else:
	print('%d-%d-%d-%d=7' % (A, B, C, D))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
# input
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
# calc
op = ["+", "-"]
for i in range(2):
    ans = a
    if i == 0:
        ans += b
    else:
        ans -= b
    for j in range(2):
        if j == 0:
            ans += c
        else:
            ans -= c
        for k in range(2):
            if k == 0:
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(str(a) + op[i] + str(b) + op[j] + str(c) + op[k] + str(d) + "=7")
                sys.exit()
# output
# 答えが存在しない入力は与えられない

Submission status: Wrong Answer

Solution code:
(a, b, c, d) = map(int, list(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')

Submission status: Wrong Answer

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

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')

Submission status: Wrong Answer

Solution code:
n = list(input())
for i in range(8):
    ans = n[0]
    ans += '+-'[i%2] + n[1]
    ans += '+-'[i//4] + n[2]
    ans += '+-'[(i%4)//2] + n[3]
    if eval(ans) == 7:
        print(ans)
        break

Submission status: Wrong Answer

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

op = ['+', '-']

for i in op:
    for j in op:
        for k in op:
            f = A + i + B + j + C + k + D
            if eval(f) == 7:
                print(f + '==7')
                exit()

Submission status: Wrong Answer

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

op = ['+', '-']

for i in op:
    tmp = A + i + B
    for j in op:
        tmp += j + C
        for k in op:
            tmp += k + D
            if eval(tmp) == 7:
                print(tmp + '=7')
                exit()
            else:
                tmp = tmp[:-2]

Submission status: Wrong Answer

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

op = ['+', '-']

for i in op:
    tmp = A + i + B
    for j in op:
        tmp += j + C
        for k in op:
            tmp += k + D
            if eval(tmp) == 7:
                print(tmp + '=7')
                exit()

Submission status: Wrong Answer

Solution code:
def Cal(A, B, op):
    if op == "+":
        return A + B
    else:
        return A - B

Num = input()
OP = ["---", "--+", "-+-", "-++", "+--", "+-+", "++-", "+++"]

for o in OP:
    Sum = Cal(int(Num[0]), int(Num[1]), o[0])
    Sum = Cal(Sum, int(Num[2]), o[1])
    Sum = Cal(Sum, int(Num[3]), o[2])
    if Sum == 7:
        print(Num[0]+o[0]+Num[1]+o[1]+Num[2]+o[2]+Num[3])
        break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
ops = ['+', '-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      s = a+op1+b+op2+c+op3+d
      res = eval(s)
      if res == 7:
        print(s+'=7')
        break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

sum = 0
for i in range(4):
    sum = sum + n[i]


if sum == 7:
    print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')

else:
    if 4*n[1] == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()

    if 4*n[2] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*n[3] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[3] + n[2])  == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')
        sys.exit()
    if 4*(n[1] + n[2] + n[3])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')

Submission status: Wrong Answer

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

sum = 0
for i in range(4):
    sum = sum + n[i]


if sum == 7:
    print(S[0] + '+' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')

else:
    if 4*n[1] == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '+' + S[2] + '+' + S[3] + '=' + '7')

    if 4*n[2] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')

    if 4*n[3] == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '+' + S[2] + '-' + S[3] + '=' + '7')

    if 4*(n[1] + n[2])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '+' + S[3] + '=' + '7')

    if 4*(n[3] + n[2])  == 2 * (sum - 7):
        print(S[0] + '+' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')

    if 4*(n[1] + n[2] + n[3])  == 2 * (sum - 7):
        print(S[0] + '-' + S[1] + '-' + S[2] + '-' + S[3] + '=' + '7')

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()
if s[0]+s[1]+s[2]+s[3]==7:
	print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]+s[2]-s[3]==7:
	print(s[0],"+",[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]+s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]-s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]+s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]-s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]+s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]-s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7",sep="")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()
if s[0]+s[1]+s[2]+s[3]==7:
	print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]+s[2]-s[3]==7:
	print(s[0],"+",[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]+s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]+s[1]-s[2]-s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]+s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]+s[2]-s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]+s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7",sep="")
elif s[0]-s[1]-s[2]-s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7",sep="")

Submission status: Wrong Answer

Solution code:
n = int(input())
s = []
for i in range(4):
	s.append(n//(10**i)-(n//(10**(i+1)))*10)
s.reverse()
if s[0]+s[1]+s[2]+s[3]==7:
	print(s[0],"+",s[1],"+",s[2],"+",s[3],"=7")
elif s[0]+s[1]+s[2]-s[3]==7:
	print(s[0],"+",[1],"+",s[2],"+",s[3],"=7")
elif s[0]+s[1]-s[2]+s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"+",s[3],"=7")
elif s[0]+s[1]-s[2]-s[3]==7:
	print(s[0],"+",s[1],"-",s[2],"-",s[3],"=7")
elif s[0]-s[1]+s[2]+s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"+",s[3],"=7")
elif s[0]-s[1]+s[2]-s[3]==7:
	print(s[0],"-",s[1],"+",s[2],"-",s[3],"=7")
elif s[0]-s[1]-s[2]+s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"+",s[3],"=7")
elif s[0]-s[1]-s[2]-s[3]==7:
	print(s[0],"-",s[1],"-",s[2],"-",s[3],"=7")

Submission status: Wrong Answer

Solution code:
O = ["+","-"]
I = list(input())
for o1 in O :
    for o2 in O :
        for o3 in O :
            f = I[0]+o1+I[1]+o2+I[2]+o3+I[3]
            if eval(f) == 7 :
                print(f+"=7")

Submission status: Wrong Answer

Solution code:
input_str = input()

for i in range(8):
    calc_str = input_str[0]
    opmaker = str(format(i, 'b')).zfill(3)
    for j, c in enumerate(opmaker):
        if c == '0':
            calc_str += '-'
        else:
            calc_str += '+'
        calc_str += input_str[j+1]
        if eval(calc_str) == 7:
            print(calc_str + '=7')
            exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = [int(i) for i in input()]
ops = ["+++", "++-", "+-+", "+--", "-++", "-+-", "--+", "---"]


for op in ops:
    s = a
    print(op)
    for i, n in enumerate([b, c, d]):
        op = list(op)
        if op[i] == "+":
            s += n
        else:
            s -= n
    if s == 7:
        print(str(a) + op[0] + str(b) + op[1] + str(c) + op[2] + str(d) + "=7")
        break

Submission status: Wrong Answer

Solution code:
A, B, C, D = input()
ops = ('+', '-', '*', '/')

for op1 in ops if B!='0' else ops[:-1]:
	for op2 in ops if C!='0' else ops[:-1]:
		for op3 in ops if D!='0' else ops[:-1]:
			if eval(A+op1+B+op2+C+op3+D+'==7'):
				print(A+op1+B+op2+C+op3+D+'=7')
				exit()

Submission status: Wrong Answer

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


for i in range(0,2):
    for j in range(0,2):
        for k in range(0,2):
            ans = ''
            if i == 0:
                AB = A + B
                ans += str(A) + '+' + str(B)
            elif i == 1:
                AB = A - B
                ans += str(A) + '-' + str(B)
            if j == 0:
                ABC = AB + C
                ans += '+' + str(C)
            elif j == 1:
                ABC = AB - C
                ans += '-' + str(C)
            if k == 0:
                ABCD = ABC + D
                ans += '+' + str(D)
            elif j == 1:
                ABCD = ABC - D
                ans += '-' + str(D)
            if ABCD == 7:
                ans += '=7'
                print(ans)
                quit()

Submission status: Wrong Answer

Solution code:
s=input()
op=["+","-","*","/"]
tolal=0
for i in op:
    for j in op:
        for k in op:
            try:
                total=eval("{}{}{}{}{}{}{}".format(s[0],i,s[1],j,s[2],k,s[3]))
            except ZeroDivisionError:
                continue
            if total ==7:
                print("{}{}{}{}{}{}{}=7".format(s[0],i,s[1],j,s[2],k,s[3]))
                exit()

Submission status: Wrong Answer

Solution code:
t = list(map(int,input()))
p = ['+','+','+']
q = []
for i in range(8):
    if i & 1:
        c = t[0] + t[1]
        p[0] = '+'
    else:
        c = t[0] - t[1]
        p[0] = '-'
    if i & (1<<1):
        c += t[2]
        p[1] = '+'
    else:
        c -= t[2]
        p[1] = '-'
    if i & (1<<2):
        c += t[3]
        p[2] = '+'
    else:
        c -= t[3]
        p[2] = '-'
    if c == 7:
        q = p
print(str(t[0]) + q[0] + str(t[1]) + q[1] + str(t[2]) + q[2] + str(t[3]) + '=7')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])
ans2='+'
ans3='+'
ans4='+'
check=True
for j in [b,-b]:
    for k in [c,-c]:
        for l in [d,-d]:
            ans = a + j + k + l
            if ans == 7:
                if (j < 0) and check==True:
                    ans2 = '-'
                elif (k < 0) and check==True:
                    ans3 = '-'
                elif (l < 0) and check==True:
                    ans4 = '-'
                check=False
print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])
ans2='+'
ans3='+'
ans4='+'
check=True
for j in [b,-b]:
    if check:
        for k in [c,-c]:
            if check:
                for l in [d,-d]:
                    if check:
                        ans = a + j + k + l
                        if ans == 7:
                            if j < 0:
                                ans2 = '-'
                            elif k < 0:
                                ans3 = '-'
                            elif l < 0:
                                ans4 = '-'
                            check = False
print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])
ans2='+'
ans3='+'
ans4='+'
for j in [b,-b]:
    for k in [c,-c]:
        for l in [d,-d]:
            ans = a + j + k + l
            if ans == 7:
                if j < 0:
                    ans2 = '-'
                elif k < 0:
                    ans3 = '-'
                elif l < 0:
                    ans4 = '-'
                break
print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])
ans2='+'
ans3='+'
ans4='+'
for i in [a]:
    for j in [b,-b]:
        for k in [c,-c]:
            for l in [d,-d]:
                ans = i + j + k + l
                if ans == 7:
                    if j < 0:
                        ans2 = '-'
                    elif k < 0:
                        ans3 = '-'
                    elif l < 0:
                        ans4 = '-'
print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])
ans2='+'
ans3='+'
ans4='+'
for i in [a]:
    for j in [b,-b]:
        for k in [c,-c]:
            for l in [d,-d]:
                ans = i + j + k + l
                if ans == 7:
                    if j < 0:
                        ans2 = '-'
                    elif k < 0:
                        ans3 = '-'
                    elif l < 0:
                        ans4 = '-'
print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
abcd = str(input())
abcd_list = list(abcd)
a = int(abcd_list[0])
b = int(abcd_list[1])
c = int(abcd_list[2])
d = int(abcd_list[3])

ans2='+'
ans3='+'
ans4='+'
for i in [a]:
    for j in [b,-b]:
        for k in [c,-c]:
            for l in [d,-d]:
                ans = i + j + k + l
                if ans == 7:
                    if j < 0:
                        ans2 = '-'
                    elif k < 0:
                        ans3 = '-'
                    elif l < 0:
                        ans4 = '-'

print(str(a)+ans2+str(b)+ans3+str(c)+ans4+str(d))

Submission status: Wrong Answer

Solution code:
#A_list =list(map(int,input().split()))
A_list = [int(x) for x in list(input())]
OP_list = ["","",""]
#current = 1
#current_sum = A_list[0]

def solve(current, current_sum):
    if current == 4:
        return current_sum == 7
    
    if solve(current + 1 , current_sum + A_list[current]):
        OP_list[current-1] = "+"
        return True
    
    if solve(current + 1 , current_sum - A_list[current]):
        OP_list[current-1] = "-"
        return True
    
    return False

solve(1,A_list[0])
print (OP_list)

Submission status: Wrong Answer

Solution code:
import sys
t = list(map(int, list(input())))
t.append(7)
op = []


def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
        sys.exit(0)

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1

    return

dfs(t[0], 0)

Submission status: Wrong Answer

Solution code:
t = list(map(int, list(input())))
t.append(7)
op = []


def dfs(x, i):
    if i == 4 or len(op) == 3:
        if x == 7:
            op.append('=')
            ans = ''
            for j in range(5):
                if j == 4:
                    ans += str(t[j])
                else:
                    ans += str(t[j]) + op[j]
            print(ans)
        return

    i += 1
    op.append('+')
    dfs(x + t[i], i)
    op.pop()

    op.append('-')
    dfs(x - t[i], i)
    op.pop()
    i -= 1

    return

dfs(t[0], 0)

Submission status: Wrong Answer

Solution code:
t=list(map(int,list(input())))
t.append(-1)
op=[]
def dfs(x,i):
  if i==4 or len(op)==3:
    if x==7:
      ans=''
      for j in range(4):
        if j==3:
          ans+=str(t[j])
        else:
          ans+=str(t[j])+op[j]
      print(ans)
    return
  i+=1
  op.append('+')
  dfs(x+t[i],i)
  op.pop()
  
  op.append('-')
  dfs(x-t[i],i)
  op.pop()
  i-=1
  
  return
dfs(t[0],0)

Submission status: Wrong Answer

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

signs = ['+' , '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+signs[i]+B+signs[j] + C + signs[k] + D
            if eval(ans) == 7:
                print(ans + '=7')
                break

Submission status: Wrong Answer

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

signs = ['+' , '-']

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = A+signs[i]+B+signs[j] + C + signs[k] + D
            if eval(ans) == 7:
                print(ans + '=7')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# vim: set fileencoding=utf-8 :
def main():
    n = raw_input()
    ll = [int(x) for x in list(str(n))]
    l = sorted([int(x) for x in list(str(n))], reverse=True)
    ops = []
    ct = 0

    # ソートしたら同じ値は絶対２個ある！！！！気がつくのが遅い！！！！！！！！！！！！！！
    for ele in l:
        if ele == 7:
            ops.append('+')
        elif ele > 7:
            ops.append('-')
        elif ele < 7:
            ops.append('+')

        ct += 1

    print(str(ll[0]) + ops[0] + str(ll[1]) + ops[1] + str(ll[2]) + ops[2] + str(ll[3]) + "=7")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# vim: set fileencoding=utf-8 :
def main():
    n = raw_input()
    l = sorted([int(x) for x in list(str(n))], reverse=True)
    ops = []
    ct = 0

    for ele in l:
        if ele == 7:
            ops.append('+')
        elif ele > 7:
            ops.append('-')
        elif ele < 7:
            ops.append('+')

        ct += 1

    print(str(l[0]) + ops[0] + str(l[1]) + ops[1] + str(l[2]) + ops[2] + str(l[3]) + "=7")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s = [int(x) for x in input()]

import functools
@functools.lru_cache(maxsize=None)
def f(c, n):
    print("c ", c, n)
    if n == 4:
        if c == 7:
            return []
        else:
            return None
    v = s[n]
    for o in ['+', '-']:
        print("f ", ''.join([str(x) for x in [c, o, v]]), eval('%d%s%d'% (c,o,v)), n + 1)
        ret = f(eval('%d%s%d'% (c,o,v)), n + 1)
        if ret is not None:
            return [o, v] + ret
print(''.join([str(x) for x in ([s[0]] + f(s[0], 1))]) + '=7')

Submission status: Wrong Answer

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

# それぞれ数ごと
for i in range(1 << 3):
    tmp = ary[0]
    ans = str(ary[0])
    for j in range(3):
        if i & (1<<j):
           tmp += ary[j+1]
           ans+= "+" + str(ary[j + 1])
        else:
            tmp -= ary[j+1]
            ans+= "-" + str(ary[j + 1])

    if tmp == 7:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
e = input()
op = ("+", "-")
for i in range(6):
  t = ""
  for j in range(4):
    k = i>>j&1
    t += e[j]+op[k]
  t = t[:-1:]
  if eval(t)==7:
    print(t+"=7")
    break

Submission status: Wrong Answer

Solution code:
A, B, C, D = map(int, input())
for i in range(8):
    sum = 0
    op1 = "+" if i // 4 % 2 == 0 else "-"
    op2 = "+" if i // 2 % 2 == 0 else "-"
    op3 = "+" if i % 2 == 0 else "-"
    if op1 == "+":
        sum = A + B
    else:
        sum = A - B
    if op2 == "+":
        sum += C
    else:
        sum -= C
    if op3 == "+":
        sum += D
    else:
        sum -= D
    if sum == 7:
        print(str(A) + op1 + str(B) + op2 + str(C) + op3 + str(D))
        break

Submission status: Wrong Answer

Solution code:
S = input()

op = [0]*3
for i in range(2):
    tmp = int(S[0])
    if i == 0:
        tmp += int(S[1])
        op[0] = '+'
    else:
        tmp -= int(S[1])
        op[0] = '-'
    for j in range(2):
        if j == 0:
            tmp += int(S[2])
            op[1] = '+'
        else:
            tmp -= int(S[2])
            op[1] = '-'
        for k in range(2):
            if k == 0:
                tmp += int(S[3])
                op[2] = '+'
            else:
                tmp -= int(S[3])
                op[2] = '-'
            if tmp == 7:
                print(S[0] + op[0] + S[1] + op[1] + S[2] + op[2] + S[3] + '=7')
                exit()

Submission status: Wrong Answer

Solution code:
n = input()

a = ['+','-']

for i in a:
    for j in a:
        for k in a:
            if eval(n[0]+i+n[1]+j+n[2]+k+n[3]) == 7:
                print(n[0]+i+n[1]+j+n[2]+k+n[3]+'=7')
                break

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    num = input()
    num_list = [int(i) for i in str(num)]

    A = num_list[0]
    B = num_list[1]
    C = num_list[2]
    D = num_list[3]

    if A + B + C + D == 7:
        print("A+B+C+D=7")
    elif A + B + C - D == 7:
        print("A+B+C-D=7")
    elif A + B - C + D == 7:
        print("A+B-C+D=7")
    elif A + B - C - D == 7:
        print("A+B-C-D=7")
    elif A - B + C + D == 7:
        print("A-B+C+D=7")
    elif A - B + C - D == 7:
        print("A-B+C-D=7")
    elif A - B - C + D == 7:
        print("A-B-C+D=7")
    elif A - B - C - D == 7:
        print("A-B-C-D=7")

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    num = input()
    num_list = [int(i) for i in str(num)]

    A = num_list[0]
    B = num_list[1]
    C = num_list[2]
    D = num_list[3]

    if A + B + C + D == 7:
        print("A+B+C+D")
    elif A + B + C - D == 7:
        print("A+B+C-D")
    elif A + B - C + D == 7:
        print("A+B-C+D")
    elif A + B - C - D == 7:
        print("A+B-C-D")
    elif A - B + C + D == 7:
        print("A-B+C+D")
    elif A - B + C - D == 7:
        print("A-B+C-D")
    elif A - B - C + D == 7:
        print("A-B-C+D")
    elif A - B - C - D == 7:
        print("A-B-C-D")

Submission status: Wrong Answer

Solution code:
def main():
	s = input()
	ans = ''
	ans = solve(s[0], s[1:])
	print(ans)

def solve(left, right):
	if len(right) == 0:
		if eval(left) == 7:
			print(left)
			exit()
	else:
		solve(left + '-' + right[0], right[1:])
		solve(left + '+' + right[0], right[1:])

if __name__ == '__main__':
	main()

Submission status: Wrong Answer

Solution code:
inp = str(input())

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

a = "%d+%d+%d+%d=7" % (A, B, C, D)
b = "%d+%d+%d-%d=7" % (A, B, C, D)
c = "%d+%d-%d+%d=7" % (A, B, C, D)
d = "%d-%d+%d+%d=7" % (A, B, C, D)
e = "%d+%d+%d+%d=7" % (A, B, C, D)
f = "%d-%d+%d-%d=7" % (A, B, C, D)
g = "%d-%d-%d+%d=7" % (A, B, C, D)
h = "%d-%d-%d-%d=7" % (A, B, C, D)

if A + B + C + D == 7:
    print(a)
elif A + B + C - D == 7:
    print(b)
elif A + B - C + D == 7:
    print(c)
elif A - B + C + D == 7:
    print(d)
elif A + B - C - D == 7:
    print(e)
elif A - B + C - D == 7:
    print(f)
elif A - B - C + D == 7:
    print(g)
elif A - B - C - D == 7:
    print(h)

Submission status: Wrong Answer

Solution code:
N=int(input())

a=N//1000
b=(N%1000)//100
c=(N%100)//10
d=N%10

ope=[-1,1]

for i in ope:
    for j in ope:
        for k in ope:
            if a+i*b+j*c+k*d==7:
                ans=[i,j,k]

l=[0]*3

for i in range(3):
    if ans[i]>0:
        l[i]="+"
    else:
        l[i]="-"

   

#all_ans=[str(a),l[0],str(b),l[1],str(c),l[2],str(d)]
all_ans=str(a)+l[0]+str(b)+l[1]+str(c)+l[2]+str(d)
print(all_ans)

Submission status: Wrong Answer

Solution code:
i=int(input())
d=i%10
c=(i//10)%10
b=(i//100)%10
a=i//1000
if a+b+c+d==7:
    print(a,"+",b,"+",c,"+",d,"=7",sep="")
elif a+b+c-d==7:
    print(a,"+",b,"+",c,"-",d,"=7",sep="")
elif a+b-c+d==7:
    print(a,"+",b,"-",c,"+",d,"=7",sep="")
elif a+b-c-d==7:
    print(a,"+",b,"-",c,"-",d,"=7",sep="")
elif a+b+c+d==7:
    print(a,"-",b,"+",c,"+",d,"=7",sep="")
elif a+b+c+d==7:
    print(a,"-",b,"+",c,"-",d,"=7",sep="")
elif a+b+c+d==7:
    print(a,"-",b,"-",c,"+",d,"=7",sep="")
else:
    print(a,"-",b,"-",c,"-",d,"=7",sep="")

Submission status: Wrong Answer

Solution code:
x=int(input())
dig=[]
for i in range(1,4):
  dig.append(x%(10))
  x=x//10
dig.append(x)

d,c,b,a=dig

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:
ticket = input()


for i in range(1 << 3):
    s = ticket[0]
    for j in range(3):
        if (i>>j) & 1:
            s += '+' + ticket[j+1]
        else:
            s += '-' + ticket[j+1]
    print(s)
    if eval(s) == 7:
        exit()

Submission status: Wrong Answer

Solution code:
arr = map(int,list(raw_input()))

printed = False

def comb(strs,sums,i):
		global printed
		if i == 3 and sums == 7 and not printed: 
			print str(arr[0]) + strs[0] + str(arr[1]) + strs[1] + str(arr[2]) + strs[2] + str(arr[3])
			printed = True

		elif i < 3:
			comb(strs+'+',sums+arr[i+1],i+1)
			comb(strs+'-',sums-arr[i+1],i+1)



comb('',arr[0],0)

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int,[num for num in input()])

if A+B+C+D == 7:
    print("%s+%s+%s+%s=7" %(A,B,C,D))
elif A-B+C+D == 7:
    print("%s-%s+%s+%s=7" %(A,B,C,D))
elif A+B-C+D == 7:
    print("%s+%s-%s+%s=7" %(A,B,C,D))
elif A+B+C-D == 7:
    print("%s+%s+%s-%s=7" %(A,B,C,D))
elif A-B-C+D == 7:
    print("%s-%s+%s+%s=7" %(A,B,C,D))
elif A-B+C-D == 7:
    print("%s-%s+%s-%s=7" %(A,B,C,D))
elif A+B-C-D == 7:
    print("%s+%s-%s-%s=7" %(A,B,C,D))
elif A-B-C-D == 7:
    print("%s-%s-%s-%s=7" %(A,B,C,D))
else:
    print("No solution found.")