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:
numbers = input()
a,b,c,d = numbers
i = len(numbers)-1

op = ['+','-']

for j in range(2 ** i):
  o = [op[int((j>>k)&1)] for k in range(i)]
  f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
  print(f+'=7') if eval(f) == 7 else ''

Submission status: Wrong Answer

Solution code:
numbers = input()
a,b,c,d = numbers
i = len(numbers)-1

op = ['+','-']

for j in range(2 ** i):
  o = [op[int((j>>k)&1)] for k in range(i)]
  f=f"{a}{o[0]}{b}{o[1]}{c}{o[2]}{d}"
  print(f) if eval(f) == 7 else ''

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input())
ans = [str(A)]
for b in [B,-B]:
    for c in [C,-C]:
        for d in [D,-D]:
            if sum([A,b,c,d]) == 7:
                ans += ['+' + str(x) if x >= 0 else str(x) for x in [b,c,d]]
                print(''.join(ans) + '=7')
                break

Submission status: Wrong Answer

Solution code:
A,B,C,D = map(int, input())
ans = list(str(A))
for b in [-B,B]:
    for c in [-C,C]:
        for d in [-D,D]:
            if sum([A,b,c,d]) == 7:
                ans += ["+" + str(x) if x>=0  else str(x) for x in [b,c,d]]
            break
for i in ans:
    print(i, end = "")
print("=7")

Submission status: Wrong Answer

Solution code:
a, b, c, d = input()
op = ["+", "-"]

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

Submission status: Wrong Answer

Solution code:
a, b, c, d = input()
op = ["+", "-"]

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

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

Submission status: Wrong Answer

Solution code:
s=input()
x1=""
s1=0
s1=int(s[0]) +int(s[1])+int(s[2])+int(s[3])
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
if s1==7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"+"+s[3])
elif a+b+c-d==7:
    print(s[0]+"+"+s[1]+"+"+s[2]+"-"+s[3])
elif a+b-c+d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"+"+s[3])
elif a-b+c+d==7:
    print(s[0]+"-"+s[1]+"+"+s[2]+"+"+s[3])
elif a+b-c-d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3])
elif a-b+c-d==7:
    print(s[0]+"+"+s[1]+"-"+s[2]+"-"+s[3])
elif a-b-c+d==7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"+"+s[3])
elif a-b-c-d==7:
    print(s[0]+"-"+s[1]+"-"+s[2]+"-"+s[3])

Submission status: Wrong Answer

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

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:
n = input()
num = [int(x) for x in n]

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:
A, B, C, D = input()
op = ["+", "-"]

for i in op:
    for j in op:
        for k in op:
            ans = A + i + B + j + C + k + D
            if eval(ans) == 7:
                break
print(ans + "=7")

Submission status: Wrong Answer

Solution code:
s=input()
A=[]
for i in range(len(s)):
    A.append(int(s[i]))
d=''
B=[]
val=[]
for i in range(2):
    c=A[0]
    if i==0:
        c+=A[1]
    else:
        c-=A[1]
    for j in range(2):
        if j==0:
            c+=A[2]
        else:
            c-=A[2]
        for k in range(2):
            if k==0:
                c+=A[3]
            else:
                c-=A[3]
            if c==7:
                B.append(i)
                B.append(j)
                B.append(k)
                for l in range(4):
                    d+=s[l]
                    if l!=3:
                        if B[l]==0:
                            d+='+'
                        else:
                            d+='-'
                print(d+'=7')
                exit()
            else:
                c=0

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


for i in range(2**(n-1)):
  ans = int(s[0])
  f = s[0]
  for j in range(n-1):
    if i & (1<<j):
      f += '+'
      ans += int(s[j+1])
    else:
      f += '-'
      ans -= int(s[j+1])
    f += s[j+1]
    
if ans == 7:
  print(f + '=7')
  exit()

Submission status: Wrong Answer

Solution code:
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    ans = a
    for op2 in op:
        for op3 in op:
            if op1 == 'plus':
                ans += b
            else:
                ans -= b
            if op2 == 'plus':
                ans += c
            else:
                ans -= c
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()

Submission status: Wrong Answer

Solution code:
a,b,c,d = list(map(int,input()))
op = ['plus','minus']
dic = {'plus':'+','minus':'-'}

for op1 in op:
    ans = a
    if op1 == 'plus':
        ans += b
    else:
        ans -= b
    for op2 in op:
        if op2 == 'plus':
            ans += c
        else:
            ans -= c
        for op3 in op:
            if op3 == 'plus':
                ans += d
            else:
                ans -= d
            if ans == 7:
                print(f'{a}{dic[op1]}{b}{dic[op2]}{c}{dic[op3]}{d}=7')
                exit()

Submission status: Wrong Answer

Solution code:
def myfunc(op):
    if op == 1:
        return "+"
    else:
        return "-"


a, b, c, d = [int(i) for i in list(input())]

for j in range(8):
    op = [1, 1, 1]
    for i in range(3):
        if (j >> i) & 1:
            op[i] = -1
    if a + b * op[0] + c * op[1] + d * op[2] == 7:
        x = myfunc(op[0])
        y = myfunc(op[1])
        z = myfunc(op[2])
        print(f"{a}{x}{b}{y}{c}{z}{d}=7")

Submission status: Wrong Answer

Solution code:
n = input()
l = len(n) - 1

for i in range(2 ** l):
    ans: int = int(n[0])
    num = n[0]
    for j in range(l):
        if (i >> j) & 1:
            num += "+"
            num += n[j + 1]
        else:
            num += "-"
            num += n[j + 1]
    for k in range(1, len(num), 2):
        if num[k] == "-":
            ans -= int(num[k+1])
        else:
            ans += int(num[k+1])
    if ans == 7:
        print(num + "=7")

Submission status: Wrong Answer

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

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

else:
    sa = sum(ABCD) - 7
    t = sa // 2

    one = "+"
    two = "+"
    thr = "+"

    if ABCD[1] == t:
        one = "-"
    elif ABCD[2] == t:
        two = "-"
    else:
        thr = "-"

    print("{0}{1}{2}{3}{4}{5}{6}=7".format(ABCD[0], one, ABCD[1], two, ABCD[2], thr, ABCD[3]))

Submission status: Wrong Answer

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

dic = { 1:"+" , -1:"-"}

import itertools
for AB,BC,CD in itertools.product([1,-1],repeat=3):
    tmp = A + B*AB + C*BC + D*CD

    if tmp ==7:
        ans = str(A)+dic[AB]+str(B)+dic[BC]+str(C)+dic[CD]+str(D)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
tn=list(map(int,list(input())))
for i in range(2,16,2):
  if sum(x*[1,-1][i>>k&1] for k,x in enumerate(tn))==7:
    s=''.join(list(['+','-'][i>>k&1]+str(tn[k]) for k in range(1,4)))
    print(str(tn[0])+s+'=7')
    break

Submission status: Wrong Answer

Solution code:
tn=list(map(int,list(input())))
for i in range(2,16,2):
  if sum(x*[1,-1][i>>k&1] for k,x in enumerate(tn))==7:
    print(str(tn[0])+''.join(list(['+','-'][i>>k&1]+str(tn[k]) for k in range(1,4))))
    break

Submission status: Wrong Answer

Solution code:
x = list(map(int,input()))
for i in range(2**3):
  ans = x[0]
  echo = x.copy()
  for j in range(3):
    if (i >> j) & 1:
      ans += x[j+1]
      echo.insert(2*j+1,"+")
      print(ans)
      print(echo)
    else:
      ans -= x[j+1]
      echo.insert(2*j+1,"-")
  if ans == 7:
    echo.append("=7")
    print(''.join(map(str,echo)))
    exit()

Submission status: Wrong Answer

Solution code:
x = list(map(int,input()))
for i in range(2**3):
  ans = x[0]
  echo = x.copy()
  for j in range(3):
    if (i >> j) & 1:
      ans += x[j+1]
      echo.insert(2*j+1,"+")
      print(ans)
      print(echo)
    else:
      ans -= x[j+1]
      echo.insert(2*j+1,"-")
  if ans == 7:
    print(''.join(map(str,echo)))
    exit()

Submission status: Wrong Answer

Solution code:
x = list(map(int,input()))
for i in range(2**3):
  ans = x[0]
  list = []
  for j in range(3):
    if (i >> j) & 1:
      ans += x[j+1]
      list.append("+")
    else:
      ans -= x[j+1]
      list.append("-")
  if ans == 7:
    print(x[0],list[0],x[1],list[1],x[2],list[2],x[3])
    exit()

Submission status: Wrong Answer

Solution code:
s=input()
a=int(s[0])
b=int(s[1])
c=int(s[2])
d=int(s[3])
arr=[b,c,d]
for i in range(8):
    x=i
    m=a
    k=''
    for j in range(3):
        if x&1:
            m+=arr[j]
            k+='+'
        else:
            m-=arr[j]
            k+='-'
        x=x>>1
    if m==7:
        k=k[::-1]
        print (s[0]+k[0]+s[1]+k[1]+s[2]+k[2]+s[3]+'='+'7')
        break

Submission status: Wrong Answer

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

for i in range(1 << 3):
    x = A[0]
    ans = str(A[0])
    for j in range(3):
        if i & 1 << j > 0:
            x += A[j + 1]
            ans += '+' + str(A[j + 1])
        else:
            x -= A[j + 1]
            ans += '-' + str(A[j + 1])
    if x == 7:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
n=int(input())
d=n%10
c=(n//10)%10
b=(n//100)%10
a=n//1000
k=[1,1,1]

for i in range(8):
    for j in range(3):
        if ((i>>j)&1):
            k[j]=-1
    if a+k[0]*b+k[1]*c+k[2]*d==7:
        for j in range(3):
            if k[j]==1:
                k[j]="+"
            else:
                k[j]="-"
        print(str(a)+k[0]+str(b)+k[1]+str(c)+k[2]+str(d)+"=7")
        break

Submission status: Wrong Answer

Solution code:
A = list(input())
sign = ['+','-']
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(A[0]+sign[i]+A[1]+sign[j]+A[2]+sign[k]+A[3]) == 7:
                print('{}{}{}{}{}{}{}'.format(A[0],sign[i],A[1],sign[j],A[2],sign[k],A[3]))
                exit()

Submission status: Wrong Answer

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

done = False
ops = ['+', '-']
for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            left = a
            left += b if op1 == '+' else -b
            left += c if op2 == '+' else -b
            left += d if op3 == '+' else -b
            if left == 7:
                done = True
                break
        if done:
            break
    if done:
        break
print('{a}{op1}{b}{op2}{c}{op3}{d}=7'.format(a=a, b=b, c=c, d=d, op1=op1, op2=op2, op3=op3))

Submission status: Wrong Answer

Solution code:
import itertools

S=input()

for i in itertools.product(["+","-"],repeat=3):
    ans=""
    for j in range(len(i)):
        if i[j]=="+":
            ans+=S[j]+i[j]
        elif i[j]=="-":
            ans+=S[j]+i[j]
    ans+=S[-1]
    sum_num=eval(ans)
    if sum_num==7:
        print(ans+"=0")
        break

Submission status: Wrong Answer

Solution code:
s = str(input())
n = 4
for bit in range(1 << n):
    f = '0'
    for i in range(0,n):
        if bit & (1 << i):
            f += '+-' + s[i]
        else:
            f += '+' + s[i]
    #print(f)
    ans = sum(map(int,f.split('+')))
    if ans == 7:
        f = f[2:]
        break
print(f.replace('+-','-')+'=7')

Submission status: Wrong Answer

Solution code:
s = str(input())
n = 4
for bit in range(1 << n):
    f = '0'
    for i in range(0,n):
        if bit & (1 << i):
            f += '+-' + s[i]
        else:
            f += '+' + s[i]
    #print(f)
    ans = sum(map(int,f.split('+')))
    if ans == 7:
        f = f.replace('+-','-',4)
        break
if f[:2] == '0+':
    print(f[2:] + '=7')
else:
    print(f[1:] + '=7')

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

S = input().strip()
res = 7
num = list()
for i in range(len(S)):
    num.append(int(S[i]))

for b in range(2**(3)):
    b_str = format(b, 'b').zfill(len(S)-1)
    sum = 0
    for i in range(len(num) - 1):
        if b_str[i] == '0':
            sum -= num[i]
        else:
            sum += num[i]
    if sum == res:
        break

plus_or_minus = list()
for i in range(3):
    if b_str[i] == '0':
        plus_or_minus.append('-')
    else:
        plus_or_minus.append('+')
print('{}{}{}{}{}{}{}=7'.format(num[0], plus_or_minus[0], num[1], plus_or_minus[1], num[2], plus_or_minus[2], num[3]))

Submission status: Wrong Answer

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

mozi = input()
suzi_list = []
for i in mozi:
    suzi_list.append(i)

n = len(suzi_list)

plus_minus, res = [], []

for i in range(2**(n-1)):
    plus_minus.append("{:03b}".format(i))

for i in plus_minus:
    i = i.replace("0", "-")
    i = i.replace("1", "+")
    res.append(i)


for i in res:
    sum = ""
    for count, j in enumerate(i):
        x = suzi_list[count]+j
        sum = sum + x
    # print(suzi_list[count+1])
    sum = sum + suzi_list[-1]
    if(eval(sum) >= 7):
        print(sum+"="+str(eval(sum)))
        break

Submission status: Wrong Answer

Solution code:
import itertools
s = input()
ans=0
for i in list(itertools.product([0,1], repeat=len(s)-1)):
    b = 0
    a = int(s[0])
    l = [a]+[0]*(2*(len(s)-1))
    for j in range(len(s)-1):
        if i[j] == 0:
            a += int(s[j+1])
            l[2*j+1] = '+'
            l[2*j+2] = str(s[j+1])
        else:
            a -= int(s[j+1])
            l[2*j+1] = '-'
            l[2*j+2] = str(s[j+1])
    if a == 7:
        l[0] = str(s[0])
        l += '=7'
        l = ''.join(l)
        print(l)

Submission status: Wrong Answer

Solution code:
import itertools
s = input()
ans=0
for i in list(itertools.product([0,1], repeat=len(s)-1)):
    b = 0
    a = int(s[0])
    l = [a]+[0]*(2*(len(s)-1))
    for j in range(len(s)-1):
        if i[j] == 0:
            a += int(s[j+1])
            l[2*j+1] = '+'
            l[2*j+2] = s[j+1]
        else:
            a -= int(s[j+1])
            l[2*j+1] = '-'
            l[2*j+2] = s[j+1]
    if a == 7:
        print(*l,'=7')
        break

Submission status: Wrong Answer

Solution code:
from itertools import product
A,B,C,D = list(input())
for k in list(product(['+','-'],repeat=3)):
    k = A + k[0] + B + k[1] + C + k[2] + D
    if eval(k) == 7:
        print('{}=7'.format(k))

Submission status: Wrong Answer

Solution code:
def GSB(x):
	counter=0
	while x!=0:
		counter+=1
		x=x>>1
	return counter


N=[int(x) for x in (list(input()))]
combinations=[int(x) for x in range((2**3))]
for i in combinations:
	checker=[x for x in N]
	j=0
	z=GSB(i)
	while j!=z and i!=0:
		if i&1==1:
			checker[j]*=-1
		i=i>>1
		j+=1
	if sum(checker)==7 and checker[0]>=0:
		checker=checker + [-1]
		for i in range(4):
			if checker[i+1]>=0:
				print(checker[i],end="+")
			else:
				print(checker[i],end="")
		print("=7")
		exit()

Submission status: Wrong Answer

Solution code:
N=[int(x) for x in list(input())]
if (N[0] -N[1] -N[2] - N[3] ==7): print(str(N[0])+"-" +str(N[1])+"-"+str(N[2])+"-"+str(N[3])+"=7")
elif (N[0] -N[1] -N[2] + N[3] ==7): print(str(N[0])+"-" +str(N[1])+"-"+str(N[2])+"+"+str(N[3])+"=7")
elif (N[0] -N[1] +N[2] - N[3] ==7): print(str(N[0])+"-" +str(N[1])+"+"+str(N[2])+"-"+str(N[3])+"=7")
elif (N[0] -N[1] +N[2] + N[3] ==7): print(str(N[0])+"-" +str(N[1])+"+"+str(N[2])+"+"+str(N[3])+"=7")
elif (N[0] +N[1] +N[2] + N[3] ==7): print(str(N[0])+"+" +str(N[1])+"+"+str(N[2])+"+"+str(N[3])+"=7")
elif (N[0] +N[1] -N[2] - N[3] ==7): print(str(N[0])+"+" +str(N[1])+"-"+str(N[2])+"-"+str(N[3])+"=7")
elif (N[0] +N[1] +N[2] - N[3] ==7): print(str(N[0])+"+" +str(N[1])+"+"+str(N[2])+"-"+str(N[3])+"=7")
elif (N[0] +N[1] -N[2] + N[3] ==7): print(str(N[0])+"-" +str(N[1])+"-"+str(N[2])+"-"+str(N[3])+"=7")

Submission status: Wrong Answer

Solution code:
def GSB(x):
	counter=0
	while x!=0:
		counter+=1
		x=x>>1
	return counter


N=[int(x) for x in (list(input()))]
combinations=[int(x) for x in range((2**4))]
for i in combinations:
	checker=[x for x in N]
	j=0
	z=GSB(i)
	while j!=z and i!=0:
		if i&1==1:
			checker[j]*=-1
		i=i>>1
		j+=1
	if sum(checker)==7:
		checker=checker + [-1]
		for i in range(4):
			if checker[i+1]>=0:
				print(checker[i],end="+")
			else:
				print(checker[i],end="")
		print("=7")
		exit()

Submission status: Wrong Answer

Solution code:
def GSB(x):
	counter=0
	while x!=0:
		counter+=1
		x=x>>1
	return counter-1


N=[int(x) for x in (list(input()))]
combinations=[int(x) for x in range((2**4))]
for i in combinations:
	checker=[x for x in N]
	j=0
	z=GSB(i)
	while j!=z and i!=0:
		if i&1==1:
			checker[j]*=-1
		i=i>>1
		j+=1
	if sum(checker)==7:
		checker=checker + [-1]
		for i in range(4):
			if checker[i+1]>=0:
				print(checker[i],end="+")
			else:
				print(checker[i],end="")
		print("=7")
		exit()

Submission status: Wrong Answer

Solution code:
s=input()
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            # 答えは1つ出力すれば良いので =7 になれば終了
            print(f + "=7")
            exit()
    else:
        # 式 f の末尾に符号と次の数字を追加し、その分 sum に加減する
        dfs(i+1,f+"-"+s[i+1], sum-int(s[i+1]))
        dfs(i+1,f+"+"+s[i+1], sum+int(s[i+1]))

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

Submission status: Wrong Answer

Solution code:
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    # 式 f の末尾に "+" を追加するかしないかして次の数字を追加
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
s = input()
n = len(s)
print(dfs(0, s[0]))

Submission status: Wrong Answer

Solution code:
import itertools
L = input()
L = [int(x) for x in list(str(L))]
P = [0]*3
sum = L[0]
A = (1,-1)
for a in itertools.product(A,repeat=3):
	for i in range(3): 
		sum += a[i]*L[i+1]
		if a[i] == 1:
			P[i] = '+'
		else:
			P[i] = '-'
	if sum == 7:
		print(L[0],P[0],L[1],P[1],L[2],P[2],L[3],'=7',sep = '')
		break

Submission status: Wrong Answer

Solution code:
num=open(0).read()
A=int(num[0])
B=int(num[1])
C=int(num[2])
D=int(num[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
            ans=A+b+c+d
            print(ans)
            if ans==7:
                sgn=[i,j,k]
                for l in range(3):
                    if sgn[l]%2==0:
                        sgn[l]='+'
                    else:
                        sgn[l]='-'
print(str(A)+sgn[0]+str(B)+sgn[1]+str(C)+sgn[2]+str(D)+'=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])
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
            ans=A+b+c+d
            print(ans)
            if ans==7:
                sgn=[i,j,k]
                for l in range(3):
                    if sgn[l]%2==0:
                        sgn[l]='+'
                    else:
                        sgn[l]='-'
print(str(A)+sgn[0]+str(B)+sgn[1]+str(C)+sgn[2]+str(D)+'=7')

Submission status: Wrong Answer

Solution code:
A,B,C,D = input()
op = ["+","-"]

for i in op:
  for j in op:
    for k in op:
      ans = A+i+B+j+C+k+D
      if eval(ans)==7:
        print(ans+"=7")
        break

Submission status: Wrong Answer

Solution code:
n_str = list(input())
n = [int(i) for i in n_str]
l = len(n)
for i in range(2 ** l):
    sum = 0
    op_list = []
    for j in range(l):
        if (i >> j) & 1:
            sum += n[j]
            op_list.append('+')
        else:
            sum -= n[j]
            op_list.append('-')
    if sum == 7:
        print(n_str[0]+op_list[0]+n_str[1]+op_list[1]+n_str[2]+op_list[2]+n_str[3]+'=7')
        exit()

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
sign = "+-"
for i in range(2):  # 1つ目の記号
    for j in range(2):  # 2つ目の記号
        for k in range(2):  # 3つ目の記号
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(str(a+sign[i]+b+sign[j]+c+sign[k]+d)+"=7")

Submission status: Wrong Answer

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

for i in range(8):
    k = 0
    b = []
    for j in range(3):
        if ((i >> j) & 1):
            k += a[j+1]
            b.append("+")
        else:
            k -= a[j+1]
            b.append("-")
    if k == 7: break

ans = ""
for i in range(3):
    ans += str(a[i]) + b[i]
ans += str(a[3]) + "=7"

print(ans)

Submission status: Wrong Answer

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

for i in range(16):
    log = []
    x = 0
    for s in range(4):
        if i>>s%1:
            x += t[s]
            log.append("+")
        else:
            x -= t[s]
            log.append("-")
    if x == 7:
        print(str(t[0])+log[0]+str(t[1])+log[1]+str(t[2])+log[2]+str(t[3])+"=7")
        break

Submission status: Wrong Answer

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

for i in range(8):
    log = []
    x = 0
    for s in range(4):
        if i>>s%1:
            x += t[s]
            log.append("+")
        else:
            x -= t[s]
            log.append("-")
    if x == 7:
        print(str(t[0])+log[0]+str(t[1])+log[1]+str(t[2])+log[2]+str(t[3])+"=7")
        break

Submission status: Wrong Answer

Solution code:
s = input()

n = 3
for i in range(2**n):
    ans = s[0]
    sum = int(s[0])
    for j in range(3):
        if 1 & (i >> j):
            ans += f'+{s[j+1]}'
            sum += int(s[j+1])
        else:
            ans += f'-{s[j+1]}'
            sum -= int(s[j+1])
    if sum == 7:
        print(f'{ans}+7')
        exit()

Submission status: Wrong Answer

Solution code:
l = list(input())
for i in range(8):
  s = int(l[0])
  b = bin(i)[2:].zfill(3)
  op = ["", "", ""]
  for j in range(len(b)):
    if b[j] == "0":
      s += int(l[j+1])
      op[j] = "+"
    else:
      s -= int(l[j+1])
      op[j] = "-"
  if s == 7:
    print(l[0]+op[0]+l[1]+op[1]+l[2]+op[2]+l[3]+"=7")

Submission status: Wrong Answer

Solution code:
# C - Train Ticket
# https://atcoder.jp/contests/abc079/tasks/abc079_c
S = input()
n = len(S) - 1
TOTAL = 7
for i in range(1 << n):
    x = S[0]
    for j in range(n):
        if i & 1 << j:
            x += "+"
        else:
            x += "-"
        x += S[j + 1]
        if eval(x) == TOTAL:
            print(f"{x}={TOTAL}")
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
import sys,math,collections,itertools
input = sys.stdin.readline

a,b,c,d =list(input().rstrip())
op_lis = itertools.product('+-*/',repeat=3)
for op in op_lis:
    try:
        if eval(a+op[0]+b+op[1]+c+op[2]+d) == 7:
            print(a+op[0]+b+op[1]+c+op[2]+d+'=7')
            exit()

    except ZeroDivisionError:
        continue

Submission status: Wrong Answer

Solution code:
S = input()
if int(S[0])+int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}+{S[3]}==7')
elif int(S[0])+int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}+{S[2]}-{S[3]}==7')
elif int(S[0])+int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}+{S[3]}==7')
elif int(S[0])-int(S[1])+int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}+{S[3]}==7')
elif int(S[0])+int(S[1])-int(S[2])-int(S[3])==7:
    print(f'{S[0]}+{S[1]}-{S[2]}-{S[3]}==7')
elif int(S[0])-int(S[1])+int(S[2])-int(S[3])==7:
    print(f'{S[0]}-{S[1]}+{S[2]}-{S[3]}==7')
elif int(S[0])-int(S[1])-int(S[2])+int(S[3])==7:
    print(f'{S[0]}-{S[1]}-{S[2]}+{S[3]}==7')
else:
    print(f'{S[0]}-{S[1]}-{S[2]}-{S[3]}==7')

Submission status: Wrong Answer

Solution code:
n = input()
op_cnt = len(n) - 1  # すき間の個数
for i in range(2**op_cnt):
  op = ['-'] * op_cnt
  for j in range(op_cnt):
    if (i >> j) & 1:
      op[op_cnt-1-j] = '+'
      formula = ''
      for p_n, p_o in zip(n, op + ['']):
        formula += (p_n + p_o)
      if eval(formula) == 7:
          print(formula + '=7')
          break

Submission status: Wrong Answer

Solution code:
from itertools import product

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

ops = product([1,-1],repeat=3)

for op in ops:
  test = a + b * op[0] + c * op[1] + d * op[2]
  if test == 7:
    _op = [""]*3
    for i in range(3):
      _op[i] = "+" if op[i] else "-"
    print("{}{}{}{}{}{}{}=7".format(a,_op[0],b,_op[1],c,_op[2],d))
    exit()
print(-1)

Submission status: Wrong Answer

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

cnt = 0
def get_str(i):
    if i >= 0:
        s = "+{}".format(i)
    else:
        s = "{}".format(i)
    return s

for i in range(1 << 3):
    if (i >> 2) % 2 == 0:
        b = -b
    if (i >> 1) % 2 == 0:
        c = -c
    if (i >> 0) % 2 == 0:
        d = -d

    if a + b + c + d == 7:
        s = ""
        s += get_str(a)
        s += get_str(b)
        s += get_str(c)
        s += get_str(d)
        s += "=7"
        print(s[1::])
        break

Submission status: Wrong Answer

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

cnt = 0
def get_str(a):
    if a >= 0:
        s = "+{}".format(a)
    else:
        s = "{}".format(a)
    return s

for i in range(1 << 4 - 1):
    if (i >> 2) % 2 == 0:
        b = -b
    if (i >> 1) % 2 == 0:
        c = -c
    if (i >> 0) % 2 == 0:
        d = -d

    if a + b + c + d  == 7:
        s = ""
        s += get_str(a)
        s += get_str(b)
        s += get_str(c)
        s += get_str(d)
        s += "=7"
        print(s[1::])
        break

Submission status: Wrong Answer

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

cnt = 0
def get_str(a):
    if a >= 0:
        s = "+{}".format(a)
    else:
        s = "{}".format(a)
    return s

for i in range(1 << 4 - 1):
    if (i >> 3) % 2 == 0:
        a = -a
    if (i >> 2) % 2 == 0:
        b = -b
    if (i >> 1) % 2 == 0:
        c = -c
    if (i >> 0) % 2 == 0:
        d = -d

    if a + b + c + d  == 7:
        s = ""
        s += get_str(a)
        s += get_str(b)
        s += get_str(c)
        s += get_str(d)
        s += "=7"
        if a >= 0:
            print(s[1::])
        else:
            print(s[::])
        break