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

list_num=[]

Ans=['+'+i for i in s]
Ans[0]=s[0]
Ans.append('=7')

for i in s:
    list_num.append(int(i))
    
list_sum=sum(list_num)

if list_sum==7:
    print(''.join(Ans))
    
    for i in range(3):
        if list_sum-list_num[i+1]==7:
            Ans[i+1]='-'+s[i+1]
            print(''.join(Ans))
        
        else:
            Ans=['-'+i for i in s]
            Ans[0]=s[0]
            Ans.append('=7')
            list_num=[-i for i in list_num]
            list_num[0]=-(list_num[0])
            list_sum=sum(list_num)
            for j in range(3):
                if list_sum-list_num[j+1]==7:
                    Ans[j+1]='+'+s[i+1]
                    print(''.join(Ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

gap = (sum_abcd-7)//2
ans = [a,'+',b,'+',c,'+',d]
if gap==0:
    print(''.join(map(str,ans))+'=7')
elif gap==(b+c+d):
    for i in range(1,len(ans),2):
        ans[i]='-'
    print(''.join(map(str,ans))+'=7')
elif gap in [b,c,d]:
    for i in range(2,len(ans),2):
        if ans[i]==gap:
            ans[i-1]='-'
            break
    print(''.join(map(str,ans))+'=7')
else:
    for i in range(2,len(ans)-1,2):
        for j in range(i+2,len(ans),2):
            if ans[i]+ans[j]==gap:
                ans[i-1]='-'
                ans[j-1]='-'
                break
    print(''.join(map(str,ans))+'=7')

Submission status: Wrong Answer

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

gap = (sum_abcd-7)/2
ans = [a,'+',b,'+',c,'+',d]
if gap==0:
    print(''.join(map(str,ans))+'=7')
elif gap==(b+c+d):
    for i in range(1,len(ans),2):
        ans[i]='-'
    print(''.join(map(str,ans))+'=7')
elif gap in [b,c,d]:
    for i in range(2,len(ans),2):
        if ans[i]==gap:
            ans[i-1]='-'
            break
    print(''.join(map(str,ans))+'=7')
else:
    for i in range(2,len(ans)-1,2):
        for j in range(i+2,len(ans),2):
            if ans[i]+ans[j]==gap:
                ans[i-1]='-'
                ans[j-1]='-'
                break
    print(''.join(map(str,ans))+'=7')

Submission status: Wrong Answer

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

gap = (sum_abcd-7)/2
ans = [a,'+',b,'+',c,'+',d]
if gap==0:
    print(''.join(map(str,ans)))
elif gap==(b+c+d):
    for i in range(1,len(ans),2):
        ans[i]='-'
    print(''.join(map(str,ans)))
elif gap in [b,c,d]:
    for i in range(2,len(ans),2):
        if ans[i]==gap:
            ans[i-1]='-'
            break
    print(''.join(map(str,ans)))
else:
    for i in range(2,len(ans)-1,2):
        for j in range(i+2,len(ans),2):
            if ans[i]+ans[j]==gap:
                ans[i-1]='-'
                ans[j-1]='-'
                break
    print(''.join(map(str,ans)))

Submission status: Wrong Answer

Solution code:
a,b,c,d = input()
for i in range(2**3):
    ls = ["+","+","+"]
    for j in range(len(ls)):
        if (i >> j) & 1:
            ls[j] = "-"
    print(ls)
    if eval(a+ls[0]+b+ls[1]+c+ls[2]+d) == 7:
        print(a+ls[0]+b+ls[1]+c+ls[2]+d+"=7")
        break

Submission status: Wrong Answer

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

print(n)


def addd(lista,op):
    cnt = lista[0]


    tmp = [lista[0]]
    for i in range(len(op)):
        if op[i]==0:
            cnt+=lista[i+1]
            tmp.append("+")
            tmp.append(lista[i+1])
        else:
            cnt -=lista[i+1]
            tmp.append("-")
            tmp.append(lista[i+1])
    if cnt ==7:
        tmp.append("=7")
        return tmp
    else:
        return False

for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = addd(n,[i,j,k])
            if ans != False:
                print("".join([str(n) for n in ans]))
                exit()

Submission status: Wrong Answer

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

ans_map = {}
for i in range(3):
    if i == 0:
        ans_map['-'] = nums[0] - nums[1]
        ans_map['+'] = nums[0] + nums[2]
        continue

    for operators in dict.fromkeys(ans_map):
        tmp_val = ans_map[operators]
        if i == 2:
            if tmp_val + nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '+',
                    nums[3]
                ))
                break

            if tmp_val - nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}=7'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '-',
                    nums[3]
                ))
                break

        ans_map[operators + '-'] = tmp_val - nums[i + 1]
        ans_map[operators + '+'] = tmp_val + nums[i + 1]
        del ans_map[operators]

Submission status: Wrong Answer

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

ans_map = {}
for i in range(3):
    if i == 0:
        ans_map['-'] = nums[0] - nums[1]
        ans_map['+'] = nums[0] + nums[2]
        continue

    for operators in dict.fromkeys(ans_map):
        tmp_val = ans_map[operators]
        if i == 2:
            if tmp_val + nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '+',
                    nums[3]
                ))
                break

            if tmp_val - nums[i + 1] == 7:
                print('{}{}{}{}{}{}{}'.format(
                    nums[0],
                    operators[0],
                    nums[1],
                    operators[1],
                    nums[2],
                    '-',
                    nums[3]
                ))
                break

        ans_map[operators + '-'] = tmp_val - nums[i + 1]
        ans_map[operators + '+'] = tmp_val + nums[i + 1]
        del ans_map[operators]

Submission status: Wrong Answer

Solution code:
def nyu():
    N = list(map(str,input()))
    return N

def check(LOP1,LOP2,LOP3):  
    global flg1
    ls =  N[0]+LOP1+N[1]+LOP2+N[2]+LOP3+N[3]
    if flg1 == True:
        return
    elif(eval(ls) == 7):
        print(N[0],LOP1,N[1],LOP2,N[2],LOP3,N[3],"=7",sep='')
        flg1 = True
        return
    elif(LOP1 == '-' and  LOP2 == '-' and LOP3 == '-'):  
        flg1 = True
        print(-1)
        return 


    if LOP1 =='+':
        check('-',LOP2,LOP3)
    if LOP2 == '+':
        check(LOP1,'-',LOP3)
    if LOP3 == '+':
        check(LOP1,LOP2,'-')



N = nyu()
flg1 = False
OP1 = "+"
OP2 = "+"
OP3 = "+"
check(OP1,OP2,OP3)

Submission status: Wrong Answer

Solution code:
def ope(i, ans, ans_str):
    if i == 3:
        if ans == 7:
            print(ans_str+"=7")
    else:
        ope(i+1, ans+int(S[i+1]), ans_str + "+" + S[i+1])
        ope(i+1, ans-int(S[i+1]), ans_str + "-" + S[i+1])
S = list(input())
ope(0,int(S[0]),S[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

s = input()

def dfs(i, n, ns):
    if i == 3:
        if n == 7:
            print(ns + '=7')
            return
        else:
            return

    dfs(i+1, n + int(s[i+1]), ns + '+' + s[i+1])
    dfs(i+1, n - int(s[i+1]), ns + '-' + s[i+1]) 


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

Submission status: Wrong Answer

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

res = ""

if a + b + c + d == 7:
    res = "a+b+c+d=7"
elif a + b + c - d == 7:
    res = "a+b+c-d=7"
elif a + b - c + d == 7:
    res = "a+b-c+d=7"
elif a + b - c - d == 7:
    res = "a+b-c-d=7"
elif a +- b + c + d == 7:
    res = "a-b+c+d=7"
elif a - b + c - d == 7:
    res = "a-b+c-d=7"
elif a - b - c + d == 7:
    res = "a-b-c+d=7"
elif a - b - c - d == 7:
    res = "a-b-c-d=7"

print(res)

Submission status: Wrong Answer

Solution code:
class TrainTicket():
    def calculate(self, S: list):
        for x in range(2):
            for y in range(2):
                for z in range (2):
                    if x == 1:
                        res = S[0] + S[1]
                    else:
                        res = S[0] - S[1]
                    if y ==1:
                        res += S[2]
                    else:
                        res -= S[2]
                    if z == 1:
                        res += S[3]
                    else:
                        res -= S[3]
                    if res == 7:
                        if x == 1:
                            xr = "+"
                        else:
                            xr = "-"
                        if y == 1:
                            yr = "+"
                        else:
                            yr= "-"
                        if z == 1:
                            zr = "+"
                        else:
                            zr = "-"
                        return(str(S[0]) + xr + str(S[1]) + yr + str(S[2]) + zr + str(S[3]))


if __name__ =="__main__":
    S = list(map(int, input()))
    print(S)
    tt = TrainTicket()
    res = tt.calculate(S)
    print(str(res)+"=7")

Submission status: Wrong Answer

Solution code:
import sys
import itertools
ABCDlist=list(map(int,list(input())))
#print(ABCDlist)

for bit in itertools.product(range(2),repeat=3):
  answer=ABCDlist[0]
  answer_list=[str(answer)]
  for i in range(3):
    if bit[i]==0:
      answer+=ABCDlist[i+1]
      answer_list.append("+"+str(ABCDlist[i+1]))
    else:
      answer-=ABCDlist[i-1]
      answer_list.append("-"+str(ABCDlist[i+1]))
      
  if answer==7:
    answer_list.append("=7")
    print("".join(answer_list))
    sys.exit(0)

Submission status: Wrong Answer

Solution code:
N=input()
a,b,c,d=int(N[0]),int(N[1]),int(N[2]),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:
ABCD=input()
answer=[ABCD[0],"-",ABCD[1],"-",ABCD[2],"-",ABCD[3]]
for i in range(8):
    pat=str(bin(i))[2:].rjust(3,"0")
    sum=int(ABCD[0])
    for j in range(3):
        if pat[j]=="0":
            sum-=int(ABCD[j+1])
            answer[2*j+1]="-"
        else:
            sum+=int(ABCD[j+1])
            answer[2*j+1]="+"
    if sum==7:
        print("".join(map(str,answer)))
        break

Submission status: Wrong Answer

Solution code:
def resolve():
    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(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:
        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')
    else:
        print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    s=input()
    for i in ['+','-']:
        for m in ['+','-']:
            for n in ['+','-']:
                if eval(s[0]+i+s[1]+m+s[2]+n+s[3])==7:
                    print(s[0]+i+s[1]+m+s[2]+n+s[3]+'=7')
                    break
            break
        break
resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    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(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:
        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')
    else:
        print(print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7'))
resolve()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
abcd = input()
n = len(abcd)-1
for i in range(3**n):
    t = abcd[0]
    for j in range(n):
        if (i >> j & 1):
            t += '+'
        else:
            t += '-'
        t += abcd[j+1]
    if eval(t) == 7:
        print(t)
        sys.exit()

Submission status: Wrong Answer

Solution code:
import numpy as np

S = input()
X = list(int(x) for x in S)
Y = [1] * 3
for i in range(8):
    for j in range(3):
        if i & (1 << j):
            Y[j] = -1
    if X[0] + np.dot(X[1:], Y) == 7:
        break
ans = [None] * (2 * len(S) - 1)
ans[::2] = X
ans[1::2] = ['+' if y == 1 else '-' for y in Y]
print(*ans, sep='', end='=7\n')

Submission status: Wrong Answer

Solution code:
def dfs(i,Str,res):
    if i==num-1:
        if res==7:
            print(Str+"=7")
            exit()
        return
    dfs(i+1,Str+"+"+S[i+1],res+int(Str))    

n=input()
num=len(n)

Submission status: Wrong Answer

Solution code:
def dfs(i, f):
  if i == n - 1:
    total = sum(list(map(int, f.split('+'))))
    if total == 7:
      print((f + '=7').replace('+-', '-'))
    return total
  return dfs(i + 1, f + '+' + s[i + 1]) + dfs(i + 1, f + '+-' + s[i + 1])

s = input()
n = len(s)
dfs(0, s[0])

Submission status: Wrong Answer

Solution code:
abcd = [int(i) for i in input()]
for i in range(2):
    for j in range(2):
        for k in range(2):
            ans = abcd[0]
            res = "" + str(abcd[0])
            if i:
                ans += abcd[1]
                res += "+" + str(abcd[1])
            else:
                ans -= abcd[1]
                res += "-" + str(abcd[1])
            if j:
                ans +=  abcd[2]
                res += "+" + str(abcd[2])
            else:
                ans -=  abcd[2]
                res += "-" + str(abcd[2])
            if k:
                ans +=  abcd[3]
                res += "+" + str(abcd[3])
            else:
                ans -=  abcd[3]
                res += "-" + str(abcd[3])
            if ans == 7:
                print(res+"=7" )
                break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 19:47:38 2020

@author: Kanaru Sato
"""

_ = str(input())
nums = []
for i in range(len(_)):
    nums.append(int(_[i]))

for ops in range(1<<3):
    count = nums[0]
    formula = [str(nums[0])]
    
    for shift in range(3):
        if ops & (1<<shift):
            count += nums[3-shift]
            formula += ["+",str(nums[3-shift])]
        else:
            count -= nums[3-shift]
            formula += ["-",str(nums[3-shift])]

    if count == 7:
        formula.append("=")
        print("".join(formula)+"7")
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 25 19:47:38 2020

@author: Kanaru Sato
"""

_ = str(input())
nums = []
for i in range(len(_)):
    nums.append(int(_[i]))

for ops in range(1<<3):
    count = nums[0]
    formula = [str(nums[0])]
    
    for shift in range(3):
        if ops & (1<<shift):
            count += nums[3-shift]
            formula += ["+",str(nums[3-shift])]
        else:
            count -= nums[3-shift]
            formula += ["-",str(nums[3-shift])]

    if count == 7:
        formula.append("=")
        print("".join(formula)+"7")

Submission status: Wrong Answer

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

plusminus=["+","-"]

def plusminus(number,i,j,k):
    a=number[0]
    b=number[1]
    c=number[2]
    d=number[3]
    if i==0:
        if j==0:
            if k==0:
                if a+b+c+d==7:
                    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a+b+c-d==7:
                    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
        else:
            if k==0:
                if a+b-c+d==7:
                    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a+b-c-d==7:
                    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
    else:
        if j==0:
            if k==0:
                if a-b+c+d==7:
                    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a-b+c-d==7:
                    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
        else:
            if k==0:
                if a-b-c+d==7:
                    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a-b-c-d==7:
                    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
    
    
    
    
    
    
    


for i in range(2):
    for j in range(2):
        for k in range(2):
            if plusminus(number,i,j,k):
                break
        break
            
    break

Submission status: Wrong Answer

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

plusminus=["+","-"]

def plusminus(number,i,j,k):
    a=number[0]
    b=number[1]
    c=number[2]
    d=number[3]
    if i==0:
        if j==0:
            if k==0:
                if a+b+c+d==7:
                    print(str(a)+"+"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a+b+c-d==7:
                    print(str(a)+"+"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
        else:
            if k==0:
                if a+b-c+d==7:
                    print(str(a)+"+"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a+b-c-d==7:
                    print(str(a)+"+"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
    else:
        if j==0:
            if k==0:
                if a-b+c+d==7:
                    print(str(a)+"-"+str(b)+"+"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a-b+c-d==7:
                    print(str(a)+"-"+str(b)+"+"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
        else:
            if k==0:
                if a-b-c+d==7:
                    print(str(a)+"-"+str(b)+"-"+str(c)+"+"+str(d)+"=7")
                    return True
                else:
                    return False
            else:
                if a-b-c-d==7:
                    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")
                    return True
                else:
                    return False
    
    
    
    
    
    
    


for i in range(2):
    for j in range(2):
        for k in range(2):
            if plusminus(number,i,j,k):
                break
            break
            
        break

Submission status: Wrong Answer

Solution code:
X = list(input())

for i in range(2**3):
    W = ["+"]*3
    for j in range(3):
        if (i >> j) & 1:
            W[j] = "-"
    formula = ""
    for k,l in zip(X,W+[""]):
        formula += k+l
    if eval(formula) == 7:
        print(formula)
        break

Submission status: Wrong Answer

Solution code:

n = str(input())

a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
l = [b,c,d]
s = a+b+c+d
ans = 1

if s == 7:
  h_1,h_2,h_3 = "+","+","+"
elif s-b*2 == 7:
  h_1,h_2,h_3 = "-","+","+"
elif s-c*2 == 7:
  h_1,h_2,h_3 = "+","-","+"
elif s-d*2 == 7:
  h_1,h_2,h_3 = "+","+","-"
elif s-b*2-c*2 == 7:
  h_1,h_2,h_3 = "-","-","+"
elif s-b*2-d*2 == 7:
  h_1,h_2,h_3 = "-","+","-"
elif s-c*2-d*2 == 7:
  h_1,h_2,h_3 = "+","-","-"
elif s-b*2-c*2-d*2 == 7:
  h_1,h_2,h_3 = "-","-","-"
else:
  ans = 0

if ans == 0:
  print("")
else:
  ans = "{0}{1}{2}{3}{4}{5}{6}{7}{8}".format(a,h_1,b,h_2,c,h_3,d,"=",s)
  print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())

ops = []
for i in range(2 ** (len(S) -1)):
    op = ["-"] * 3
    for j in range(len(S) - 1):
        if i >> j & 1:
            op[j] = "+"
    ops.append(op)

def fomula(S, op):
    s = list(S)
    count = 1
    for i in range(len(s) - 1):
        s.insert(i+count, op[i])
        count += 1
    fomula = ""
    for k in range(len(s)):
        fomula += s[k]

    return fomula


for i in range(2 ** (len(S) -1)):
    fomul = fomula(S, ops[i])
    if eval(fomul) == 7:
        print(fomul)
        exit()

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
A=[int(i) for i in S]
D=["+" for i in range(N-1)]
output=S[0]
for i in range(2**N):
  C=A
  B=D
  for j in range(N-1):
    if ((i>>j)&1):
      C[j+1]= -1*int(str(S[j+1]))
      B[j]=  "-"
    else:
      C[j+1]= int(str(S[j+1]))
      B[j]=  "+"
  print(C,B,sum(C))
  if sum(C) ==7:
    for i in range(1,N):
      output += B[i-1] + str(S[i])
    print(output+"=7")
    break

Submission status: Wrong Answer

Solution code:
import itertools

def solve(S):
    bit_list = list(itertools.product([0, 1], repeat=3))
    
    for pattern in bit_list:
        count = int(S[0])
        ans = S[0]
        for i in range(3):
            if pattern[i] == 0:
                count += int(S[i+1])
                ans += "+" + S[i+1]
            else:
                count -= int(S[i+1])
                ans += "-" + S[i+1]
        
        if count == 7:
            print(ans)
            break
    

if __name__ == '__main__':
    S = input()
    solve(S)

Submission status: Wrong Answer

Solution code:
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    # bit全探索
    # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
    L = input()
    L = [int(c) for c in L]



    n = len(L)-1
    # 昇順での探索だよ
    for i in range(2 ** n):
        ans=L[0]
        cnt=0
        s=''

        """        
        10進数表記　2進数表記
        0           000
        1           001
        2           010
        3           011
        4           100
        5           101
        6           110
        7           111
        """

        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                cnt+=L[-j-1]
                s='+'+str(L[-j-1])+s
            else:
                cnt-=L[-j-1]
                s='-'+str(L[-j-1])+s

        if cnt==7:
            print(str(L[0])+s+'=7')
            break



resolve()

Submission status: Wrong Answer

Solution code:
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():

    # bit全探索
    # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
    L = input()
    L = [int(c) for c in L]



    n = len(L)
    # 昇順での探索だよ
    for i in range(2 ** n):
        ans=L[0]
        cnt=0
        s=''

        """        
        10進数表記　2進数表記
        0           000
        1           001
        2           010
        3           011
        4           100
        5           101
        6           110
        7           111
        """

        for j in range(n):  # このループが一番のポイント
            if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
                cnt+=L[-j-1]
                s='+'+str(L[-j-1])+s
            else:
                cnt-=L[-j-1]
                s='-'+str(L[-j-1])+s

        if cnt==7:
            print(s[1:]+'=7')
            break



resolve()

Submission status: Wrong Answer

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

for i in range(2 ** 3):
    op = ['+', '+', '+']
    ans = a
    for j in range(3):
        if ((i >> j) & 1):
            op[j] = '-'
            ans -= int(abcd[j + 1])
        else:
            ans += int(abcd[j + 1])
    if ans == 7:
        print(str(a) + str(op[0]) + str(b) + str(op[1]) + str(c) + str(op[2]) + str(d) + '=7')

Submission status: Wrong Answer

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

for i in range(2 ** 3):
    op = [1, 1, 1]
    for j in range(3):
        if ((i >> j) & 1):
            op[j] = -1
    if (a + b * op[0] + c * op[1] + d * op[2]) == 7:
        print(str(a) + str(b * op[0]) + str(c * op[1]) + str(d * op[2]) + '=7')

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_c
import random
import sys

str = input()
print(str)


def retop():
    if(random.uniform(0, 1) > 0.5):
        return "+"
    return "-"


for i in range(100):
    formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
    if eval(formula) == 7:
        print(formula + "=7")
        sys.exit()

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc079/tasks/abc079_c
import random
import sys

str = input()
print(str)


def retop():
    if(random.uniform(0, 1) > 0.5):
        return "+"
    return "-"


for i in range(100):
    formula = (str[0] + retop() + str[1] + retop() + str[2] + retop() + str[3])
    if eval(formula) == 7:
        print(formula)
        sys.exit()

Submission status: Wrong Answer

Solution code:
s = input()
#import sys
#s = '1222'
n = len(s)
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').ljust(n,'0')
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  #print(f)
  if eval(f) == 7:
    print(f+'=7')
    break

Submission status: Wrong Answer

Solution code:
s = input()
#import sys
#s = '1222'
n = len(s)
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').zfill(n)
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  if eval(f) == 7:
    print(f+'=7')
    break

Submission status: Wrong Answer

Solution code:
s = input()
#import sys
#s = '1222'
n = len(s)
is7 = False
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').zfill(n)
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  if eval(f) == 7:
    print(f+'=7')
    break

Submission status: Wrong Answer

Solution code:
s = input()
#import sys
#s = '1222'
n = len(s)
is7 = False
for i in range(2**(n-1)):
  #print(i)
  f = ''
  b = format(i, 'b').zfill(n)
  #print(b)
  for j in range(n):
    f += s[j]
    if b[j] == '0':
      f += '-'
    else:
      f += '+'
  f = f[:len(f)-1]
  if eval(f) == 7:
    print(f)
    break

Submission status: Wrong Answer

Solution code:
s = input()

def dfs(i,sen,num):
    if i == 3:
        if num == 7:
            print(sen+"=7")
            exit()
    else:
        dfs(i+1,sen+"+"+s[i+1],num+int(s[i+1]))
        dfs(i+1,sen+"-"+s[i+1],num-int(s[i-1]))

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

Submission status: Wrong Answer

Solution code:
s = input()

def dfs(i,sen,num):
    if i == 3:
        if num == 7:
            print(sen+"=7")
            quit()
    else:
        dfs(i+1,sen+"+"+s[i+1],num+int(s[i+1]))
        dfs(i+1,sen+"-"+s[i+1],num-int(s[i-1]))

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

Submission status: Wrong Answer

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

for i in range(2**(n-1)):
    x = [s[0]]
    for j in range(n-1):
        if (i>>j)&1:
            y ='+'
        else:
            y = '-'
        x.append(y)
        y = 0
        x.append(s[j+1])
    z = ''.join(x)
    if eval(z) == 7:
        print(z + '=7')

Submission status: Wrong Answer

Solution code:
A = input()
A = list(A[0]+"F"+A[1]+"G"+A[2]+"H"+A[3])
B=["+", "-"]

for i in range(2):
    for j in range(2):
        for k in range(2):
            A[1] = B[i]
            A[3] = B[j]
            A[5] = B[k]
            C = "".join(A)
            if 7 == eval(C):
                print(C+"=7")
                break

Submission status: Wrong Answer

Solution code:
def resolve():
    s = input()
    for bit in range(2 ** 3):
        _str = "".join(
            s[i] if i == 3 else s[i] + "+" if 1 << i & bit else s[i] + "-"
            for i in range(4)
        )
        if eval(_str) == 7:
            print(_str + "=7")


if __name__ == "__main__":
    resolve()