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:
ABCD = int(input())
a = int(ABCD//10e2)
b = int((ABCD-a*10e2)//10e1)
c = int((ABCD-a*10e2-b*10e1)//10)
d = int(ABCD-a*10e2-b*10e1-c*10)
print(a,b,c,d)
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")
elif a-b-c-d == 7:
    print(str(a)+"-"+str(b)+"-"+str(c)+"-"+str(d)+"=7")

Submission status: Wrong Answer

Solution code:
n = input()
s_num = len(n) -1 
all_p_m = []
for i in range(2**s_num):
  p_m_list = [False for i in range(s_num)]
  for j in range(s_num):
    if ((i >>j) & 1):
      p_m_list[j] = True
  all_p_m.append(p_m_list)
  
for p_m in all_p_m:
  result = int(n[0])
  for i in range(len(p_m)):
    if p_m[i] == True:
      result += int(n[i + 1])
    else:
      result -= int(n[i + 1])
  if result == 7:
    ans_p_m = p_m

ans = ["0" for i in range(7)]
for _ in range(7):
  if _ %2 ==0:
    ans[_] = n[_//2]
  else:
    if ans_p_m[_//2] == True:
    	ans[_] = "+"
    else:
      ans[_] = "-"
    
print("".join(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=input()
A=int(N[0])
E=7-A
F=["-","-","-"]
for i in range(8):
 B=int(N[1])
 C=int(N[2])
 D=int(N[3])
 for j in range(3):
  if ((i >> j) & 1):
   F[j]="+"
 if F[0]=="-":
  B*=-1
 if F[1]=="-":
  C*=-1
 if F[2]=="-":
  D*=-1
 if B+C+D==E:
  print(str(A)+str(F[0])+str(B)+str(F[1])+str(C)+str(F[2])+str(D)+"=7")
  break

Submission status: Wrong Answer

Solution code:
A, B, C, D = (int(x) for x in input())

class Op(int):
  def __str__(self):
     return '-' if self < 0 else '+'
    
pm = (Op(1), Op(-1))    

for op1 in pm:
  for op2 in pm:
    for op3 in pm:
      if A + op1 * B + op2 * C + op3 * D == 7:
        print(''.join(str(x) for x in [A, op1, B, op2, C, op3, D]) + '=7')
        break

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
while True:
    if a + b + c + d == 7:
        print('%d+%d+%d+%d=7'%(a,b,c,d))
        break
    if a + b + c - d == 7:
        print('%d+%d+%d-%d=7'%(a,b,c,d))
        break
    if a + b - c + d == 7:
        print('%d+%d-%d+%d=7'%(a,b,c,d))
        break
    if a + b - c - d == 7:
        print('%d+%d-%d-%d=7'%(a,b,c,d))
        break
    if a - b - c - d == 7:
        print('%d-%d-%d-%d=7'%(a,b,c,d))
        break
    if a - b + c + d == 7:
        print('%d-%d+%d+%d=7'%(a,b,c,d))
        break
    if a - b + c - d == 7:
        print('%d-%d+%d-%d=7'%(a,b,c,d))
        break
    if a - b - c + d == 7:
        print('%d-%d-%d-%d=7'%(a,b,c,d))
        break

Submission status: Wrong Answer

Solution code:
import itertools
status = [(0, 1) for _ in range(3)]
state = list(itertools.product(*status))
num = [int(i) for i in input()]
for ptn in state:
  ans = num[0]
  ans_str = str(num[0])
  for i,ope in enumerate(ptn):
    if ope == 0:
      ans += num[i+1]
      ans_str += ("+" + str(num[i+1]))
    else:
      ans -= num[i+1]
      ans_str += ("-" + str(num[i+1]))
  if ans == 7:
    break
print(ans_str)

Submission status: Wrong Answer

Solution code:
def dfs(num, string, place):
    if len(string) == 0:
        return dfs(num, num[0], place+1)
    
    if len(string) == 7:
        if eval(string) == 7:
            print(string + "=7")
            exit()
        return 
    else:
        return dfs(num, string + "+" + num[place], place + 1), dfs(num, string + "-" + num[place], place + 1)
dfs("1222", "",0)

Submission status: Wrong Answer

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



l=[str(a),'+',str(b),'+',str(c),'+',str(d)]
for i in range(1):
    #+++
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    #-++
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='-'
    #--+
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break
    
    l[5]='-'
    #---
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='+'
    #+--
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='+'
    #++-
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[3]='+'
    l[5]='-'
    #+-+
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

    l[1]='-'
    l[3]='+'
    l[5]='-'
    #-+-
    seven=''.join(l)
    if eval(seven)==7:
        print(seven+'=7')
        break

Submission status: Wrong Answer

Solution code:
def main():
    s = input()

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

    for i in range(2):
        tmp = 0
        if i % 2 == 0:
            tmp = a + b 
        else:
            tmp = a - b
        for j in range(2):
            if j % 2 == 0:
                hoge = tmp
                tmp += c
            else:
                tmp = hoge
                tmp -= c
            for k in range(2):
                if k % 2 == 0:
                    hoge = tmp
                    tmp += d
                else:
                    tmp = hoge
                    tmp -= d
                if tmp == 7:
                    op1 = '+' if i % 2 == 0 else '-'
                    op2 = '+' if j % 2 == 0 else '-'
                    op3 = '+' if k % 2 == 0 else '-'
                    print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                    exit()
            

    # print(i,j,k,tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    s = input()

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

    for i in range(2):
        tmp = 0
        if i % 2 == 0:
            tmp = a + b 
        else:
            tmp = a - b
        for j in range(2):
            if j % 2 == 0:
                tmp += c
            else:
                tmp -= c
            for k in range(2):
                if k % 2 == 0:
                    tmp += d
                else:
                    tmp -= d
                if tmp == 7:
                    op1 = '+' if i % 2 == 0 else '-'
                    op2 = '+' if j % 2 == 0 else '-'
                    op3 = '+' if k % 2 == 0 else '-'
                    print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
                    exit()
            

    # print(i,j,k,tmp)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

A = [S[0], -S[0]]
B = [S[1], -S[1]]
C = [S[2], -S[2]]
D = [S[3], -S[3]]

E = []
for i in A:
    for j in B:
        for k in C:
            for l in D:
                if i + j + k + l == 7:
                    E = [i, j, k, l]
                    break
s = ""
for i in range(4):
    if i == 0:
        s += str(E[i])
    else:
        if E[i] < 0:
            s += str(E[i])
        else:
            s += "+" + str(E[i])
print(s + "=7")

Submission status: Wrong Answer

Solution code:
def resolve():
    S = list(map(int, input()))
    a, b, c, d = S[0], S[1], S[2], S[3]
    op = ['+', '-']
    for i in op:
        moji = str(a)
        sum = a
        sum += b if i == '+' else -b
        moji += i + str(b)
        for j in op:
            sum += c if j == '+' else -c
            moji += j + str(c)
            for k in op:
                sum += d if k == '+' else -d
                moji += k + str(d)
                if sum == 7:
                    moji += '=7'
                    return print(moji)
                moji = str(a)
                sum = a

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print(e+'=7')
        break

Submission status: Wrong Answer

Solution code:
s = input()
l = len(s)
ans = 0
for i in range(2**(l-1)):
    e = ""
    for j in range(l):
        if ((i >> j) & 1):
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    if eval(e[:-1]) == 7:
        print('{}=7'.format(e))
        break

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, list(input()))
for i in (-1,1):
  for j in (-1,1):
    for k in (-1,1):
      if a + i * b + j * c + k * d == 7:
        op1 = '+' * ((1+i)//2) + '-' * ((1-i)//2)
        op2 = '+' * ((1+j)//2) + '-' * ((1-j)//2)
        op3 = '+' * ((1+k)//2) + '-' * ((1-k)//2)
        print(str(a)+op1+str(b)+op2+str(c)+op3+str(d))
        exit()

Submission status: Wrong Answer

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

sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            siki = a+sign[i]+b+sign[j]+c+sign[k]+d
            ans = eval(siki)
            if ans == 7 :
                print(siki + '=7')

Submission status: Wrong Answer

Solution code:
a,b,c,d = list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            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,b,c,d = list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            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,b,c,d = list(input())
sign = '+-'
for i in range(2):
    for j in range(2):
        for k in range(2):
            if eval(a+sign[i]+b+sign[j]+c+sign[k]+d) == 7:
                print(a+sign[i]+b+sign[j]+c+sign[k]+d + '==7')

Submission status: Wrong Answer

Solution code:
str_input = list(input())
for i in range(2**3):
    ope = ['-'] * 3
    siki = ''
    for j in range(3):
        if(i>>j)&1:
            ope[j] = '+'
    for moji, op in zip(str_input, ope+['']):
        siki +=(moji+op)
    print(siki)
    ans = eval(siki)
    if ans == 7:
        print(siki + '=7')
        break

Submission status: Wrong Answer

Solution code:
import itertools
L = list(input())
sm = ['+','-']
SM = list(itertools.product(sm,repeat=3))

for i,j,k in SM:
    if eval(L[0]+i+L[1]+j+L[2]+k+L[3])==7:
        print(L[0]+i+L[1]+j+L[2]+k+L[3]+'=7')

Submission status: Wrong Answer

Solution code:
n = input()
op_cnt = len(n)-1
op = ['-']*op_cnt
for i in range(2**op_cnt):
    siki = ''
    for j in range(op_cnt):
        if ((i>>j)&1):
            op[op_cnt-1-j] = '+'
    for moji, ope in zip(n, op+['']):
        siki += (moji+ope)
    if eval(siki) == 7:
        print(siki + '=7')
        break

Submission status: Wrong Answer

Solution code:
S = input()
s = [int(c) for c in S]
def to_s(a):
  if a>=0:
    return "+"+str(a)
  return str(a)

for b in [-s[1],s[1]]:
  for c in [-s[2],s[2]]:
    for d in [-s[3],s[3]]:
      if s[0]+b+c+d == 7:
        print(S[0]+to_s(s[1])+to_s(s[2])+to_s(s[3])+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
S = input()
s = [int(c) for c in S]
def to_s(a):
  if a>0:
    return "+"+str(a)
  return str(a)

for b in [-s[1],s[1]]:
  for c in [-s[2],s[2]]:
    for d in [-s[3],s[3]]:
      if s[0]+b+c+d == 7:
        print(S[0]+to_s(s[1])+to_s(s[2])+to_s(s[3])+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
a = input()

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

    sum = a[0] + N[0] + a[1] + N[1] + a[2] + N[2] + a[3]
    if eval(sum) == 7:
        print(sum + "=7")

Submission status: Wrong Answer

Solution code:
s = input()

n = len(s) - 1
ans = 0
for i in range(1 << n):
    exp = s[0]
    for j in range(n):
        if i & (1 << j):
            exp += "+"
        else:
            exp += "-"
        exp += s[j + 1]
    if eval(exp) == 7:
        ans = exp

print(ans)

Submission status: Wrong Answer

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

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

for k in [1, -1]:
    for l in [1, -1]:
        for m in [1, -1]:
            if a + (k * b) + (l * c) + (m * d) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, dict[k], b, dict[l], c, dict[m], d))

Submission status: Wrong Answer

Solution code:
def op(a,b,n):
  if n == 0:
    return a+b
  else:
    return a-b
def p(n):
  if n == 0:
    return '+'
  else:
    return '-'
s = 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):
      s1 = op(a,b,i)
      s2 = op(c,d,k)
      tmp = op(s1,s2,j)
      if tmp == 7:
        ans = str(a) + p(i) + str(b) + p(j) + str(c) + p(k) + str(d) +"=7"
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
# coding: utf-8
from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)
from inspect import currentframe


# my functions here!
#標準エラー出力
def printargs2err(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' : '+repr(arg) for arg in args),file=sys.stderr)
def debug(*args):
    print(*args,file=sys.stderr)

def printglobals():
    for (symbol, value) in globals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
def printlocals():
    for (symbol, value) in locals().items():
        print('symbol="%s"、value=%s' % (symbol, value),file=sys.stderr)
#入力（後でいじる）
def pin(type=int):
    return map(type,input().split())
     
#input

                
def resolve():
    a=list(input())
    A=["+","-"]
    temp=""
    for i in A:
        for j in A:
            for k in A:
                temp=a[0]+i+a[1]+j+a[2]+k+a[3]
                if eval(temp)==7:
                    print(temp+"=7")
                    return
        #print([["NA","YYMM"],["MMYY","AMBIGUOUS"]][cMMYY][cYYMM])
#if __name__=="__main__":resolve()

"""
#printデバッグ消した？
#前の問題の結果見てないのに次の問題に行くの？
"""
"""
お前カッコ閉じるの忘れてるだろ
"""
import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """1222"""
        output = """1+2+2+2=7"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """0290"""
        output = """0-2+9+0=7"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """3242"""
        output = """3+2+4-2=7"""
        self.assertIO(input, output)

if __name__ == "__main__":
    unittest.main()

Submission status: Wrong Answer

Solution code:
import sys

ABCD = input()
for n in range(2 ** (len(ABCD) - 1)):
    value = ""
    for i in range(len(ABCD) - 1):
        value += ABCD[i]
        if n & (2 ** i) != 1:
            value += "+"
        else:
            value += "-"
    value += ABCD[-1]
    if eval(value) == 7:
        print(value + "=7")
        sys.exit()

Submission status: Wrong Answer

Solution code:
a = list(input())
op = ['-'] * 3
for i in range(2**3):
    ans = int(a[0])
    for j in range(3):
        if 1 & (i>>j):
            ans += int(a[3-j])
            op[2-j] = '+'
        else:
            ans -= int(a[3-j])
    if ans == 7:
        break
print(a[0] + op[0] + a[1] + op[1] + a[2] + op[2] +a[3] + "=7")

Submission status: Wrong Answer

Solution code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = []

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**i+C*op**j+D*op**k == 7):
                sign.append(i)
                sign.append(j)
                sign.append(k)

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "+"
    else:
        sign[n] = "+-"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")

Submission status: Wrong Answer

Solution code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = [0]*3

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**(i+1)+C*op**(j+1)+D*op**(k+1) == 7):
                sign[0] = i
                sign[1] = j
                sign[2] = k
                quit()

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "-"
    else:
        sign[n] = "+"

print(Num[0]+sign[0]+Num[1]+sign[1]+Num[2]+sign[2]+Num[3]+"=7")

Submission status: Wrong Answer

Solution code:
Num = input()
op = -1
A = int(Num[0])
B = int(Num[1])
C = int(Num[2])
D = int(Num[3])
sign = [0]*3

for i in range(2):
    for j in range(2):
        for k in range(2):
            if(A+B*op**(i+1)+C*op**(j+1)+D*op**(k+1) == 7):
                sign[0] = i
                sign[1] = j
                sign[2] = k
                quit()

for n in range(3):
    if(sign[n] == 0):
        sign[n] = "-"
    else:
        sign[n] = "+"

print(str(A)+sign[0]+str(B)+sign[1]+str(C)+sign[2]+str(D)+"=7")

Submission status: Wrong Answer

Solution code:
b = list(map(int,list(input())))
clear = True
for i in range(2):
  for j in range(2):
    for k in range(2):
      a = b[:]
      ans = sum(a)
      if i:
        ans -= a[1]
      if j:
        ans -= a[2]
      if k:
        ans -= a[3]
      if ans == 7 and clear:
        box = str(a[0])
        if i:
          box += "-"
        else:
          box += "+"
        box += str(a[1])
        if j:
          box += "-"
        else:
          box += "+"
        box += str(a[2])
        if k:
          box += "-"
        else:
          box += "+"
        box += str(a[3])
        box += "=7"
        print(box)
        clear = False

Submission status: Wrong Answer

Solution code:
a = list(map(int,list(input())))
clear = True
for i in range(2):
  for j in range(2):
    for k in range(2):
      ans = sum(a)
      if i:
        ans -= a[1]
      if j:
        ans -= a[2]
      if k:
        ans -= a[3]
      if ans == 7 and clear:
        box = str(a[0])
        if i:
          box += "-"
        else:
          box += "+"
        box += str(a[1])
        if j:
          box += "-"
        else:
          box += "+"
        box += str(a[2])
        if k:
          box += "-"
        else:
          box += "+"
        box += str(a[3])
        box += "=7"
        print(box)
        clear = False

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[j]="+"

    formula=""
    for p_n, p_o in zip(n, op + [""]):
        formula += (p_n + p_o)
        print(formula)
    if eval(formula) == 7:
        print(formula + "=7")
        break

Submission status: Wrong Answer

Solution code:
# A, B, C, D = map(int, input())
A = list(map(int, input()))
N = len(A)
P = []
ans = []

for i in range(2**N):
    tmp_list = []
    tmp_count = 0
    for j in range(N):
        if (i>>j)&1:
            tmp_list.append("+")
            tmp_count += A[j]
        else:
            tmp_list.append("-")
            tmp_count -= A[j]
#     print(tmp_list)
#     print(tmp_count)
    if tmp_count == 7:
        ans = []
        for k in range(N):
            if k==0 and tmp_list[k]=="+":
                ans.append(str(A[k]))
            else:
                ans.append(tmp_list[k] + str(A[k]))


print("".join(ans)+"=7")

Submission status: Wrong Answer

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

def helper(i, x, op):
    if i == 4:
        if x == 7:
            return op
        else:
            return ""
    
    op_p = helper(i+1, x+int(s[i]), op + "+" + s[i])
    if op_p != "":
        return op_p
    
    op_m = helper(i+1, x-int(s[i]), op + "-" + s[i])
    if op_m != "":
        return op_m
    
    return ""

print(helper(1, int(s[0]), s[0]))

Submission status: Wrong Answer

Solution code:
s=list(input())

hugou=[]
for i in range(8):
  z=[]
  k=0
  ans=0
  for j in range(3):
    if k==0:
      z.append(s[k])
      ans+=int(s[k])
    if ((i>>j)&1):
      z.append("+")
      k+=1
      ans+=int(s[k])
      z.append(s[k])
    else:
      z.append("-")
      k+=1
      ans-=int(s[k])
      z.append(s[k])
  if ans==7:
    print("".join(z))
    break

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):
    opi = '+'
    if i == 1:
        b *= (-1)
        opi = '-'
    for j in range(2):
        opj = '+'
        if j == 1:
            c *= (-1)
            opj = '-'
        for k in range(2):
            opk = '+'
            if k == 1:
                d *= (-1)
                opk = '-'
            ans = a + b + c + d
            if ans == 7:
                print(str(a) + opi + str(abs(b)) + opj + str(abs(c)) + opk + str(abs(d)) + '=7')
                exit()

Submission status: Wrong Answer

Solution code:
seq=input()
list=[]
for i in range(4):
    list.append(int(seq[i]))
ans=[]
brk=0
for a in range (2):
    for b in range (2):
        for c in range (2):
            if list[0]+(2*a-1)*list[1]+(2*b-1)*list[2]+(2*c-1)*list[2]==7:
                ans.append(a)
                ans.append(b)
                ans.append(c)
                brk+=1
                break
        if brk!=0:
            break
    if brk!=0:
        break
A=""
B=""
C=""
if a==0:
    A="-"
else:
    A="+"
if b==0:
    B="-"
else:
    B="+"    
if c==0:
    C="-"
else:
    C="+"
print(str(list[0])+A+str(list[1])+B+str(list[2])+C+str(list[3])+"=7")

Submission status: Wrong Answer

Solution code:
seq=input()
list=[]
for i in range(4):
    list.append(int(seq[i]))
ans=[]
brk=0
for a in range (2):
    for b in range (2):
        for c in range (2):
            if list[0]+(2*a-1)*list[1]+(2*b-1)*list[2]+(2*c-1)*list[2]==7:
                ans.append(a)
                ans.append(b)
                ans.append(c)
                brk+=1
                break
        if brk!=0:
            break
    if brk!=0:
        break
A=""
B=""
C=""
if a==0:
    A="-"
else:
    A="+"
if b==0:
    B="-"
else:
    B="+"    
if c==0:
    C="-"
else:
    C="+"
print(str(list[0])+A+str(list[1])+B+str(list[2])+C+str(list[3]))

Submission status: Wrong Answer

Solution code:
N=list(input())
A=[]
for i in range(2**3):
   B=[0]*3
   for j in range(3):
      if i>>j&1:
         B[j]=1
   A.append(B)


for i in range(8):
   s=int(N[0])
   for j in range(3):
      if A[i][j]==0:
         s+=int(N[j+1])
      else:
         s-=int(N[j+1])
      if s==7:
         ans=[]
         for k in range(4):
            ans.append(N[k])
            if k<3:
               if A[i][k]==0:
                  ans.append("+")
               else:
                  ans.append("-")   
         print(''.join(ans)+'=7')   
         exit()

Submission status: Wrong Answer

Solution code:
N=list(input())
A=[]
for i in range(2**3):
   B=[0]*3
   for j in range(3):
      if i>>j&1:
         B[j]=1
   A.append(B)


for i in range(8):
   s=int(N[0])
   for j in range(3):
      if A[i][j]==0:
         s+=int(N[j+1])
      else:
         s-=int(N[j+1])
      if s==7:
         print(A[i])
         ans=[]
         for k in range(4):
            ans.append(N[k])
            if k<3:
               if A[i][k]==0:
                  ans.append("+")
               else:
                  ans.append("-")   
         print(''.join(ans)+'=7')   
         exit()

Submission status: Wrong Answer

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

op = ['+','-']

for i in op :
  for j  in op :
    for k in op :
      if eval( a+ i + b + j + c + k +d) == 7 :
        print('a{}b{}c{}d=7'.format( i, j, k))
        exit()

Submission status: Wrong Answer

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

op = ['+','-']

for i in op :
  for j  in op :
    for k in op :
      if eval( a+ i + b + j + c + k +d) == 7 :
        print('a{}b{}c{}d == 7'.format( i, j, k))
        exit()

Submission status: Wrong Answer

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

op = ["+", "-"]

def calculate(n_1, n_2, op):
    if op == 0:
        return n_1 + n_2
    else:
        return n_1 - n_2
        
for i in range(2):
    ans = calculate(a, b, i)
    for j in range(2):
        ans = calculate(ans, c, j)
        for k in range(2):
            if calculate(ans, d, k) == 7:
                print("{}{}{}{}{}{}{}=7".format(a, op[i], b, op[j], c, op[k], d))
                exit()

Submission status: Wrong Answer

Solution code:
x = [int(i) for i in list(input())]

a = x[0] + x[1] + x[2] + x[3]
aa = "{}+{}+{}+{}={}".format(x[0], x[1], x[2], x[3], a)
b = x[0] + x[1] + x[2] - x[3]
bb = "{}+{}+{}-{}={}".format(x[0], x[1], x[2], x[3], b)
c = x[0] + x[1] - x[2] + x[3]
cc = "{}+{}-{}+{}={}".format(x[0], x[1], x[2], x[3], c)
d = x[0] + x[1] - x[2] - x[3]
dd = "{}+{}-{}-{}={}".format(x[0], x[1], x[2], x[3], d)
e = x[0] - x[1] + x[2] + x[3]
ee = "{}-{}+{}+{}={}".format(x[0], x[1], x[2], x[3], e)
f = x[0] - x[1] + x[2] - x[3]
ff = "{}-{}+{}-{}={}".format(x[0], x[1], x[2], x[3], f)
g = x[0] - x[1] - x[2] + x[3]
gg = "{}-{}-{}+{}={}".format(x[0], x[1], x[2], x[3], g)
h = x[0] - x[1] - x[2] - x[3]
hh = "{}-{}-{}-{}={}".format(x[0], x[1], x[2], x[3], h)

for i, j in zip([a, b, d, d, e, f, g, h], [aa, bb, cc, dd, ee, ff, gg, hh]):
    if i == 7:
        print(j)
        break

Submission status: Wrong Answer

Solution code:
abcd = input()
ans_word = []

for i in range(2**3):
    ans = int(abcd[0])
    for j in range(3):
        #print(str(i) + ' ' + str(j))
        if((i>>j)&1 == 1):
            ans += int(abcd[j+1])
        else:
            ans -= int(abcd[j+1])
    #print(ans)
    if(ans == 7):
        for k in range(3):
            ans_word.append(abcd[k])
            if((i>>k)&1 == 1):
                ans_word.append('+')
            else:
                if(k < 2):
                    ans_word.append('-')
        ans_word.append("=7")
        print("".join(ans_word))
        break

Submission status: Wrong Answer

Solution code:
abcd = input()
ans_word = []

for i in range(2**3):
    ans = int(abcd[0])
    for j in range(3):
        #print(str(i) + ' ' + str(j))
        if((i>>j)&1 == 1):
            ans += int(abcd[j+1])
        else:
            ans -= int(abcd[j+1])
    #print(ans)
    if(ans == 7):
        for k in range(3):
            ans_word.append(abcd[k])
            if((i>>k)&1 == 1):
                ans_word.append('+')
            else:
                ans_word.append('-')
        ans_word.append("=7")
        print("".join(ans_word))
        break

Submission status: Wrong Answer

Solution code:
a = [int(i) for i in list(input())]
sym = ["+", "-"]

for i in sym:
    for j in sym:
        for k in sym:
            if i == "+":
                l = a[0] + a[1]
            else:
                l = a[0] - a[1]

            if k == "+":
                r = a[2] + a[3]
            else:
                r = a[2] - a[3]

            if j == "+":
                m = l + r
            else:
                m = l - r

            if m == 7:
                print("{}{}{}{}{}{}{}={}".format(a[0], i, a[1], j, a[2], k, a[3], m))
                exit()

Submission status: Wrong Answer

Solution code:
ABCD = [int(i) for i in input()]

if ABCD[0] + ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] + ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "+" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] + ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "+" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] + ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "+" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

elif ABCD[0] - ABCD[1] - ABCD[2] - ABCD[3] == 7:
    print(str(ABCD[0]) + "-" + str(ABCD[1]) + "-" +
          str(ABCD[2]) + "-" + str(ABCD[3]) + "="+"7")

Submission status: Wrong Answer

Solution code:
A=list(input())
for i in range(4):
  A[i]=int(A[i])

for bit in range(8):
  flag=["+","+","+"]
  for i in range(3):
    if not bit>>(2-i) & 1 :
      A[i+1]=-A[i+1]
      flag[i]="-"
  if sum(A)==7:
    print("{}{}{}{}{}{}{}".format(A[0],flag[0],A[1],flag[1],A[2],flag[2],A[3]))
    exit()
  for i in range(4):
    A[i]=abs(A[i])

Submission status: Wrong Answer

Solution code:
ABCD = list(map(int, list(input())))
op_cnt = len(ABCD) -1
for i in range(2 ** op_cnt):
  ans_str = str(ABCD[0]) 
  ans = ABCD[0]
  op = ["-"]* op_cnt
  for j in range(op_cnt):
    if ((i >> j) & 1):
      op[op_cnt- j - 1] = "+"
  for i, f in enumerate(op):
    if f == "+":
      ans += ABCD[i+1]
      ans_str += "+" + str(ABCD[i+1])
    else:
      ans -= ABCD[i+1]
      ans_str += "-" + str(ABCD[i+1])
  if ans == 7:
    print(ans_str + "=7")

Submission status: Wrong Answer

Solution code:
a=input()
op=list("+-")
flag = False
for i in op:
    for j in op:
        for k in op:
            s = a[0]+i+a[1]+j+a[2]+k+a[3]
            flag = True
            if eval(s) == 7:
                break
        if flag:
            break
    if flag:
        break
print(s+"=7")