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

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

for i in range(2**3):
    cnt = int(s[0])
    ls = []
    for j in range(3):    
        if ((i>>j)&1):
            ls.append("+")
            cnt += int(s[j+1])
        else:
            ls.append("-")
            cnt -= int(s[j+1])
    if cnt==7:
        eq = [s[0],ls[0],s[1],ls[1],s[2],ls[2],s[3]]
        print("".join(eq))
        break

Submission status: Wrong Answer

Solution code:
l = input().split()
ABCD = l[0]

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

#print(A, B, C, D)

def op(code, x, y):
    if code == 0:
        return x + y
    return x - y

def to_op(code):
    if code == 0:
        return '+'
    return '-'

for i in range(8):
    code1 = i % 2
    ans = op(code1, A, B)
    code2 = (i // 2) % 2
    ans = op(code2, ans, C)
    code3 = (i // 4) % 2
    ans = op(code3, ans, D)
    if ans == 7:
        print('{}{}{}{}{}{}{}=7'.format(
            A, to_op(code1),
            B, to_op(code2),
            C, to_op(code2),
            D
        ))
        break

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            B *= (-1) ** i
            C *= (-1) ** j
            D *= (-1) ** k
            if(A + B + C + D == 7):
                shiki = ''
                shiki += str(A)
                if(B<0):
                    shiki += str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += str(D)
                else:
                    shiki += '+' + str(D)
                shiki += '=7'
                print(shiki)
                exit()

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            B = B * (-1) ** i
            C = C * (-1) ** j
            D = D * (-1) ** k
            if(A + B + C + D == 7):
                shiki = ''
                shiki += str(A)
                if(B<0):
                    shiki += str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += str(D)
                else:
                    shiki += '+' + str(D)
                shiki += '=7'
                print(shiki)
                exit()

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            B = B * (-1) ** i
            C = C * (-1) ** j
            D = D * (-1) ** k
            if(A + B + C + D == 7):
                shiki = ''
                shiki += str(A)
                if(B<0):
                    shiki += str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += str(D)
                else:
                    shiki += '+' + str(D)
                shiki += '=7'
                print(shiki,end='')
                exit()

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

shiki = ''

for i in range(2):
    for j in range(2):
        for k in range(2):
            B = B * (-1) ** i
            C = C * (-1) ** j
            D = D * (-1) ** k
            if(A + B + C + D == 7):
                shiki += str(A)

                if(B<0):
                    shiki += '-' + str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += '-' + str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += '-' + str(D)
                else:
                    shiki += '+' + str(D)
                shiki += '=7'
                print(shiki,end='')
                break
        break
    break

Submission status: Wrong Answer

Solution code:
#coding: utf-8

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

shiki = ''

for i in range(2):
    for j in range(2):
        for k in range(2):
            B = B * (-1) ** i
            C = C * (-1) ** j
            D = D * (-1) ** k
            if(A + B + C + D == 7):
                shiki += str(A)

                if(B<0):
                    shiki += '-' + str(B)
                else:
                    shiki += '+' + str(B)

                if(C<0):
                    shiki += '-' + str(C)
                else:
                    shiki += '+' + str(C)

                if(D<0):
                    shiki += '-' + str(D)
                else:
                    shiki += '+' + str(D)
                print(shiki,end='')
                break
        break
    break

Submission status: Wrong Answer

Solution code:
#input
S = list(input())
for i in range(len(S)):
    S[i] = int(S[i])
#print(S)
L = len(S)
fugou = []

#bit zentansaku
for i in range(2**(L-1)):
    total = S[0]
    #bin_i = bin(i)
    moji = format(i,'b').zfill(4)
    #print(moji)
    for k in range(1,L):
        #print(moji[k])
        if int(moji[k]) == 1:
            total = total + S[k]
        else:
            total = total - S[k]
        #print(total)
    if total == 7:
        moji_answer = moji
print(moji_answer)
#print
for i in range(1,L):
    if int(moji_answer[i]) == 1:
        fugou_tandoku = "+"
    else:
        fugou_tandoku = "-"
    fugou.append(fugou_tandoku)
print(S[0],fugou[0],S[1],fugou[1],S[2],fugou[2],S[3],'=7',sep='')

Submission status: Wrong Answer

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


def exec(x, y, op):
    if op == '+':
        return x + y
    else:
        return x - y

for op1 in ['+', '-']:
    for op2 in ['+', '-']:
        for op3 in ['+', '-']:
            if exec(exec(exec(A, B, op1), C, op2), D, op3) == 7:
                print('{A}{op1}{B}{op2}{C}{op3}{D}=7'.format(
                    A=A,
                    B=B,
                    C=C,
                    D=D,
                    op1=op1,
                    op2=op2,
                    op3=op3
                ))
                break

Submission status: Wrong Answer

Solution code:
s = list(input())

op_cnt = len(s)-1
sum = 0
for i in range(2**op_cnt):
    op = ['+']*op_cnt
    for j in range(op_cnt):
        if (i>>j) & 1:
            op[j] = '+' 

    fomula = s[0]
    for j in range(op_cnt):
        fomula += op[j]
        fomula += s[j+1]
    
    if eval(fomula) == 7:
        print('{}=7'.format(fomula))
        break

Submission status: Wrong Answer

Solution code:
tmp = input()
a = int(tmp[0])
b = int(tmp[1])
c = int(tmp[2])
d = int(tmp[3])
tmpans = 0
for s1 in ["+", "-"]:
    tmpans = a
    for s2 in ["+", "-"]:
        for s3 in ["+", "-"]:
            if s1 == "+":tmpans += b
            else:tmpans -= b
            if s2 == "+":tmpans += c
            else:tmpans -= c
            if s3 == "+":tmpans += d
            else:tmpans -= d
            if tmpans == 7:
                print(str(a)+s1+str(b)+s2+str(c)+s3+str(d)+"=7")
                exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import types
#import copy

# Input
abcd = int(input())
n = len(str(abcd)) - 1 # 閾の数

# Print
for i in range( 2**n ):
    op = n * ["-"]

    # Create operation list
    # example: ['+', '-', '+']
    for j in range(n):
        if ( i >> j ) & 1:
            op[n-1 -j] = "+"
            
    formula = ""
    for p_n, p_o in zip(str(abcd), op+[""]):
        formula += (p_n + p_o)

    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Wrong Answer

Solution code:
S0=input()

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

Submission status: Wrong Answer

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

op_choice = ["+", "-"]

for op1 in op_choice:
    for op2 in op_choice:
        for op3 in op_choice:
            check = a + op1 + b + op2 + c + op3 + d
            if eval(check) == 7:
                print(check + "=7")

Submission status: Wrong Answer

Solution code:
num = input()
a = int(num[0])
b = int(num[1])
c = int(num[2])
d = int(num[3])
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 == 7:
  print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
  print('{}-{}-{}+{}=7'.format(a, b, c, d))
else:
  print('{}-{}-{}-{}=7'.format(a, b, c, d))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
numbers=list(map(int,list(input())))
ansLst=[]
def count(i,opes,sum):
    if i == 4:
        if sum == 7:
            ansLst.append(str(numbers[0])+opes[0]+str(numbers[1])+opes[1]+str(numbers[2])+opes[3]+str(numbers[3])+"=7")
    else:
        count(i+1,opes+["+"],numbers[i]+sum)
        count(i+1,opes+["-"],sum-numbers[i])
count(0,[],0)
print(ansLst[0])

Submission status: Wrong Answer

Solution code:
numbers=list(map(int,list(input())))
def count(i,opes,sum):
    if i == 4:
        if sum == 7:
            print(str(numbers[0])+opes[0]+str(numbers[1])+opes[1]+str(numbers[2])+opes[3]+str(numbers[3])+"=7")
            exit(0)
        return False
    else:
        result = count(i+1,opes+["+"],numbers[i]+sum)
        if not result:
            return count(i+1,opes+["-"],sum-numbers[i])
        return False
count(0,[],0)

Submission status: Wrong Answer

Solution code:
s = input()

for i in {"+","-"}:
    for j in {"+","-"}:
        for k in {"+","-"}:
            eq = s[0]+i+s[1]+j+s[2]+k+s[3]
            if eval(eq) == 7:
                break

print(eq + "=7")

Submission status: Wrong Answer

Solution code:
s = input()

a = int(s[:1])
b = int(s[1:2])
c = int(s[2:3])
d = int(s[3:4])

ans = 0
op1 = {"0":"+","1":"-"}
op2 = {"0":"+","1":"-"}
op3 = {"0":"+","1":"-"}

for i in range(2):
    if i == 0:
        ans = c + d
    else:
        ans = c - d

    for j in range(2):
        if j == 0:
            ans += b
        else:
            ans -= b

        for k in range(2):
            if k == 0:
                ans += a
                if ans == 7:
                    print(str(a)+op1[str(i)]+str(b)+op2[str(j)]+str(c)+op3[str(k)]+str(d)+"=7")
                    break
            else:
                ans -= a
                if ans == 7:
                    print(str(a)+op1[str(i)]+str(b)+op2[str(j)]+str(c)+op3[str(k)]+str(d)+"=7")
                    break

Submission status: Wrong Answer

Solution code:
import numpy as np

s = [w for w in input()]
length = len(s)

for i in range(2 ** (length-1)):
    b = format(i, 'b')
    b_len = len(b)
    pad_width = (length - b_len, 0)
    b_pad = np.pad([n for n in b], pad_width, 'constant', constant_values=0)
    score = int(s[0])
    result = s[0]
    for flag, num in zip(b_pad, s[1:]):
        if flag == '1':
            score += int(num)
            result += '+' + num
        else:
            score -= int(num)
            result += '-' + num

    if score == 7:
        print(result+'=7')
        break

Submission status: Wrong Answer

Solution code:
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    for i in range(2 ** l):
        binary = bi(i, l)
        tot = int(inp[0])
        for j in range(l):
            if binary[j] == "1":
                tot += int(inp[j+1])
            else:
                tot -= int(inp[j+1])
        print(tot)
        if tot == 7:
            return ''.join([inp[j] + "+" if binary[j] == "1" else inp[j] + "-" for j in range(l)] + [inp[-1] + "=7"])

inp = input()

print(solve(str(inp)))

Submission status: Wrong Answer

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

for i in range(2**3):
  ans = tick[0]
  op = []
  for j in range(3):
    if (i >> j) & 1:
      op.append("+")
      ans += tick[j+1]
    else:
      op.append("-")
      ans -= tick[j+1]
  if ans == 7:
    print(tick[0], op[0], tick[1], op[1], tick[2], op[2], tick[3], "=7", sep="")

Submission status: Wrong Answer

Solution code:
from itertools import combinations_with_replacement
x=[a for a in input()]
a=('+','-')
s=list(combinations_with_replacement(a,3))
for op in s:
     ops=x[0]+op[0]+x[1]+op[1]+x[2]+op[2]+x[3]
     if eval(ops)==7:
          print(ops+'=7')
          break

Submission status: Wrong Answer

Solution code:
from itertools import product

A, B, C, D = [x for x in input().strip()]

for x in ["".join(x) for x in product(A, '+-', B, '+-', C, '+-', D)]:
    if eval(x) == 7:
        print(x+"=7")

Submission status: Wrong Answer

Solution code:
import itertools
S = input()
A,B,C,D = S[0],S[1],S[2],S[3]
op = ['+','-']

for o1,o2,o3 in itertools.product(op,repeat=3):
    formula = A+o1+B+o2+C+o3+D
    result = eval(formula)
    if result == 7:
        print(formula+"=7")

Submission status: Wrong Answer

Solution code:
num = list(map(int,list(input())))
for i in range(2**3):
    ans = num[0]
    siki = str(num[0])
    for h in range(3):
        if ((i>>h)&1):
            ans += num[h+1]
            siki += ('+'+str(num[h+1]))
        else:
            ans -= num[h-1]
            siki += ('-'+str(num[h+1]))
    if ans == 7:
        print(siki+'=7')
        break

Submission status: Wrong Answer

Solution code:
N=input()
for i in range(8):
    S = ([["+","-"][(i>>j)&1] for j in range(3)])
    seq=N[0]+S[0]+N[1]+S[1]+N[2]+S[2]+N[3]
    if eval(seq)==7:
        print(seq)
        break

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    abcd = [int(s[i:i+1]) for i in range(len(s))]
    op_n = len(abcd) - 1

    for i in range(2 ** op_n):
        operator = ['-'] * op_n
        for j in range(op_n):
            if ((i >> j) & 1):
                operator[(op_n - 1) -j ] = "+"

        ans = [0] * (len(abcd) + 1)
        formula = "{}+".format(ans[0])
        for k in range(len(abcd)):
            if k == 0:
                ans[k+1] = (ans[k] + abcd[k])
                formula += str(abcd[k])
            else:
                ans[k+1] = add_or_sub(ans[k], abcd[k], operator[k-1])
                formula += (operator[k-1] + str(abcd[k]))

        if ans[len(abcd)] == 7:
            print(formula.replace("{}+".format(ans[0]), "") + "=7")
            break

def add_or_sub(num1, num2, op):
    if op == "+":
        return num1 + num2
    else:
        return num1 - num2

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N=list(input())
l=len(N)-1
for n in range(2**l):
    lis=list(format(n,'b'))
    list(map(int,lis))
    nagasa=len(lis)
    if nagasa<l:
        for _ in range(l-nagasa):
            lis.insert(0,0)
    S=int(N[0])
    ans=[]
    for ll in range(l):
        if lis[ll]=='1':
            S=S+int(N[ll+1])
            ans.append('+')
        else:
            S=int(N[ll])-int(N[ll+1])
            ans.append('-')
    if S==7:
        kotae=[N[0]]
        for x in range(l):
            kotae.append(ans[x])
            kotae.append(N[x+1])
        kotae.append('=7')
        last=''.join(kotae)
        print(last)
        break

Submission status: Wrong Answer

Solution code:
N=list(input())
l=len(N)-1
for n in range(2**l):
    lis=list(format(n,'b'))
    list(map(int,lis))
    nagasa=len(lis)
    if nagasa<l:
        for _ in range(l-nagasa):
            lis.insert(0,0)
    S=int(N[0])
    ans=[]
    for ll in range(l):
        if lis[ll]=='1':
            S=S+int(N[ll+1])
            ans.append('+')
        else:
            S=int(N[ll])-int(N[ll+1])
            ans.append('-')
    if S==7:
        kotae=[N[0]]
        for x in range(l):
            kotae.append(ans[x])
            kotae.append(N[x+1])
        last=''.join(kotae)
        print(last)
        break

Submission status: Wrong Answer

Solution code:
n = input()

for i in range(2 ** 3):
    ops = ["+"] * 3
    for j in range(3):
        if i >> j:
            ops[j] = "-"

    f = ""
    for pn, po in zip(n, ops + [""]):
        f += (pn + po)
    if eval(f) == 7:
        print(f + "=7")
        break

Submission status: Wrong Answer

Solution code:
S = input().rstrip()
plus_minus = [1, -1]
A = int(S[0])
for i in plus_minus:
    total = int(S[0])
    B = i*int(S[1])
    for j in plus_minus:
        C = j*int(S[2])
        for k in plus_minus:
            D = k*int(S[3])
            total += B+C+D
            if total == 7:
                if B >= 0:
                    B = "+" + str(B)
                if C >= 0:
                    C = "+" + str(C)
                if D >= 0:
                    D = "+" + str(D)
                answer = str(A) + str(B) + str(C) + str(D) + "=7"
                print(answer)
                exit()

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc079/tasks/abc079_c
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
ans  = str(A)
for ab in range(2):
    for bc in range(2):
        for cd in range(2):
            sum = A
            if ab:
                sum +=B
            else:
                sum -=B
            if bc:
                sum +=C
            else:
                sum -=C
            if cd:
                sum +=D
            else:
                sum -=D
            if sum == 7:
                A_B_C_D = ABCD[0] + str(ab) +ABCD[1]+ str(bc) +ABCD[2]+ str(cd) +ABCD[3]
                for i in range(1,6,2):
                    if int(A_B_C_D[i]):
                        ans += "+"
                    else:
                        ans += "-"
                    ans += A_B_C_D[i+1]
                break
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
#https://atcoder.jp/contests/abc079/tasks/abc079_c
ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
ans  = str(A)
sum = A
for ab in range(2):
    for bc in range(2):
        for cd in range(2):
            sum = A
            if ab:
                sum +=B
            else:
                sum -=B
            if bc:
                sum +=C
            else:
                sum -=C
            if cd:
                sum +=D
            else:
                sum -=D
            if sum == 7:
                A_B_C_D = ABCD[0] + str(ab) +ABCD[1]+ str(bc) +ABCD[2]+ str(cd) +ABCD[3]
                for i in range(1,6,2):
                    if A_B_C_D[i] == 0:
                        ans += "-"
                    else:
                        ans += "+"
                    ans += A_B_C_D[i+1]
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
from itertools import product
s = input()
for i in product('+-', repeat=3):
	t = ''.join([a+b for a, b in zip(list(i), s)])
	if eval(t) == 7:
		print(t+'=7');exit()

Submission status: Wrong Answer

Solution code:
array = [int(i) for i in list(input())]
flag = False
fugou = ['+', '-']

for i in fugou:
	if i == '+':
		tmp = array[0] + array[1]
	else:
		tmp = array[0] - array[1]
	for j in fugou:
		if j == '+':
			tmp2 = tmp + array[2]
		else:
			tmp2 = tmp - array[2]
		for k in fugou:
			if k == '+':
				if tmp2 + array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3]))
					flag = True
					break
			else:
				if tmp2 - array[3] == 7:
					print(str(array[0])
							+ i + str(array[1])
							+ j + str(array[2])
							+ k + str(array[3]))
					flag = True
					break
		if flag: break
	if flag: break

Submission status: Wrong Answer

Solution code:
a = input()
l = ['+', '-']
for i in l:
  for j in l:
     for k in l:
        eq = a[0] + i + a[1] + j + a[2] + k + a[3] 
        if eval(eq) == 7:
          print(eq, '=7', sep='')
          break

Submission status: Wrong Answer

Solution code:
a = input()
l = ['+', '-']
for i in l:
  for j in l:
     for k in l:
        eq = a[0] + i + a[1] + j + a[2] + k + a[3] 
        if eval(eq) == 7:
          print(eq, '=7', sep='')

Submission status: Wrong Answer

Solution code:
hoge=input()
a=int(hoge[0])
b=int(hoge[1])
c=int(hoge[2])
d=int(hoge[3])
for i in [-1,1]:
  for j in [-1,1]:
    for k in [-1,1]:
      if(a+i*b+j*c+k*d==7):
        if(i==1):
          x="+"
        else:
          x="-"
        if(j==1):
          y="+"
        else:
          y="-"
        if(k==1):
          z="+"
        else:
          z="-"
        print(str(a)+x+str(b)+y+str(c)+z+str(d)+"=7")
        break

Submission status: Wrong Answer

Solution code:
l = ["" for i in range(7)]
ll = list(input())

for i in range(4):
    l[i*2] = ll[i]

flag = False
for i in range(2):
    if i==0:
        l[1] = '+'
    else:
        l[1] = '-'
    for ii in range(2):
        if ii==0:
            l[3] = '+'
        else:
            l[3] = '-'
        for iii in range(2):
            if iii==0:
                l[5] = '+'
            else:
                l[5] = '-'
            t = "".join(l)
            ans = eval(t)
            if ans==7:
                print(t+'=7')
                flag = True
        if flag:
            break
    if flag:
        break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
op = '+-'
for op1 in op:
    for op2 in op:
        for op3 in op:
            ans = a + op1 + b + op2 + c + op3 + d
            if eval(ans) == 7:
                print('{}=7'.format(ans))
                break

Submission status: Wrong Answer

Solution code:
A,B,C,D=list(input())
flg=True
while flg:
    for a in "+-":
        for b in "+-":
            for c in "+-":
                f=A+a+B+b+C+c+D
                if eval(f)==7:
                    flg=False
                    
                    
                    
                    
                    
                    
                    
print(f+"=7")

Submission status: Wrong Answer

Solution code:
S=input()
size = len(S)
pmlist = [format(i,'010b').replace('0','+').replace('1', '-') for i in range(2**(size-1))]
for pm in pmlist:
    eq = ''.join([S[i]+pm[i] for i in range(size-1)]+[S[size-1]])
    if eval(eq) == 7:
        break
print(eq+'=7')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

import sys
import itertools as it
import operator

if __name__ == "__main__":
    xs = [int(c) for c in input().strip()]
    ops = it.product([-1, 1], repeat=3)
    res = next(op for op in ops if 7 == (xs[0] + sum(map(operator.mul, xs[1:], op))))
    symbols = ["+" if i == 1 else "-" for i in res]
    iterable = filter(
        lambda x: x is not None,
        it.chain.from_iterable(
            it.zip_longest(map(str, xs), symbols)
        )
    )
    res = "".join(iterable)
    print(res)

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 = []
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')
else:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-t0'+str(d)+'=7')

Submission status: Wrong Answer

Solution code:
from itertools import product
S = input()

for string in product(["+","-"],repeat = 3):
    string = list(string)
    string.append("")
    sum_ = [a + b for a,b in zip(S,string)]
    if eval("".join(sum_)) == 7:
        print("".join(sum_),"=7")
        break

Submission status: Wrong Answer

Solution code:
S = input()

s = []
for c in S:
    s.append(c)

operator=[]    
for i in range(2**3):
    op = ['+']*3 + ['']
    for j in range(3):
        if (i>>j) & 1:
            op[2-j] = '-'

    operator.append(op)

F = []
for op in operator:
    f = "".join(a+b for a, b in zip(s,op))
    F.append(f)


for fm in F:
    if eval(fm):
        print(fm + '=7')
        break

Submission status: Wrong Answer

Solution code:
import operator
S = input()
nums = []
for s in S:
    nums.append(int(s))

ope = {'+': operator.add, '-': operator.sub}
idx = {0:'+', 1:'-'}
for i in range(2):
    ans = ope[idx[i]](nums[0], nums[1])
    for j in range(2):
        ans = ope[idx[j]](ans, nums[2])
        for k in range(2):
            if ope[idx[k]](ans, nums[3]) == 7:
                print(str(nums[0])+idx[i]+str(nums[1])+idx[j]+str(nums[2])+idx[k]+str(nums[3])+'=7')
                quit()

Submission status: Wrong Answer

Solution code:
# import unittest
import re


def find(abcd):
    a, b, c, d = abcd
    ops = ['{}{}{}'.format(i, j, k)
           for i in [0, 1, 2] for j in [0, 1, 2] for k in [0, 1, 2]]
    opr = {'0': '', '1': '+', '2': '-'}

    pattern = re.compile(r'([\+,-])')

    for op in ops:
        expression = a + opr[op[0]] + b + opr[op[1]] + c + opr[op[2]] + d
        splitted = pattern.split(expression)
        suppressed = ''
        for item in splitted:
            if item != '+' and item != '-':
                suppressed += str(int(item))
            else:
                suppressed += item
        try:
            if eval(suppressed) == 7:
                return(expression)
        except SyntaxError:
            pass


def main():
    abcd = input()
    print('{}=7'.format(find(abcd)))


main()

Submission status: Wrong Answer

Solution code:
def main():
    a, b, c, d = input()
    ops = [str(i) + str(j) + str(k)
           for i in [0, 1, 2] for j in [0, 1, 2] for k in [0, 1, 2]]
    opr = {'0': '', '1': '+', '2': '-'}

    for op in ops:
        expression = a + opr[op[0]] + b + opr[op[1]] + c + opr[op[2]] + d
        try:
            if eval(expression) == 7:
                print('{}=7'.format(expression))
                break
        except SyntaxError:
            pass


main()

Submission status: Wrong Answer

Solution code:
I = input()
for param in range(2**(len(I)-1)):
    ans = ""
    for i in range(len(I)):
        ans += I[i] + ["+","-",""][((param >> i) & 1) if i != len(I) - 1 else 2]
    if eval(ans) == 7:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:

import copy
x = input()
x_copy = copy.deepcopy(x)
for i in range(8):
    for j in range(3):
        if (i >> j):
            x = x[:2*j+1] + "+" + x[2*j+1:]
        else:
            x = x[:2*j+1] + "-" + x[2*j+1:]
    if eval(x) == 7:
        print(x + "=7")
        break
    x = x_copy

Submission status: Wrong Answer

Solution code:
s = input()
space = len(s) - 1
ans = 0

for i in range(2 ** space):
    formula = s[0]
    for j in range(space):
        if (i >> j) & 1:
            formula += "+"
        else:
            formula += "-"
        formula += s[j + 1]
    if eval(formula) == 7:
        print("{}=7".format(formula))