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

while True:
    if A + B + C + D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        break
    elif A + B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        break
    elif A + B - C + D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        break
    elif A + B - C - D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        break
    elif A - B + C + D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        break
    elif A - B - C + D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        break
    elif A - B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        break
    elif A - B - C - D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        break

Submission status: Wrong Answer

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

while True:
    if A + B + C + D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        break
    elif A + B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        break
    elif A + B - C + D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        break
    elif A + B - C - D == 7:
        print(str(A) + "+" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        break
    if A - B + C + D == 7:
        print(str(A) + "-" + str(B) + "+" + str(C) + "+" + str(D) + "=7")
        break
    elif A - B - C + D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "+" + str(D) + "=7")
        break
    elif A - B + C - D == 7:
        print(str(A) + "+" + str(B) + "+" + str(C) + "-" + str(D) + "=7")
        break
    elif A - B - C - D == 7:
        print(str(A) + "-" + str(B) + "-" + str(C) + "-" + str(D) + "=7")
        break

Submission status: Wrong Answer

Solution code:
import itertools
il = list(map(int,list(input())))
flag = True
for i in itertools.product(range(2),repeat=3):
    if flag:
        if il[0]+((-1)**i[0])*il[1]+((-1)**i[1])*il[2]+((-1)**i[2])*il[3] == 7:
            print(i)
            flag = False
            op1, op2, op3 = "+", "+", "+"
            if i[0]:
                op1 = "-"
            if i[1]:
                op2 = "-"
            if i[2]:
                op3 = "-"
            print(str(il[0])+op1+str(il[1])+op2+str(il[2])+op3+str(il[3])+"=7")
    else:
        break

Submission status: Wrong Answer

Solution code:
import itertools
il = list(map(int,list(input())))
flag = True
for i in itertools.product(range(2),repeat=3):
    if flag:
        if il[0]+((-1)**i[0])*il[1]+((-1)**i[1])*il[2]+((-1)**i[2])*il[3] == 7:
            flag = False
            op1, op2, op3 = "-", "-", "-"
            if i[0]:
                op1 = "+"
            if i[1]:
                op2 = "+"
            if i[2]:
                op3 = "+"
            print(str(il[0])+op1+str(il[1])+op2+str(il[2])+op3+str(il[3])+"=7")
    else:
        break

Submission status: Wrong Answer

Solution code:
import itertools
il = list(map(int,list(input())))

flag = True
for i in itertools.product(range(2),repeat=3):
    if flag:
        ticket_sum = il[0] + ((-1)**i[0]) * il[1] + ((-1)**i[1]) * il[2]+ ((-1)**i[2]) * il[3]
        if ticket_sum == 7:
            flag = False
            op1, op2, op3 = "-", "-", "-"
            if i[0]:
                op1 = "+"
            if i[1]:
                op2 = "+"
            if i[2]:
                op3 = "+"
            print(str(il[0])+op1+str(il[1])+op2+str(il[2])+op3+str(il[3])+"=7")
    else:
        break

Submission status: Wrong Answer

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

n = 3
c_list = [list(map(int,format(i,"b").zfill(n))) for i in range(2**n)]

for i in c_list:
    for j, v in enumerate(i):
        if v == 1:
            input_list[j+1] = input_list[j+1] * -1
    if sum(input_list) == 7:
        break
ans = [str(input_list[0])]
for j in range(3):
    if i[j] == 0:
        ans.append("+")
    ans.append(str(input_list[j+1]))
else:
    ans.append("=7")

print("".join(ans))

Submission status: Wrong Answer

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

if A+B+C+D == 7: print("{0}+{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C+D == 7: print("{0}-{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B-C+D == 7: print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B-C-D == 7: print("{0}-{1}-{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7: print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A+B+C-D == 7: print("{0}+{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7: print("{0}+{1}-{2}-{3}=7".format(A,B,C,D))
elif A-B+C-D == 7: print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))

Submission status: Wrong Answer

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

if A+B+C+D == 7: print("{0}+{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C+D == 7: print("{0}-{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B-C+D == 7: print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B-C-D == 7: print("{0}-{1}-{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7: print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A+B+C-D == 7: print("{0}+{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C+D == 7: print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B+C-D == 7: print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
abcd = [int(_) for _ in list(input())]
op = [0, 1]


def cal(ops, abcd, tsum):
    if ops:
        if ops.pop(0):
            _ = abcd.pop(0)
            return cal(ops, abcd, tsum + _)
        else:
            _ = abcd.pop(0)
            return cal(ops, abcd, tsum - _)
    else:
        return tsum


for op1 in op:
    for op2 in op:
        for op3 in op:
            ops = [op1, op2, op3]
            if cal(ops, abcd[1:], abcd[0]) == 7:
                ops = [op1, op2, op3]
                break

abcd = [str(_) for _ in abcd]
ops = ['+' if op else '-' for op in ops]
tmp = [abcd[i] + _ for i, _ in enumerate(ops)]
tmp.append(abcd[-1])
print(''.join(tmp) + '=7')

Submission status: Wrong Answer

Solution code:
n = [int(i) for i in input()]
n_cp = n[:]
total = n_cp.pop(0)

op = [False,False,False]




for i in range(3):
    max_i = n_cp.index(max(n_cp))
    
    if total < 7:
        total += n_cp[max_i]
        op[max_i] = True
    else:
        total -= n_cp[max_i]
        op[max_i] = False
    
    n_cp[max_i] = -1

ans = str(n[0])

for i,o in enumerate(op):
    if o:
        ans+="+" + str(n[i+1])
    else:
        ans+="-" + str(n[i+1])

print(ans+"=7")

Submission status: Wrong Answer

Solution code:
s=input()
for op1 in '+-':
  for op2 in '+-':
    for op3 in '+-':
      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:
import sys

def calc(operator, array):
    if operator == "+":
        return array[0] + array[1]
    else:
        return array[0] - array[1]


n = list(input())
n_int = list(map(int, n))
operator_array = ["+", "-"]

for i in operator_array:
    for j in operator_array:
        for k in operator_array:
            if calc(i, [calc(j, n_int[:2]), calc(k, n_int[2:])]) == 7:
                print("{0}{1}{2}{3}{4}{5}{6}=7".format(
                    n_int[0], j, n_int[1], i, n_int[2], k, n_int[3]))
                sys.exit()

Submission status: Wrong Answer

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

op = ['+', '-']

for i in range(7):
    formula = A + op[(i >> 0) & 1] + B + op[(i >> 1) & 1] + C + op[(i >> 2) & 1] + D
    if eval(formula) == 7:
        print(formula)
        break

Submission status: Wrong Answer

Solution code:
p = str(input())

q =list(str(p))
r = []

for i in range(len(q)):
    r.append(int(q[i]))

a = r[0]
b = [-r[1],r[1]]
c = [-r[2],r[2]]
d = [-r[3],r[3]]

e = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a + b[i] + c[j] + d[k] == 7:
                e.append(a)
                e.append(b[i])
                e.append(c[j])
                e.append(d[k])

for i in range(len(e)):
    if e[i] < 0 or i == 0:
        e[i] = str(e[i])
    else:
        e[i] = '+' + str(e[i])
        
print(e[0] + e[1] + e[2] + e[3])

Submission status: Wrong Answer

Solution code:
p = str(input())

q =list(str(p))
r = []

for i in range(len(q)):
    r.append(int(q[i]))

a = r[0]
b = [-r[1],r[1]]
c = [-r[2],r[2]]
d = [-r[3],r[3]]

e = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            if a + b[i] + c[j] + d[k] == 7:
                e.append(a)
                e.append(b[i])
                e.append(c[j])
                e.append(d[k])
print(e)
for i in range(len(e)):
    if e[i] < 0 or i == 0:
        e[i] = str(e[i])
    else:
        e[i] = '+' + str(e[i])
        
print(e[0] + e[1] + e[2] + e[3])

Submission status: Wrong Answer

Solution code:
s = list(input())
op = ['+','-']

for i in op:
    for j in op:
        for k in op:
            stot = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(stot) == 7:
                print(stot + "=7")
                break

Submission status: Wrong Answer

Solution code:
abcd = list(input())
a,b,c,d = int(abcd[0]),int(abcd[1]),int(abcd[2]),int(abcd[3]),
if (a+b+c+d)==7:
    print(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=input()
a=int(S[0])
b=int(S[1])
c=int(S[2])
d=int(S[3])
def operation(a,b,t):    
    if t==0:return a+b
    else:return a-b
def converter(t):
    if t==0:return "+"
    else:return "-"
e=0
f=0
g=0
for x in range(2):
    for y in range(2):
        for z in range(2):
            e=operation(a,b,x)
            f=operation(e,c,y)
            g=operation(f,d,z)
            if g==7:
                print(str(a)+converter(x)+str(b)+converter(y)+str(c)+converter(z)+str(d)+"=7")
                break

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def myprint(c1,c2,c3):
    return print(str(a)+c1+str(b)+c2+str(c)+c3+str(d)+'=7')

if a+b+c+d==7:
    myprint('+','+','+')
if a+b+c-d==7:
    myprint('+','+','-')
if a+b-c+d==7:
    myprint('+','-','+')
if a+b-c-d==7:
    myprint('+','-','-')
if a-b+c+d==7:
    myprint('-','+','+')
if a-b+c-d==7:
    myprint('-','+','-')
if a-b-c+d==7:
    myprint('-','-','+')
if a-b-c-d==7:
    myprint('-','-','-')

Submission status: Wrong Answer

Solution code:
import itertools

A, B, C, D = [int(s) for s in list(input())]
print('A:{}, B:{}, C:{}, D:{}'.format(A, B, C, D))

symbols = ['+', '-']
for s1, s2, s3 in itertools.product(symbols, symbols, symbols):
    N = 0
    N = A + B if s1 == '+' else A - B
    N = N + C if s2 == '+' else N - C
    N = N + D if s3 == '+' else N - D
    if N == 7:
        print('{}{}{}{}{}{}{}={}'.format(A, s1, B, s2, C, s3, D, N))
        break

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
ans=0
for i in range(1<<n-1):
    num=s[0]
    for j in range(n-1):
        if i&(1<<j):
            num+="+"+s[j+1]
        else:
            num+="-"+s[j+1]
    if eval(num)==7:
        print(num+"=7")
        exit

Submission status: Wrong Answer

Solution code:
s=list(input().strip())

if int(s[0])+int(s[1])+int(s[2])+int(s[3])==7:
  print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3])
elif int(s[0])-int(s[1])-int(s[2])-int(s[3])==7:
  print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3])
elif int(s[0])+int(s[1])-int(s[2])-int(s[3])==7:
  print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3])
elif int(s[0])+int(s[1])+int(s[2])-int(s[3])==7:
  print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3])
elif int(s[0])-int(s[1])+int(s[2])-int(s[3])==7:
  print(s[0]+"-"+s[1]+"+"+s[2]+"-"+s[3])
elif int(s[0])-int(s[1])+int(s[2])+int(s[3])==7:
  print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3])
elif int(s[0])+int(s[1])-int(s[2])+int(s[3])==7:
  print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3])
elif int(s[0])-int(s[1])-int(s[2])+int(s[3])==7:
  print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3])
else:
  print(-1)

Submission status: Wrong Answer

Solution code:
def dfs(N, ops, nums, Sum):
    if N == 3:
        if Sum == 7:
            print(str(nums[0])+ops[0]+str(nums[1])+ops[1]+str(nums[2])+ops[2]+str(nums[3]))
            return True
        else:
            return False
    else:
        ops[N]="+"
        if dfs(N+1, ops, nums, Sum+nums[N+1]):
            return True
        ops[N]="-"
        if dfs(N+1, ops, nums, Sum-nums[N+1]):
            return True

nums=[int(i) for i in input()]
ops=["" for i in range(3)]
dfs(0, ops, nums, nums[0])

Submission status: Wrong Answer

Solution code:
a=list(map(int,input()))
if a[0]+a[1]+a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"==7")
    exit()
elif a[0]+a[1]+a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"==7")
    exit()
elif a[0]+a[1]-a[2]+a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"==7")
    exit()
elif a[0]+a[1]-a[2]-a[3]==7:
    print(str(a[0])+"+"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"==7")
    exit()
elif  a[0]-a[1]+a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"+"+str(a[3])+"==7")
    exit()
elif a[0]-a[1]+a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"+"+str(a[2])+"-"+str(a[3])+"==7")
    exit()
elif a[0]-a[1]-a[2]+a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"+"+str(a[3])+"==7")
    exit()
elif a[0]-a[1]-a[2]-a[3]==7:
    print(str(a[0])+"-"+str(a[1])+"-"+str(a[2])+"-"+str(a[3])+"==7")
    exit()

Submission status: Wrong Answer

Solution code:
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3], "=7")
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product

s = tuple(map(int, tuple(input())))

options = (-1, 1)

for op1, op2, op3 in product(options, repeat=3):
    if (s[0] + s[1] * op1 + s[2] * op2 + s[3] * op3) == 7:
        _op1 = "+" if op1 == 1 else "-"
        _op2 = "+" if op2 == 1 else "-"
        _op3 = "+" if op3 == 1 else "-"
        print(s[0], _op1, s[1], _op2, s[2], _op3, s[3])
        exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A,B,C,D = list(map(int, list(input())))

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:


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

for op1 in "-+":
    for op2 in "-+":
        for op3 in "-+":
            e = 0
            e += a + b if op1 == '+' else a - b
            e += c if op2 == '+' else -c
            e += d if op3 == '+' else -d
            if e == 7:
                s = str(a) + op1 + str(b) + op2 + str(c) + op3 + str(d)
                print(e)
                exit(0)

Submission status: Wrong Answer

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

marks = "+-*/"
template = "{0}{1}{2}{3}{4}{5}{6}"
for m1 in marks:
    for m2 in marks:
        for m3 in marks:
            formula = template.format(a,m1,b,m2,c,m3,d)
            try:
                if eval(formula) == 7:
                    print(formula+"=7")
                    exit(0)
            except Exception as e:
                continue

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

import numpy as np
li=np.array(list(map(int,list(input()))))
wa=[
   [1,1,1,1],
   [1,1,1,-1],
   [1,1,-1,1],
   [1,1,-1,-1],
   [1,-1,1,1],
   [1,-1,1,-1],
   [1,-1,-1,1],
   [1,-1,-1,-1],
   [-1,1,1,1],
   [-1,1,1,-1],
   [-1,1,-1,1],
   [-1,1,-1,-1],
   [-1,-1,1,1],
   [-1,-1,1,-1],
   [-1,-1,-1,1],
   [-1,-1,-1,-1],
  ]
wa=np.array(wa)
for w in wa:
  if np.dot(w,li)==7:
    isfirst=True
    for p,i in zip(w,range(4)):
        if isfirst:
            print(li[0],end='')
            isfirst=False
            continue
        if p >0:
            print('+',end=str(li[i]))
        else:
            print('+',end=str(li[i]))
    print('=7')
    quit()

Submission status: Wrong Answer

Solution code:
import itertools
N=[int(x) for x in input()]
op=['+','-']
for op1 in op:
  for op2 in op:
    for op3 in op:
      if op1=='+': ans=N[0]+N[1]
      else: ans=N[0]-N[1]
      if op2=='+': ans+=N[2]
      else: ans-=N[2]
      if op3=='+': ans+=N[3]
      else: ans-=N[3]
      if ans==7:
        print(op1,end="")
        print(N[1],end="")
        print(op2,end="")
        print(N[2],end="")
        print(op3,end="")
        print(N[3],end="")
        print("=7")
        exit()

Submission status: Wrong Answer

Solution code:
import itertools
N=[int(x) for x in input()]
op=['+','-']
for op1 in op:
  if op1=='+': ans=N[0]+N[1]
  else: ans=N[0]-N[1]
  for op2 in op:
    if op2=='+': ans+=N[2]
    else: ans-=N[2]
    for op3 in op:
      if op3=='+': ans+=N[3]
      else: ans-=N[3]
      if ans==7:
        print(N[0],end="")
        print(op1,end="")
        print(N[1],end="")
        print(op2,end="")
        print(N[2],end="")
        print(op3,end="")
        print(N[3],end="")
        print("=7")
        exit()

Submission status: Wrong Answer

Solution code:
import sys

x = input()

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

work = A
op1,op2,op3 = "","",""
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i == 1:
                op1 = "+"
                work += B
            else:
                op1 = "-"
                work -= B
            if j == 1:
                op2 = "+"
                work += C
            else:
                op2 = "-"
                work -= C
            if k == 1:
                op3 = "+"
                work += D
            else:
                op3 = "-"
                work -= D
            if work ==7:
                print(x[0]+op1+x[1]+op2+x[2]+op3+x[3])
                sys.exit()
            else:
                work = A

Submission status: Wrong Answer

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

if int(A)+int(B)+int(C)+int(D) == 7:
	ans=A+'+'+B+'+'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)+int(C)-int(D) == 7:
	ans=A+'+'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)+int(B)-int(C)+int(D) == 7:
	ans=A+'+'+B+'-'+C+'+'+D+'=7'
	print(ans)

elif int(A)+int(B)-int(C)-int(D) == 7:
	ans=A+'+'+B+'-'+C+'-'+D+'=7'
	print(ans)

elif int(A)-int(B)+int(C)+int(D) == 7:
	ans=A+'-'+B+'+'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)+int(C)-int(D) == 7:
	ans=A+'-'+B+'+'+C+'-'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)+int(D) == 7:
	ans=A+'+'+B+'-'+C+'+'+D+'=7'
	print(ans)
	
elif int(A)-int(B)-int(C)-int(D) == 7:
	ans=A+'-'+B+'-'+C+'-'+D+'=7'
	print(ans)

Submission status: Wrong Answer

Solution code:
N = input()
H = [int(N[0]), int(N[1]), int(N[2]), int(N[3])]
print(H)
A = H[0]
B = H[1]
C = H[2]
D = H[3]
# A = N[0], B = N[1], C = N[2], D = N[3]
# a = N[0], b = N[1], c = N[2], d = N[3]
# A = int(a), B = int(b), C = int(c), D = int(d)
c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}

if A+B+C+D == 7:
    print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '=7')
elif A+B+C-D == 7:
    print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '=7')
elif A+B-C+D == 7:
    print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '=7')
elif A+B-C-D == 7:
    print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '=7')
elif A-B+C+D == 7:
    print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '=7')
elif A-B+C-D == 7:
    print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '=7')
elif A-B-C+D == 7:
    print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '=7')
elif A-B-C-D == 7:
    print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '=7')

Submission status: Wrong Answer

Solution code:
N = input()
H = [int(N[0]), int(N[1]), int(N[2]), int(N[3])]
print(H)
A = H[0]
B = H[1]
C = H[2]
D = H[3]
# A = N[0], B = N[1], C = N[2], D = N[3]
# a = N[0], b = N[1], c = N[2], d = N[3]
# A = int(a), B = int(b), C = int(c), D = int(d)
c1 = {'op1':'+', 'op2':'+', 'op3':'+'}
c2 = {'op1':'+', 'op2':'+', 'op3':'-'}
c3 = {'op1':'+', 'op2':'-', 'op3':'+'}
c4 = {'op1':'+', 'op2':'-', 'op3':'-'}
c5 = {'op1':'-', 'op2':'+', 'op3':'+'}
c6 = {'op1':'-', 'op2':'+', 'op3':'-'}
c7 = {'op1':'-', 'op2':'-', 'op3':'+'}
c8 = {'op1':'-', 'op2':'+', 'op3':'+'}

if A+B+C+D == 7:
    print(str(A) + c1['op1'] + str(B) + c1['op2'] + str(C) + c1['op3'] + str(D) + '= 7')
elif A+B+C-D == 7:
    print(str(A) + c2['op1'] + str(B) + c2['op2'] + str(C) + c2['op3'] + str(D) + '= 7')
elif A+B-C+D == 7:
    print(str(A) + c3['op1'] + str(B) + c3['op2'] + str(C) + c3['op3'] + str(D) + '= 7')
elif A+B-C-D == 7:
    print(str(A) + c4['op1'] + str(B) + c4['op2'] + str(C) + c4['op3'] + str(D) + '= 7')
elif A-B+C+D == 7:
    print(str(A) + c5['op1'] + str(B) + c5['op2'] + str(C) + c5['op3'] + str(D) + '= 7')
elif A-B+C-D == 7:
    print(str(A) + c6['op1'] + str(B) + c6['op2'] + str(C) + c6['op3'] + str(D) + '= 7')
elif A-B-C+D == 7:
    print(str(A) + c7['op1'] + str(B) + c7['op2'] + str(C) + c7['op3'] + str(D) + '= 7')
elif A-B-C-D == 7:
    print(str(A) + c8['op1'] + str(B) + c8['op2'] + str(C) + c8['op3'] + str(D) + '= 7')

Submission status: Wrong Answer

Solution code:
lis = map(int,list(raw_input()))
outop = []
out = ""
for i in xrange(8):
	n2 = format(i,"03b")
	oplis = map(int,list(str(n2)))
	sum = lis[0]
	for num in xrange(3):
		if oplis[num] == 1:
			sum += lis[num+1]
		else:
			sum -= lis[num+1]
	if sum == 7:
		for op in oplis:
			if op == 1:
				outop.append("+")
			else:
				outop.append("-")
		print  "{0[0]}{1[0]}{0[1]}{1[1]}{0[2]}{1[2]}{0[3]}=7".format(lis,outop)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
A, B, C, D = map(int, list(raw_input()))

if A+B+C+D == 7:
    print '%s+%s+%s+%s' % (A, B, C, D)
elif A+B+C-D == 7:
    print '%s+%s+%s-%s' % (A, B, C, D)
elif A+B-C+D == 7:
    print '%s+%s-%s+%s' % (A, B, C, D)
elif A-B+C+D == 7:
    print '%s-%s+%s+%s' % (A, B, C, D)
elif A+B-C-D == 7:
    print '%s+%s-%s-%s' % (A, B, C, D)
elif A-B+C-D == 7:
    print '%s-%s+%s-%s' % (A, B, C, D)
elif A-B-C+D == 7:
    print '%s-%s-%s+%s' % (A, B, C, D)
elif A-B-C-D == 7:
    print '%s-%s-%s-%s' % (A, B, C, D)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
p = int(input())
a = p // 1000
b = (p // 100) % 10
c = (p // 10) % 10
d = p % 10


if a + b + c + d == 7:
    print("{}+{}+{}+{}=7".format(a,b,c,d))
elif a + b + c - d == 7:
    print("{}+{}+{}-{}=7".format(a,b,c,d))
elif a + b - c + d == 7:
    print("{}+{}-{}+{}=7".format(a,b,c,d))
elif a + b - c - d == 7:
    print("{}+{}-{}-{}=7".format(a,b,c,d))
elif a - b + c + d == 7:
    print("{}-{}+{}+{}=7".format(a,b,c,d))
elif a - b + c - d:
    print("{}-{}+{}-{}=7".format(a,b,c,d))
elif a - b - c + d == 7:
    print("{}-{}-{}+{}=7".format(a,b,c,d))
elif a - b - c - d == 7:
    print("{}-{}-{}-{}=7".format(a,b,c,d))

Submission status: Wrong Answer

Solution code:
s=input()
listA=[0,0,0,0]
i=0
for x in s:
    listA[i]=int(x)
    i+=1
a=listA[0]
b=listA[1]
c=listA[2]
d=listA[3]
if(a+b+c+d==7):
    print("%d+%d+%d+%d==7"% (a,b,c,d))
elif(a+b+c-d==7):
    print("%d+%d+%d-%d==7"% (a,b,c,d))
elif(a+b-c+d==7):
    print("%d+%d-%d+%d==7" % (a, b, c, d))
elif(a+b-c-d==7):
    print("%d+%d-%d-%d==7" % (a, b, c, d))
elif(a-b+c+d==7):
    print("%d-%d+%d+%d==7" % (a, b, c, d))
elif(a-b-c+d==7):
    print("%d-%d-%d+%d==7" % (a, b, c, d))
elif(a-b-c-d==7):
    print("%d-%d-%d-%d==7" % (a, b, c, d))
elif(a-b+c-d==7):
    print("%d-%d+%d-%d==7" % (a, b, c, d))

Submission status: Wrong Answer

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

ppp = lambda a,b,c,d: (a+b+c+d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
pps = lambda a,b,c,d: (a+b+c-d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
psp = lambda a,b,c,d: (a+b-c+d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
pss = lambda a,b,c,d: (a+b-c-d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
spp = lambda a,b,c,d: (a-b+c+d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
sps = lambda a,b,c,d: (a-b+c-d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
ssp = lambda a,b,c,d: (a-b-c+d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))
sss = lambda a,b,c,d: (a-b-c-d == 7, "%d+%d+%d+%d=7" % (a,b,c,d))

li = [ppp, pps, psp, pss, spp, sps, ssp, sss]
for l in li:
    if l(a, b, c, d)[0]:
        print l(a,b,c,d)[1]

Submission status: Wrong Answer

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

def plus(x,y):
    return x+y

def minus(x,y):
    return x-y

pm_list = [plus,minus]
print_list = ["+","-"]

for i,method in enumerate(pm_list):
    goukei = 0
    goukei = method(a,b)
    for j,method2 in enumerate(pm_list):
        goukei = method2(goukei,c)
        for k,method3 in enumerate(pm_list):
            goukei = method3(goukei,d)
            
            if goukei == 7:
                kw = str(a)+print_list[i]+str(b)+print_list[j]+str(c)+print_list[k]+str(d)+"=7"
                print(kw)
                break
        if goukei ==7:
            break
            
    if goukei ==7:
        break

Submission status: Wrong Answer

Solution code:
a = [int(i) for i in list(input())]
enzan = ['+', '+', '+']
res = 0
for i in range(2):
	if i == 0:
		enzan[0] = '+'
		b = a[0] + a[1]
	else:
		enzan[0] = '-'
		b = a[0] - a[1]
	for j in range(2):
		if j == 0:
			enzan[1] = '+'
			c = b + a[2]
		else:
			enzan[1] = '-'
			c = b - a[2]
		for k in range(2):
			if k == 0:
				enzan[2] = '+'
				d = c + a[3]
			else:
				enzan[2] = '-'
				d = b - a[3]
			if d == 7:
				print(str(a[0])+enzan[0]+str(a[1])+enzan[1]+str(a[2])+enzan[2]+str(a[3])+'=7')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N = input()

for i in range(8):
    num = [int(i) for i in N]
    for j in range(3):
        if (i >> j) % 2 == 1:
            num[j] *= -1
    if sum(num) == 7:
        print('{:d}{:+d}{:+d}{:+d}=7'.format(num[0], num[1], num[2], num[3]))
        break

Submission status: Wrong Answer

Solution code:
s = raw_input()
[a,b,c,d] = [int(t) for t in s]
if a + b + c + d == 7:
    print str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)
elif a + b + c - d == 7:
    print str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)
elif a + b - c + d == 7:
    print str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)
elif a + b - c - d == 7:
    print str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)
elif a - b + c + d == 7:
    print str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)
elif a - b + c - d == 7:
    print str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)
elif a - b - c + d == 7:
    print str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)
elif a - b - c - d == 7:
    print str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)

Submission status: Wrong Answer

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

k = [
[1, 1, 1],
[1, 1, -1],
[1, -1, 1],
[1, -1, -1],
[-1, 1, 1],
[-1, 1, -1],
[-1, -1, 1],
[-1, -1, -1]]

p = ""

for i in k:
  if (a + b * i[0] + c * i[1] + d * i[2]) == 7:
    p += str(a)
    p += "+" if i[0] == 1 else "-"
    p += str(b)
    p += "+" if i[1] == 1 else "-"
    p += str(c)
    p += "+" if i[2] == 1 else "-"
    p += str(d)
    p += "=7"
    print(p)
    p = ""

Submission status: Wrong Answer

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

def judge(a, b, c, d):
  if a + b + c + d == 7:
    return '{}+{}+{}+{}=7'.format(a, b, c, d)
  elif a - b - c - d == 7:
    return '{}-{}-{}-{}=7'.format(a, b, c, d)
  elif a + b - c - d == 7:
    return '{}+{}-{}-{}=7'.format(a, b, c, d)
  elif a - b + c - d == 7:
    return '{}-{}+{}-{}=7'.format(a, b, c, d)
  elif a - b - c + d == 7:
    return '{}-{}-{}+{}=7'.format(a, b, c, d)
  elif a - b + c + d == 7:
    return '{}-{}+{}+{}=7'.format(a, b, c, d)
  elif a + b - c + d == 7:
    return '{}+{}-{}+{}=7'.format(a, b, c, d)

print(judge(A, B, C, D))