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

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

elif a-b-c-d == 7:
	print('{0}-{1}-{2}-{3}=7' .format(str(a),str(b),str(c),str(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('{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 = str, input()
ABCD_list = list(ABCD[1])
A = int(ABCD_list[0])
B = int(ABCD_list[1])
C = int(ABCD_list[2])
D = int(ABCD_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:
# coding: utf-8
N=input()
lst=list(N)
#+++
if (int(lst[0])+int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
#---
elif (int(lst[0])-int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
#-+-    
elif (int(lst[0])-int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
#+-+    
elif (int(lst[0])+int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=7')

#++-
elif (int(lst[0])+int(lst[1])+int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'-'+lst[3]+'=7')
#+--    
elif (int(lst[0])+int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
#-++    
elif (int(lst[0])-int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
#--+   
elif (int(lst[0])-int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=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])

if a+b+c+d == 7:
	print('{0}+{1}+{2}+{3}=7' .format(a,b,c,d))
	
if a-b+c+d == 7:
	print('{0}-{1}+{2}+{3}=7' .format(a,b,c,d))

if a+b-c+d == 7:
	print('{0}+{1}-{2}+{3}=7' .format(a,b,c,d))

if a+b+c-d == 7:
	print('{0}+{1}+{2}—{3}=7' .format(a,b,c,d))

if a-b-c+d == 7:
	print('{0}-{1}-{2}+{3}=7' .format(a,b,c,d))
	
if a+b-c-d == 7:
	print('{0}+{1}-{2}-{3}=7' .format(a,b,c,d))
	
if a-b+c-d == 7:
	print('{0}-{1}+{2}-{3}=7' .format(a,b,c,d))

if a-b-c-d == 7:
	print('{0}-{1}-{2}-{3}=7' .format(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('{0}+{1}+{2}+{3}=7' .format(a,b,c,d))
	
if a-b+c+d == 7:
	print('{0}-{1}+{2}+{3}=7' .format(a,b,c,d))

if a+b-c+d == 7:
	print('{0}+{1}-{2}+{3}=7' .format(a,b,c,d))

if a+b+c-d == 7:
	print('{0}+{1}+{2}—{3}=7' .format(a,b,c,d))

if a-b-c+d == 7:
	print('{0}-{1}-{2}+{3}=7' .format(a,b,c,d))
	
if a+b-c-d == 7:
	print('{0}+{1}-{2}-{3}=7' .format(a,b,c,d))
	
if a-b+c-d == 7:
	print('{0}-{1}+{2}-{3}=7' .format(a,b,c,d))

if a-b-c-d == 7:
	print('{0}-{1}-{2}-{3}=7' .format(a,b,c,d))
	
else:
	print('False')

Submission status: Wrong Answer

Solution code:
# coding: utf-8
N=input()
lst=list(N)
if (int(lst[0])+int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
    
elif (int(lst[0])-int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
    
elif (int(lst[0])-int(lst[1])+int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'+'+lst[3]+'=7')
    
elif (int(lst[0])+int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=7')
    
elif (int(lst[0])+int(lst[1])+int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'+'+lst[1]+'+'+lst[2]+'-'+lst[3]+'=7')
    
elif (int(lst[0])+int(lst[1])-int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'-'+lst[3]+'=7')
    
elif (int(lst[0])-int(lst[1])+int(lst[2])-int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'+'+lst[2]+'-'+lst[3]+'=7')
    
elif (int(lst[0])-int(lst[1])-int(lst[2])+int(lst[3]))==7:
    print(lst[0]+'-'+lst[1]+'-'+lst[2]+'+'+lst[3]+'=7')

Submission status: Wrong Answer

Solution code:
sr = input()

a, b, c, d = int(sr[0]), int(sr[1]), int(sr[2]), int(sr[3])

def calc(one, two, three):
  if a + one*b + two*c + three*d == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  

for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        break
    else:
      continue
    break

Submission status: Wrong Answer

Solution code:

def f2(a,b,c,d,s):
    if a-b<7:
        if a-b+c<7:
            if a-b+c+d==7:
                s[1],s[3],s[5]="-","+","+"
        elif a-b+c>=7:
            if a-b+c-d==7:
                s[1],s[3],s[5]="-","+","-"
    elif a-b>=7:
        if a-b-c<7:
            if a-b-c+d==7:
                s[1],s[3],s[5]="-","-","+"
        elif a-b-c>=7:
            if a-b-c-d==7:
                s[1],s[3],s[5]="-","-","-"

def f1(a,b,c,d,s):
    if a+b<7:
        if a+b+c<7:
            if a+b+c+d==7:
                s[1],s[3],s[5]="+","+","+"
            elif a+b+c+d!=7:
                f2(a,b,c,d,s)
        elif a+b+c>=7:
            if a+b+c-d==7:
                s[1],s[3],s[5]="+","+","-"
            elif a+b+c-d!=7:
                f2(a,b,c,d,s)
    elif a+b>=7:
        if a+b-c<7:
            if a+b-c+d==7:
                s[1],s[3],s[5]="+","-","+"
            elif a+b-c+d!=7:
                f2(a,b,c,d,s)
        elif a+b-c>=7:
            if a+b-c-d==7:
                s[1],s[3],s[5]="+","-","-"
            elif a+b-c-d!=7:
                f2(a,b,c,d,s)



x=str(input())
ans=''

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

s=[a,"",b,"",c,"",d]

f1(a,b,c,d,s)

for x in s:
    ans+=str(x)

print(ans+"=7")

Submission status: Wrong Answer

Solution code:
n = input()
num = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
if sum(num) == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")

Submission status: Wrong Answer

Solution code:

def f2(a,b,c,d,s):
    if a-b<7:
        if a-b+c<7:
            if a-b+c+d==7:
                s[1],s[3],s[5]="-","+","+"
        elif a-b+c>=7:
            if a-b+c-d==7:
                s[1],s[3],s[5]="-","+","-"
    elif a-b>=7:
        if a-b-c<7:
            if a-b+c+d==7:
                s[1],s[3],s[5]="-","-","+"
        elif a-b-c>=7:
            if a-b+c-d==7:
                s[1],s[3],s[5]="-","-","-"

def f1(a,b,c,d,s):
    if a+b<7:
        if a+b+c<7:
            if a+b+c+d==7:
                s[1],s[3],s[5]="+","+","+"
            elif a+b+c+d!=7:
                f2(a,b,c,d,s)
        elif a+b+c>=7:
            if a+b+c-d==7:
                s[1],s[3],s[5]="+","+","-"
            elif a+b+c-d!=7:
                f2(a,b,c,d,s)
    elif a+b>=7:
        if a+b-c<7:
            if a+b-c+d==7:
                s[1],s[3],s[5]="+","-","+"
            elif a+b-c+d!=7:
                f2(a,b,c,d,s)
        elif a+b-c>=7:
            if a+b-c-d==7:
                s[1],s[3],s[5]="+","-","-"
            elif a+b-c-d!=7:
                f2(a,b,c,d,s)



x=str(input())
ans=''

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

s=[a,"",b,"",c,"",d]

f1(a,b,c,d,s)

for x in s:
    ans+=str(x)

print(ans+"=7")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
check = True
ans = ''
for key1 in keys:
    if key1 == '+' and check:
        x = int(N[0]) + int(N[1])
    elif(key1 == '-' and check):
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+' and check:
            x = x  + int(N[2])
        elif(key2 == '-' and check):
            x = x  - int(N[2])
            
        for key3 in keys:
            if key3 == '+' and check:
                x = x  + int(N[3])
                if (x == 7):
                    ans = N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    #print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False
                else:
                    x = 0
            elif(key3 == '-' and check):
                x = x  - int(N[3])

                if (x == 7):
                    ans =  N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False

                else:
                    x = 0
print ans

Submission status: Wrong Answer

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
check = True
for key1 in keys:
    if key1 == '+' and check:
        x = int(N[0]) + int(N[1])
    elif(key1 == '-' and check):
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+' and check:
            x = x  + int(N[2])
        elif(key2 == '-' and check):
            x = x  - int(N[2])
            
        for key3 in keys:
            if key3 == '+' and check:
                x = x  + int(N[3])
                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False

                else:
                    x = 0
            elif(key3 == '-' and check):
                x = x  - int(N[3])

                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+ '=7'
                    check = False

                else:
                    x = 0

Submission status: Wrong Answer

Solution code:
r = input()
a = int(r[0])
b = int(r[1])
c = int(r[2])
d = int(r[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")
else:
  print(a,"-",b,"-",c,"-",d,"=7")

Submission status: Wrong Answer

Solution code:


def ans(x1, x2, x3, x4, state1, state2, state3):
    return int(eval("{}{}{}{}{}{}{}".format(x1,state1,x2,state2,x3,state3,x4)))

n = input()

x1 = int(n[0])
x2 = int(n[1])
x3 = int(n[2])
x4 = int(n[3])

state1 = "+"
state2 = "+"
state3 = "+"

x = 7

for n in range(8):
    k = n
    if bin(k)[2] == "0":
        state1 = "+"
    else:
        state1 = "-"
    try:
        if bin(k)[3] == "0":
            state2 = "+"
        else:
            state2 = "-"
    except:
        state2 = "+"
    try:
        if bin(k)[4] == "0":
            state3 = "+"
        else:
            state3 = "-"
    except:
        state3 = "+"
    a = ans(x1, x2,x3,x4,state1,state2,state3)
#    print("{}{}{}{}{}{}{}={}".format(x1,state1,x2,state2,x3,state3,x4,a))
    if a == 7:
        break
print("{}{}{}{}{}{}{}=7".format(x1,state1,x2,state2,x3,state3,x4))
#for n in range(2, 5):
 #   print(bin(x)[n])

Submission status: Wrong Answer

Solution code:
r = input()
a = int(r[0])
b = int(r[1])
c = int(r[2])
d = int(r[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-+d ==7:
  print(a,"-",b,"-",c,"+",d,"=7")
else:
  print(a,"-",b,"-",c,"-",d,"=7")

Submission status: Wrong Answer

Solution code:
sr = input()

a, b, c, d = int(sr[0]), int(sr[1]), int(sr[2]), int(sr[3])

def calc(one, two, three):
  if a + one*b + two*c + three*d == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        break
      else:
        pass 
    break
  break

Submission status: Wrong Answer

Solution code:
sr = input()

a, b, c, d = int(sr[0]), int(sr[1]), int(sr[2]), int(sr[3])

def calc(one, two, three):
  if a + one*b + two*c + three*d == 7:
    return True
  else:
    return False
  
def change(num):
  if num == 1:
    return "+"
  else:
    return "-"
  
for q in [1, -1]:
  for w in [1, -1]:
    for e in [1, -1]:
      if calc(q, w, e):
        r, t, y = change(q), change(w), change(e)
        print(str(a)+r+str(b)+t+str(c)+y+str(d)+"=7")
        break
      else:
        pass  
  break

Submission status: Wrong Answer

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

list = []
list.append(A + B + C + D)
list.append(A + B + C - D)
list.append(A + B - C + D)
list.append(A + B - C - D)
list.append(A - B + C + D)
list.append(A - B + C - D)
list.append(A - B - C + D)
list.append(A - B - C - D)

num = list.index(7)
print(num)

if num <= 3:
    op1 = '+'
else:
    op1 = '-'

if num == 0 or num == 1 or num == 4 or num == 5:
    op2 = '+'
else:
    op2 = '-'

if num % 2 == 0:
    op3 = '+'
else:
    op3 = '-'

print('{}{}{}{}{}{}{}=7'.format(A,op1,B,op2,C,op3,D))

Submission status: Wrong Answer

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
check = True
for key1 in keys:
    if key1 == '+':
        x = int(N[0]) + int(N[1])
    else:
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+':
            x = x  + int(N[2])
        else:
            x = x  - int(N[2])
            
        for key3 in keys:
            if key3 == '+':
                x = x  + int(N[3])
                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'
                    break
                else:
                    x = 0
            else:
                x = x  - int(N[3])

                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'
                    break
                else:
                    x = 0
                
            break
        break

Submission status: Wrong Answer

Solution code:
from itertools import chain, combinations


def all_subsets(ss):
    return chain(*map(lambda x: combinations(ss, x), range(0, len(ss) + 1)))

array=raw_input()

for subset in all_subsets([0,1,2]):
    suma=sum(map(int,str(array)))
    signs=list("+++")

    for ind in subset:
        suma=suma-2*int(array[ind+1])
        signs[ind]='-'

    if suma == 7:
        print array[0],
        for i in range(0,3):
            print signs[i],array[i+1],
        break

Submission status: Wrong Answer

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
for key1 in keys:
    if key1 == '+':
        x = int(N[0]) + int(N[1])
    else:
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+':
            x = x  + int(N[2])
        else:
            x = x  - int(N[2])
            
        for key3 in keys:
            if key3 == '+':
                x = x  + int(N[3])
                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'

                else:
                    x = 0
            else:
                x = x  - int(N[3])

                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'

                else:
                    x = 0

Submission status: Wrong Answer

Solution code:
import math

def test(n):
    s = n[0]
    num = int(n[0])
    for i in n[1:4]:
        if num >= 7:
            s = s + "-" + i
        else:
            s = s + "+" + i
    return (s + "=7")

if __name__ == "__main__":
    n = input()
    print(test(n))

Submission status: Wrong Answer

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

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))
else:
    print("{0}-{1}-{2}-{3}=7".format(a,b,c,d))

Submission status: Wrong Answer

Solution code:
N = raw_input()
keys = ['+','-']
x = 0
for key1 in keys:
    if key1 == '+':
        x = int(N[0]) + int(N[1])
    else:
        x = int(N[0]) - int(N[1])
    for key2 in keys:
        if key2 == '+':
            x = x  + int(N[2])

        else:
            x = x  - int(N[2])

            
        for key3 in keys:
            if key3 == '+':
                x = x  + int(N[3])
                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'
                    break
                else:
                    x = 0
            else:
                x = x  - int(N[3])

                if (x == 7):
                    print N[0] + key1 + N[1] + key2 + N[2] + key3 + N[3]+'=7'
                    break
                else:
                    x = 0

Submission status: Wrong Answer

Solution code:

if __name__=="__main__":
    n = input()
    s = list(n)
    a = int(s[0])
    b = int(s[1])
    c = int(s[2])
    d = int(s[3])

    if a-b-c>=7:
        print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    elif a-b+c>=7:
        print(s[0] + "-" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
    elif a-b+c<7:
        print(s[0] + "-" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
    elif a-b-c<7:
        print(s[0] + "-" + s[1] + "-" + s[2] + "+" + s[3] + "=7")
    elif a+b-c>=7:
        print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3]+"=7")
    elif a+b+c>=7:
        print(s[0] + "+" + s[1] + "+" + s[2] + "-" + s[3] + "=7")
    elif a+b+c<7:
        print(s[0] + "+" + s[1] + "+" + s[2] + "+" + s[3] + "=7")
    elif a+b-c<7:
        print(s[0] + "+" + s[1] + "-" + s[2] + "+" + s[3] + "=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])
x = d+7
y = -d+7
if a+b+c == x:
    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
if a+b+c == y:
    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
if a-b+c == x:
    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
if a-b+c == y:
    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
if a+b-c == x:
    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
if a+b-c == y:
    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
if a-b-c == x:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
if a-b-c == y:
    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")

Submission status: Wrong Answer

Solution code:
a = input()
c = map(int,list(a))
b = []
for i in c:
    b.append(i)
if(b[0] + b[1] + b[2] + b[3]==7):
    print(a[0]+"+"+a[1]+"+"+a[2]+"+"+a[3]+"=7",end="")
elif(b[0] + b[1] + b[2] - b[3]==7):
    print(a[0]+"+"+a[1]+"+"+a[2],"-"+a[3]+"=7",end="")
elif(b[0] + b[1] - b[2] + b[3]==7):
    print(a[0]+"+"+a[1]+"-"+a[2],"+"+a[3]+"=7",end="")
elif(b[0] + b[1] - b[2] - b[3]==7):
    print(a[0]+"+"+a[1]+"-"+a[2],"-"+a[3]+"=7",end="")
elif(b[0] - b[1] + b[2] + b[3]==7):
    print(a[0]+"-"+a[1]+"+"+a[2],"+"+a[3]+"=7",end="")
elif(b[0] - b[1] + b[2] - b[3]==7):
    print(a[0]+"-"+a[1]+"+"+a[2],"-"+a[3]+"=7",end="")
elif(b[0] - b[1] - b[2] + b[3]==7):
    print(a[0]+"-"+a[1]+"-"+a[2],"+"+a[3]+"=7",end="")
elif(b[0] - b[1] - b[2] - b[3]==7):
    print(a[0]+"-"+a[1]+"-"+a[2],"-"+a[3]+"=7",end="")

Submission status: Wrong Answer

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

mark = ["+", "-"]

for m1 in mark:
  for m2 in mark:
    for m3 in mark:
      if eval("{0} {1} {2} {3} {4} {5} {6}".format(A,m1,B,m2,C,m3,D)) == 7:
        print("{0}{1}{2}{3}{4}{5}{6}=7".format(A,m1,B,m2,C,m3,D))
        break

Submission status: Wrong Answer

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

ans_list = [[0 for _ in range(8)] for __ in range(3)]

ans_list[0][0] = a + b
ans_list[0][1] = a - b
for i in range(2):
    ans_list[1][i * 2] = ans_list[0][i] + c
    ans_list[1][i * 2 + 1] = ans_list[0][i] - c
for i in range(4):
    ans_list[2][i * 2] = ans_list[1][i] + d
    ans_list[2][i * 2 + 1] = ans_list[1][i] - d

for n in range(8):
    if ans_list[2][n] == 7:
        ans = ""
        ans += abcd[0]
        if n > 4:
            ans += "-"
        else:
            ans += "+"
        ans += abcd[1]
        if n == 0 or n == 1 or n == 4 or n == 5:
            ans += "+"
        else:
            ans += "-"
        ans += abcd[2]
        if n % 2 == 0:
            ans += "+"
        else:
            ans += "-"
        ans += abcd[3]
        ans += "=7"
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
a = ['+', '-']
b = [lambda x,y: x+y, lambda x,y: x-y]

A, B, C, D = map(int, input())

end = False
for q, w in zip(a, b):
    for o, p in zip(a, b):
        if w(A, B) + p(C, D) == 7:
            print('{0}{1}{2}+{3}{4}{5}=7'.format(A,q,B,C,o,D))
            end = True
            break
        elif w(A, B) - p(C, D) == 7:
            print('{0}{1}{2}-{3}{4}{5}=7'.format(A,q,B,C,o,D))
            end = True
            break
    if end == True:
        break

Submission status: Wrong Answer

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

N = int(input())

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

tmp = [0 for i in range(8)]
tmp2 = ['{}+{}+{}+{}'.format(a, b, c, d), '{}+{}+{}-{}'.format(a, b, c, d),
        '{}+{}-{}+{}'.format(a, b, c, d), '{}+{}+{}-{}'.format(a, b, c, d),
        '{}-{}+{}+{}'.format(a, b, c, d), '{}-{}+{}-{}'.format(a, b, c, d),
        '{}-{}-{}+{}'.format(a, b, c, d), '{}-{}-{}-{}'.format(a, b, c, d)]

tmp[0] = a + b + c + d
tmp[1] = a + b + c - d
tmp[2] = a + b - c + d
tmp[3] = a + b - c - d
tmp[4] = a - b + c + d
tmp[5] = a - b + c - d
tmp[6] = a - b - c + d
tmp[7] = a - b - c - d

for i in range(8):
    if(tmp[i] == 7):
        x = i
        break

print(str(tmp2[i])+'=7')

Submission status: Wrong Answer

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

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:
e=input()
a=e[0]
b=e[1]
c=e[2]
d=e[3]
t=0
for x1 in ["+","-","*","/"]:
    for x2 in ["+","-","*","/"]:
        for x3 in ["+","-","*","/"]:
            y= a+x1+b+x2+c+x3+d
            if y.find("/0") >= 0:
                break
            elif eval(y)==7:
                t=1
            if t==1:
                break
        if t==1:
            break  
    if t==1:
        break
print(a+x1+b+x2+c+x3+d+"=7")

Submission status: Wrong Answer

Solution code:
import sys
N = input()
a, b, c, d = int(N[0]),int(N[1]), int(N[2]), int(N[3])
n = a + b + c + d
if n == 7:
    print("{}+{}+{}+{}=7".format(a, b, c, d))
    sys.exit()
n = a - b + c + d
if n == 7:
    print("{}-{}+{}+{}=7".format(a, b, c, d))
    sys.exit()
n = a + b - c + d
if n == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
    sys.exit()
n = a + b - c + d
if n == 7:
    print("{}+{}-{}+{}=7".format(a, b, c, d))
    sys.exit()
n = a + b + c - d
if n == 7:
    print("{}+{}+{}-{}=7".format(a, b, c, d))
    sys.exit()
n = a - b - c + d
if n == 7:
    print("{}-{}-{}+{}=7".format(a, b, c, d))
    sys.exit()
n = a + b - c - d
if n == 7:
    print("{}+{}-{}-{}=7".format(a, b, c, d))
    sys.exit()
n = a - b - c - d
if n == 7:
    print("{}-{}-{}-{}=7".format(a, b, c, d))
    sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

N = int(sys.stdin.readline().strip())

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

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:
#!/usr/bin/env python
import itertools
input_str = input()
print(input_str)
A = input_str[0]
B = input_str[1]
C = input_str[2]
D = input_str[3]

ops = ['+', '-']
all_ops = list(itertools.product(A, ops, B, ops, C, ops, D))
for tmp in all_ops:
    result = eval(''.join(tmp))
    if result == 7:
        print(''.join(tmp) + "=7")
        break

Submission status: Wrong Answer

Solution code:
import sys
A, B, C, D = map(int, input())
ops = ['+', '-']
for op1 in ops:
    tmp = A
    for op2 in ops:
        for op3 in ops:
            if op1 == '+':
                tmp += B
            else:
                tmp -= B
            if op2 == '+':
                tmp += C
            else:
                tmp -= C
            if op3 == '+':
                tmp += D
            else:
                tmp -= D
            if tmp == 7:
                print("{}{}{}{}{}{}{}=7".format(A,op1,B,op2,C,op3,D))
                sys.exit()

Submission status: Wrong Answer

Solution code:
# cook your dish here
# from math import * 
#for _ in range(int(input().strip())):

order=['+++','++-','+-+','+--','-++','-+-','--+','---']

s=input()
flag=-1
for i in range(8):
    ans=int(s[0])
    for j in range(1,len(s)):
        if order[i][j-1]=='+':
            ans+=(int(s[j]))
        else:
            ans-=(int(s[j]))
    if ans==7:
        flag=i
#print(flag)
if flag>-1:
    for i in range(3):
        print(s[i],order[flag][i],sep="",end="")
    print(s[3])

Submission status: Wrong Answer

Solution code:
plus = lambda x, y: x + y
minus = lambda x, y: x - y
en = [plus, minus]
en2 = ['+', '-']

law = input()
A, B, C, D = map(int, law)

for first, first2 in zip(en, en2):
    for last, last2 in zip(en, en2):
        front = first(A, B)
        back = last(C, D)
        if front + back == 7:
            print('{0}{1}{2}+{3}{4}{5}=7'.format(A, first2, B, C, last2, D))
            exit()
        elif front - back == 7:
            print('{0}{1}{2}-{3}{4}{5}=7'.format(A, first2, B, C, last2, D))
            exit()

Submission status: Wrong Answer

Solution code:
from sys import stdin
import itertools
a = stdin.readline().strip()
n = int(a)
b = list(a)
c = itertools.permutations(b)
ans = ''
j = ['+++','++-','+-+','+--','-++','-+-','--+','---']
for ii in c:
    i = list(ii)
    #print i
    ans = ''
    for x in j:
     #   print x
        f = i[0] + x[0] + i[1] + x[1] + i[2] + x[2] + i[3]
        if eval(f)==7:
            ans = f
            break
    if len(ans):
        break
print ans

Submission status: Wrong Answer

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


for i in range(8):
    op1=1 if i%2 ==0 else -1
    op2=1 if (i//2)%2==0 else -1
    op3=1 if (i//4)%2==0 else -1
    if A + op1*B + op2*C + op3*D == 7:
        print(str(A)+ ("+" if op1==1 else "-")
              +str(B)+ ("+" if op2==1 else "-")
               + str(B) +( "+" if op3==1 else "-")
              +str(D)+"=7"
                )
        exit()