Problem:


Score : 300 points

Problem Statement

Sitting in a station waiting room, Joisino is gazing at her train ticket.

The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).

In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.

The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

Constraints

0≤A,B,C,D≤9

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

ABCD

Output

Print the formula you made, including the part =7.

Use the signs + and -.

Do not print a space between a digit and a sign.

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

0 - 2 + 9 - 0 = 7 is also a valid solution.

Sample Input 3

3242

Sample Output 3

3+2+4-2=7



Sample input:
1222


Sample output:
1+2+2+2=7

Submission status: Wrong Answer

Solution code:
n=input()
num=[]
for i in range(4):
    num.append(int(n[i]))
o=["+","+","+"]
op=[1,1,1]
def ans():
    return num[0]+op[0]*num[1]+op[1]*num[2]+op[2]*num[3]
if ans()!=7:
    for i in range(3):
        op[i]=-1
        if ans()==7:
            break
        op[i]=1
if ans()!=7:  
    for i in range(2):
        op[i]=-1
        op[i+1]=-1
        if ans()==7:
            break
        op[i]=1
        op[i+1]=1
if ans()!=7:
    for i in range(3):
        op[i]=-1
for i in range(3):
    if op[i]==-1:
        o[i]="-"
print(n[0]+o[0]+n[1]+o[1]+n[2]+o[2]+n[3]+"=7")

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input())
l = [a+b+c+d, a+b+c-d, a+b-c+d, a+b-c-d, a-b+c+d, a-b+c-d, a-b-c+d, a-b-c-d]

if l.index(7) == 0:
    print(a, '+', b, '+', c, '+', d, '= 7')
elif l.index(7) == 1:
    print(a, '+', b, '+', c, '-', d, '= 7')
elif l.index(7) == 2:
    print(a, '+', b, '-', c, '+', d, '= 7')
elif l.index(7) == 3:
    print(a, '+', b, '-', c, '-', d, '= 7')
elif l.index(7) == 4:
    print(a, '-', b, '+', c, '+', d, '= 7')
elif l.index(7) == 5:
    print(a, '-', b, '+', c, '-', d, '= 7')
elif l.index(7) == 6:
    print(a, '-', b, '-', c, '+', d, '= 7')
elif l.index(7) == 7:
    print(a, '-', b, '-', c, '-', d, '= 7')

Submission status: Wrong Answer

Solution code:
a = list(input())
s = 0
for i in a:
    s += int(i)
print("+".join(a) + "=" + str(s))

Submission status: Wrong Answer

Solution code:
def func(i, x, a):
    global ans
    ans = ''
    if i == 0:
        if x == 7:
            return True
        else:
            return False

    if func(i-1, x+int(a[i-1]), a):
        ans += '+' + a[i-1]
        return True

    if func(i-1, x-int(a[i-1]), a):
        ans += '-' + a[i-1]
        return True

    else:
        return False

if __name__ == '__main__':
    a = input()
    if not a:
        exit()
    n = len(a)
    x = 0
    if func(n, x, a):
        if ans[0] == '+':
            print(ans[1:] + '=7')
        else:
            print(ans + '=7')
    else:
        pass

Submission status: Wrong Answer

Solution code:
def func(i, x, a):
    global ans
    ans = ''
    if i == 0:
        if x == 7:
            return True
        else:
            return False

    if func(i-1, x+int(a[i-1]), a):
        ans += '+' + a[i-1]
        return True

    if func(i-1, x-int(a[i-1]), a):
        ans += '-' + a[i-1]
        return True

    else:
        return False

if __name__ == '__main__':
    a = input()
    n = len(a)
    x = 0
    if func(n, x, a):
        print(ans[1:] + '=7')

Submission status: Wrong Answer

Solution code:
def func(i, x, a):
    global ans
    ans = ''
    if i == 0:
        if x == 7:
            return True
        else:
            return False

    if func(i-1, x+int(a[i-1]), a):
        ans += '+' + a[i-1]
        return True

    if func(i-1, x-int(a[i-1]), a):
        ans += '-' + a[i-1]
        return True

    else:
        return False

if __name__ == '__main__':
    a = input()
    if not a:
        exit()
    n = len(a)
    x = 0
    if func(n, x, a):
        print(ans[1:] + '=7')
    else:
        pass

Submission status: Wrong Answer

Solution code:
def func(i, x, a):
    global ans
    ans = ''
    if i == 0:
        if x == 7:
            return True
        else:
            return False

    if func(i-1, x+int(a[i-1]), a):
        ans += '+' + a[i-1]
        return True

    if func(i-1, x-int(a[i-1]), a):
        ans += '-' + a[i-1]
        return True

    else:
        return False

if __name__ == '__main__':
    a = input()
    n = len(a)
    x = 0
    if func(n, x, a):
        print(ans[1:] + '=7')
    else:
        pass

Submission status: Wrong Answer

Solution code:
a=input()
for i in range(16):
  b=bin(i)[2:]
  b="0"*(4-len(b))+b
  b=b.replace("0","-").replace("1","+")
  xv="".join([d+s for s,d in zip(a,list(b))])
  if xv[0]=="+":xv=xv[1:]
  if eval(xv)==7:
    print(xv,"=7",sep="");break

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(2**3):
  op=format(i,'03b')
  op=op.replace('1','+').replace('0','-')
  st=s[0]+op[0]+s[1]+op[1]+s[2]+op[2]+s[3]
  if eval(st)==7:
    print(st+"=7")

Submission status: Wrong Answer

Solution code:
abcd=list(input())
for i in range(2**3):
    if i%8==0:
        op1="+"
    else:
        op1="-"
    if i%4==0:
        op2="+"
    else:
        op2="-"
    if i%2==0:
        op3="+"
    else:
        op3="-"
    siki=abcd[0]+op1+abcd[1]+op2+abcd[2]+op3+abcd[3]
    if eval(siki)==7:
        siki+="=7"
        break
print(siki)

Submission status: Wrong Answer

Solution code:
n = list(input())
ni = map(int,n)
ns = sorted(ni, reverse=True)
ans = 0
op = []
for i in ns:
    ans += i
    if ans > 7:
        ans -= i
        op += "-"
    else:
        op += "+"
print("%d%s%d%s%d%s%d=7" % (ns[0],op[0],ns[1],op[1],ns[2],op[2],ns[3]))

Submission status: Wrong Answer

Solution code:

n = input()
a = int(n[0])

for i in range(8):
    x = "{0:03b}".format(i)
    s = a
    ss = "{0}".format(a)
    for j in range(3):
        if x[j] == '0':
            s -= int(n[j+1])
            ss += "-{0}".format(int(n[j+1]))
        else:
            s += int(n[j+1])
            ss += "+{0}".format(int(n[j+1]))
    if s == 7:
        break
print(ss)

Submission status: Wrong Answer

Solution code:
ABCD = input()

for i in range(2 ** 3):
    bit = []
    num = i
    for _ in range(3):
        bit.append(num % 2)
        num = num //2
    eq = ""
    for j in range(3):
        eq += ABCD[j]
        if bit[j] == 0:
            eq += "-"
        else:
            eq += "+"
    eq += ABCD[-1]
    if eval(eq) == 7:
        eq += "=7"
        print(eq)

Submission status: Wrong Answer

Solution code:
s = input()

def func(ac,s,op):
  next = s[0]
  if len(s) ==1:
    if ac + next == 7:
      print(str+'+'+s[0]+'=7')
      exit(0)
    if ac - next == 7:
      print(str+'-'+s[0]+'=7')
      exit(0)
  else:
    func(ac+next,s[1:],op+'+'+str(next))
    func(ac-next,s[1:],op+'-'+str(next))

Submission status: Wrong Answer

Solution code:
import re
s = input()

def sum_p(res, i):
    if i == 3:
        res += s[i]
        a = sum(list(map(int, re.split('[+, *]', res))))
        if a == 7:
            res = res.replace("*", "")
            print(res+"=7")
    elif i == 0:
        res1 = res+s[i]+"+"
        sum_p(res1, i+1)
        res2 = res+s[i]+"*"+"-"
        sum_p(res2, i+1)
    else:
        sum_p(res+s[i]+"+", i+1)
        sum_p(res+s[i]+"*"+"-", i+1)

sum_p("", 0)

Submission status: Wrong Answer

Solution code:
s = input()

def sum_p(res, i, ans):
    if i == 3:
        res += s[i]
        a = sum(list(map(int, res.split("+"))))
        if a == 7:
            ans = res
            print(ans+"=7")
    elif i == 0:
        res = res+s[i]+"+"
        sum_p(res, i+1, ans)
        res += "-"
        sum_p(res, i+1, ans)
    else:
        sum_p(res+s[i]+"+", i+1, ans)
        sum_p(res+s[i]+"+"+"-", i+1, ans)

sum_p("", 0, "")

Submission status: Wrong Answer

Solution code:
abcd = input()
bit = 0b1000
ans=int(abcd[0])
op = [-1,-1,-1]
str_bit = bin(bit)

while bit<16:
  for i in range(3,6):
    if str_bit[i]=="1":
      op[i-3]=1
      ans+=int(abcd[i-3])
    else:
      op[i-3]=0
      ans-=int(abcd[i-3])
   
  if ans==7:
    for i in range(len(op)):
      if op[i]==1:
        op[i]="+"
      else:
        op[i]="-"
    print(abcd[0],op[0],abcd[1],op[1],abcd[2],op[2],abcd[3],"=7",sep='')
    exit()
  
  ans=int(abcd[0])
  bit+=1
  str_bit=bin(bit)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = input()
a = [int(s[i]) for i in range(4) ]
total = sum(a)
operand = "+-"
for i in range(3):
    k = i
    is_7 = total
    digit = 1
    while digit <= 3:
        if k % 2: is_7 -= 2*a[digit]
        digit += 1
        k = k // 2
    if is_7 == 7:
        print(s[0]+ operand[i%2] + s[1] + operand[(i//2)%2] + s[2] + operand[(i//4)%2] + s[3]+ "=7")
        break

Submission status: Wrong Answer

Solution code:
nums = input()
n = 4


def calc(i, f, sum):
    if i == n-1:
        print(f+'=7')
        exit()
        return sum == 7

    else:
        calc(i+1, f + '-' + nums[i+1], sum - int(nums[i+1]))

        calc(i+1,  f + '+' + nums[i+1], sum + int(nums[i]))



calc(0, nums[0], int(nums[0]))

Submission status: Wrong Answer

Solution code:
import sys
a,b,c,d=[i for i in 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+i+b+j+c+k+d)
        sys.exit()

Submission status: Wrong Answer

Solution code:
plus = lambda a,b:a+b
minus = lambda a,b:a-b

bit = 0

nums = [int(c) for c in input()]

for bit in range(8):
  op_lst = [(plus if bit >> i & 1 else minus) for i in [2,1,0]]
  temp = nums[0]
  for i in range(len(op_lst)):
    temp = op_lst[i](temp,nums[i+1])
  if temp == 7:
    break

op_strings = {plus:"+",minus:"-"}

s = str(nums[0]) + op_strings[op_lst[0]] + str(nums[1]) + op_strings[op_lst[1]] + str(nums[2]) + op_strings[op_lst[2]] + str(nums[3])

print(s)

Submission status: Wrong Answer

Solution code:
s=input()
def dfs(i,su):
    if i==4:
      return su==7
    if dfs(i+1,su+int(s[i])):
      return True
    if dfs(i+1,su-int(s[i])):
      return True
    return False
print(dfs(1,int(s[0])))

Submission status: Wrong Answer

Solution code:
s = input()
opl = ['+', '-']

flag = [0,0,0]
for i in range(0, 0b111+1):
    for j in range(3):
        #print(i)
        flag[j] = (i>>(j+1) & 1)
        ans = s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3]
        if(eval(ans) == 7):
            print(ans + '=7')
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
s = input()
opl = ['+', '-']

flag = [0,0,0]
for i in range(0, 0b111+1):
    for j in range(3):
        #print(i)
        flag[j] = (i>>(j+1) & 1)
        ans = s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3]
        if(eval(ans) == 7):
            print(ans + '=7', end='')
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:

Submission status: Wrong Answer

Solution code:
s = input()
opl = ['+', '-']

flag = [0,0,0]
for i in range(0, 0b111+1):
    for j in range(3):
        #print(i)
        flag[j] = (i>>(j+1) & 1)
        ans = s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3]
        if(eval(ans) == 7):
            print(s[0] + opl[flag[0]] + s[1] + opl[flag[1]] + s[2] + opl[flag[2]] + s[3])
            break
    else:
        continue
    break

Submission status: Wrong Answer

Solution code:
ABCD = [int(s) for s in list(input())]
operators = ["-", "+"]
for bit in range(1 << 3):
    ops = [(bit >> i) & 1 for i in range(3)]
    tmp = ABCD[0]
    for op, val in zip(ops, ABCD[1:]):
        if op:
            tmp += val
        else:
            tmp -= val
    if tmp == 7:
        print(ABCD[0], end="")
        for op, val in zip(ops, ABCD[1:]):
            print(operators[op], val, sep="", end="")
            print("=7")
        exit()

Submission status: Wrong Answer

Solution code:
ABCD = [int(s) for s in list(input())]
operators = ["-", "+"]
for bit in range(1 << 3):
    ops = [(bit >> i) & 1 for i in range(3)]
    tmp = ABCD[0]
    for op, val in zip(ops, ABCD[1:]):
        if op:
            tmp += val
        else:
            tmp -= val
    if tmp == 7:
        print(ABCD[0], end="")
        for op, val in zip(ops, ABCD[1:]):
            print(operators[op], val, sep="", end="")
        print()
        exit()

Submission status: Wrong Answer

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

S = "%s%s%s%s%s%s%s" % (A,"+",B,"-",C,"-",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"-",B,"+",C,"-",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"-",B,"-",C,"+",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"+",B,"+",C,"-",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"+",B,"-",C,"+",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"-",B,"+",C,"+",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"+",B,"+",C,"+",D)
if eval(S)==7:
    print(S + "=7")
S = "%s%s%s%s%s%s%s" % (A,"-",B,"-",C,"-",D)
if eval(S)==7:
    print(S + "=7")

Submission status: Wrong Answer

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

def dfs( i : int, total : int, formular : str  ):
    if i == n - 1:
        if total == 7:
            print( formular+"=7" )
            exit
    else:
        next = s[ i + 1]
        dfs( i + 1, total + int( next ), formular + "+" + next )
        dfs( i + 1, total -  int( next ), formular + "-" + next )

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

Submission status: Wrong Answer

Solution code:
import sys
S = input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])
list = [int(S[i]) for i in range(4)]
ans=str(S[0])

for bit in range(1 << 3):
    for i in range(1,4):
        if bit & (1 << i):
            list[i] = list[i] * -1
        
        if sum(list) == 7:
            for j in range(1,4):
                if list[j] < 0:
                    ans = ans + "-" + S[j]
                else:
                    ans = ans + "+" + S[j]
            
            print(ans+"=7")
            sys.exit()

Submission status: Wrong Answer

Solution code:
s = input()

def dfs( i, sums, s1 ):
    if i == 3:
        if sums == 7:
             print(s1 + "=7")
             exit()
    else:
        dfs( i + 1, sums + int( s[i+1] ), "{}+{}".format( s1, s[ i  + 1 ] ))
        dfs( i + 1, sums  - int( s[i+1] ), "{} -{}".format( s1, s[ i  + 1 ] ))

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

Submission status: Wrong Answer

Solution code:
s = input()

def dfs( i, sums, s1 ):
    if i == 3:
        if sums == 7:
             print(s1 + "=7")
    else:
        dfs( i + 1, sums + int( s[i+1] ), "{}+{}".format( s1, s[ i  + 1 ] ))
        dfs( i + 1, sums  - int( s[i+1] ), "{} -{}".format( s1, s[ i  + 1 ] ))

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

Submission status: Wrong Answer

Solution code:
s = input()

def dfs( i, sums, s1 ):
    if i == 3:
        if sums == 7:
            print(s1)
            return s1
    else:
        dfs( i + 1, sums + int( s[i+1] ), "{}+{}".format( s1, s[ i  + 1 ] ))
        dfs( i + 1, sums  - int( s[i+1] ), "{} -{}".format( s1, s[ i  + 1 ] ))

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

A, B, C, D = map(int, list(input()[:-1]))

n = 3
ops = []
for bit in range(0, 1<<n):
    op = ["-"]*n
    for j in range(n):
        if bit>>j & 1:
            op[j] = "+"
    ops.append(op)

for op in ops:
    a, b, c, d = A, B, C, D
    if op[0] == "-":
        b = -B
    if op[1] == "-":
        c = -C
    if op[2] == "-":
        d = -D
    if a + b + c + d == 7:
        ans = op
        break
ans = str(a)
for num in (b, c, d):
    if num > 0:
        ans += "+"
        ans += str(num)
    else:
        ans += str(num)
ans += "=7"
print(ans)

Submission status: Wrong Answer

Solution code:
s = [int(x) for x in input()]
insert_operator_number = len(s) - 1

for iter_op in range(1 << insert_operator_number):
  result_sum = s[0]
  result_string = ""
  for i in range(insert_operator_number):
    if (iter_op & (1 << i)):
      result_sum += s[i+1]
      result_string += "{}+".format(s[i])
    else:
      result_sum -= s[i+1]
      result_string += "{}-".format(s[i])
    
    if result_sum == 7:
      break

print("{}{}=7".format(result_string,s[-1]))

Submission status: Wrong Answer

Solution code:
#79-C:DFS

def dfs(i,f,f_sum):
    if i==3:
        if f_sum==7:
            print(f+'=7')
    else:
        dfs(i+1,f+'+'+s[i+1],f_sum+int(s[i+1]))
        dfs(i+1,f+'-'+s[i+1],f_sum-int(s[i+1]))

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

Submission status: Wrong Answer

Solution code:
s = str(input())

n = len(s) - 1

for i in range(1 << n):
    f = ""
    f += s[0]

    for j in range(n):

        if 1 & (i >> j):

            f += "+"
            f += s[j + 1]
        else :

            f += "-"
            f += s[j + 1]

    print(eval(f))

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(8):
    h=s[0]
    ans=int(s[0])
    for j in range(3):
        if i>>j&1:
            ans+=int(s[j+1])
            h+='+'+s[j+1]
        else:
            ans-=int(s[j+1])
            h+='-'+s[j+1]
    if ans==7:
        print(h+'=7')

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(8):
    ans=s[0]
    cnt=int(s[0])
    for j in range(3):
        if (i>>j) & 1:
            ans+="+"+s[j+1]
            cnt+=int(s[j+1])
        else:
            ans+="-"+s[j+1]
            cnt-=int(s[j+1])
    if cnt==7:
        print(ans+"+=7")
        exit()

Submission status: Wrong Answer

Solution code:

s=input()
for i in range(8):
    ans=s[0]
    cnt=int(s[0])
    for j in range(3):
        if i>>j & 1:
            ans+="+"+s[j+1]
            cnt+=int(s[j+1])
        else:
            ans+="-"+s[j+1]
            cnt-=int(s[j+1])
    if cnt==7:
        print(ans+"+=7")
        exit()

Submission status: Wrong Answer

Solution code:
s=input()
for i in range(8):
    ans=s[0]
    cnt=int(s[0])
    for j in range(3):
        if i>>j & 1:
            ans+="+"+s[j+1]
            cnt+=int(s[j+1])
        else:
            ans+="-"+s[j+1]
    if cnt==7:
        print(ans+"+=7")

Submission status: Wrong Answer

Solution code:
import itertools
num = str(input())
sign = ("+", "-")
for s1, s2, s3 in itertools.product(sign, repeat=3):
    result = num[0] + s1 + num[1] + s2 + num[2] + s3 + num[3]
    if eval(result) == 7:
        print(result)
        break

Submission status: Wrong Answer

Solution code:
a=list(input())
import copy
for i in range(2**3):
    b=[]
    c=copy.deepcopy(a)
    for j in range(3):
        if (i>>j)&1:
            b.append("+")
        else:
            b.append('-')
    c.insert(1,b[0])
    c.insert(3,b[1])
    c.insert(5,b[2])
    c=''.join(c)
    if eval(c)==7:
        print(c+"=7")

Submission status: Wrong Answer

Solution code:
import sys
s = input()

for i in range(8):
    bit = bin(i)[2:].zfill(3)
    string = s[0]
    flag = int(s[0])

    for j,k in enumerate(bit):
        if k == '0':
            string += '+' + s[j+1]
            flag += int(s[j+1])
        else:
            string += '-' + s[j+1]
            flag -= int(s[j+1])

        if flag == 7:
            print(string + '=7')
            sys.exit()

Submission status: Wrong Answer

Solution code:
n=input()
a=n[0]
b=n[1]
c=n[2]
d=n[3]
e="=7"


for i in ["+","-","*","/"]:
    if i !="/" or i =="/" and int(b)!=0:
        for j in ["+","-","*","/"]:
            if j=="/" and int(c)==0:
                break
            for k in ["+","-","*","/"]:
                if k=="/" and int(d)==0:
                    break
                if eval(a+i+b+j+c+k+d)==7:
                    print(a+i+b+j+c+k+d+e)
                    exit()

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:
import sys

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


for i in range(2**(len(S)-1)):
    op_list = ['+']*(len(S)-1)
    for j in range(len(S)-1):

        if (i>>j)&1:
            op_list[j]='-'
    s = ""
    for j in range(len(S)-1):
        s = s + S[j] + op_list[j]

    s = s + S[len(S)-1]

    if 7==eval(s):
        print(s,"=7", sep="")

Submission status: Wrong Answer

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


for i in range(2**(len(S)-1)):
    op_list = ['+']*(len(S)-1)
    for j in range(len(S)-1):

        if (i>>j)&1:
            op_list[j]='-'
    s = ""
    for j in range(len(S)-1):
        s = s + S[j] + op_list[j]

    s = s + S[len(S)-1]

    if 7==eval(s):
        print(s,"=7", sep="")

Submission status: Wrong Answer

Solution code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(map(int,list(input())))
li = [1,-1]

for i in range(1<<3):
    ans = s[0]
    for j in range(1,4):
        if i>>(j-1)&1:
            ans += s[j]
        else:
            ans -= s[j]
    print(bin(i),ans)
    if ans == 7:
        print(s[0],end="")
        for j in range(1,4):
            if i>>(j-1)&1:
                print("+",end="")
                print(s[j],end="")
            else:
                print("-",end="")
                print(s[j],end="")
        print("=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])

for i in range(-1,2,2):
    for j in range(-1,2,2):
        for k in range(-1,2,2):
            if i ==-1:
                a_b='-'
            else:
                a_b='+'
            if j ==-1:
                b_c='-'
            else:
                b_c='+'
            if k==-1:
                c_d='-'
            else:
                c_d='+'
            t=a+i*b+j*c+k*d
            if t==7:
                print(str(a)+a_b+str(b)+b_c+str(c)+c_d+str(d)+'==7')
            break

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1<<3):
  f = s[0]
  
  for i in range(1,4):
    if bit & (1<<i):
      f += "+"
    else:
      f += "-"
      
    f += s[i]
    
  if eval(f) == 7:
    print("{}=7".format(f))
    exit()

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += '+'
        else:
            ans -= int(s[i - 1])
            f += '-'
        f += s[i + 1]

    if ans == 7:
        print(f + '=7')
        exit()

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1 << 3):
    ans = int(s[0])
    f = s[0]

    for i in range(3):
        if bit & (1 << i):
            ans += int(s[i + 1])
            f += '+'
        else:
            ans -= int(s[i - 1])
            f += '-'
        f += s[i + 1]

    if ans == 7:
        print(f + '=7')
        break

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

def printFormula(x):
    print(nums[0], end = "")
    for i in range(len(nums) - 1):
        if x & (1 << i):
            print("+", end = "")
        else:
            print("-", end = "")
        print(nums[i + 1], end = "")
    print("=7")
        


str1 = input()
nums = []
for i in range(len(str1)):
    nums.append(int(str1[i]))
    
ope = []
for i in range(1 << (len(str1) - 1)):
    sum_num = nums[0]
    
    for j in range(len(str1) - 1):
        if i & (1 << j):
            sum_num += nums[1 + j]
        else:
            sum_num -= nums[1 + j]
        
    if sum_num == 7:
        printFormula(i)

Submission status: Wrong Answer

Solution code:
S = input()
n = 3

for i in range(1<<n):
    tmp = int(S[0])
    ans = S[0]
    for j in range(n):
        if i & (1<<j):
            tmp += int(S[j+1])
            ans += "+"
        else:
            tmp -= int(S[j+1])
            ans += "-"
        ans += S[j+1]
    if tmp == 7:
        ans += "=7"
        print(ans)

Submission status: Wrong Answer

Solution code:
import sys

E = list(input())

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

sum = 0
for i in range(2**3):

    op_list = ['-', '-', '-']
    sum1 = 0
    for j in range(len(E)):
        if (i>>j) & 1:
            op_list[j]  = '+'
    sum = eval(E[0]+op_list[0]+E[1]+op_list[1]+E[2]+op_list[2]+E[3])

    if sum==7:
        print(A,op_list[0],B,op_list[1],C,op_list[2],D)
        sys.exit()

Submission status: Wrong Answer

Solution code:
l=input()
a=int(l[0])
b=int(l[1])
c=int(l[2])
d=int(l[3])
for i in range(2**3):
  s=0
  lis=[]
  for j in range(3):
    if (i>>(2-j)&1)!=1:
      if j==0:
        s+=a-b
        x='-'
      elif j==1:
        s-=c
        y='-'
      else:
        s-=d
        z='-'
    else:
      if j==0:
        s+=a+b
        x='+'
      elif j==1:
        s+=c
        y='+'
      else:
        s+=d
        z='+'
  if s==7:
    print(s)
    print(str(a)+x+str(b)+y+str(c)+z+str(d)+'=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])
for i in range(2*3):
  s=0
  for j in range(3):
    if (i>>(2-j))==0:
      if j==0:
        s+=a-b
        x='-'
      elif j==1:
        s-=c
        y='-'
      else:
        s-=d
        z='-'
    else:
      if j==0:
        s+=a+b
        x='+'
      elif j==1:
        s+=c
        y='+'
      else:
        s+=d
        z='+'
  if s==7:
    print(str(a)+x+str(b)+y+str(c)+z+str(d)+'=7')
    exit()

Submission status: Wrong Answer

Solution code:
def dfs(i, f, Sum):
    if i == n-1:
        if Sum == 7:
            print(f+"=7")
    else:
        dfs(i+1, f+"+"+a[i+1], Sum + int(a[i+1]))
        dfs(i+1, f+"-"+a[i+1], Sum - int(a[i+1]))
        

a = input()
n = len(a)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a = input()
input_list = []
for k in a:
    input_list.append(int(k))
n=3
bag = []
fomul_list = []
for i in range(2 ** n):
    sum = input_list[0]
    fomul = str(input_list[0])
    for j in range(3):
        if (i >> j)&1:
            sum += input_list[j+1]
            fomul = fomul + "+" + str(input_list[j+1])
        else:
            sum -= input_list[j+1]
            fomul = fomul + "-" + str(input_list[j+1])
    bag.append(sum)
    fomul_list.append(fomul)
print(fomul_list[bag.index(7)])

Submission status: Wrong Answer

Solution code:
S = input()

op = ["+","-"]

for a in op:
  for b in op:
    for c in op:
      shiki = S[0]+a+S[1]+b+S[2]+c+S[3]+"==7"
      if eval(shiki):
        print(shiki)
        exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n=[int(i) for i in list(input())]
op=[1,-1]
ans=[]
for op1 in op:
	for op2 in op:
		for op3 in op:
			if n[0]+op1*n[1]+op2*n[2]+op3*n[3]==7:
				ans=[op1,op2,op3]
out=''
for i in range(3):
	out+=str(n[i])
	out+='+' if ans[i]==1 else '-'
print(out+str(n[3]))

Submission status: Wrong Answer

Solution code:
A = list(input())

for i in range(2**3):
    num = int(A[0])
    ans = A[0]
    for j in range(3):
        if ((i >> j)&1):
           num += int(A[j+1])
           ans += "+"+A[j+1]
        else:
           num -= int(A[j+1])
           ans += "-"+A[j+1]
    if num == 7:
        print(ans)
        break

Submission status: Wrong Answer

Solution code:
N = list(map(str,input()))
n = 3

for i in range(8):
    PlusMinus = ["-"] * 3
    for j in range(3):
        if ((i >> j) & 1):
            PlusMinus[n - j - 1] = "+"
    if eval(N[0] + PlusMinus[0] + N[1] + PlusMinus[1] + N[2] + PlusMinus[2] + N[3]) == 7:
        print(N[0] + PlusMinus[0] + N[1] + PlusMinus[1] + N[2] + PlusMinus[2] + N[3] + "=7")

Submission status: Wrong Answer

Solution code:
import sys
num = [int(x) for x in input()]
sign = ["-","+"]
ans = str(num[0])
for x in range(2 ** (len(num)-1)):
  sum = num[0]
  for i in range(len(num) - 1):
    if ((x >> (2-i)) & 1) == 1:
      sum += num[i+1]
    else:
      sum -= num[i+1]
  if sum == 7:
    for i in range(len(num) - 1):
      ans = "{}{}{}".format(ans,sign[(x >> (2 - i)) & 1],num[i+1])
    print(ans)
    sys.exit()

Submission status: Wrong Answer

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

for i in range(len(num) ** 2):
  op = []
  for j in range(len(num)):
    if (i >> j) & 1:
      op.append("+")
    else:
      op.append("-")
  sum = num[0]
  for k in range(1,len(num)):
    if op[k] == "+":
      sum += num[k]
    elif op[k] == "-":
      sum -= num[k]
  if sum == 7:
    print("{}{}{}{}{}{}{}=7".format(num[0],op[0],num[1],op[1],num[2],op[2],num[3]))
    break

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    abcd = tuple(map(int, args[0]))
    ret = str(abcd[0])
    for p in range(2**3):
        tmp = abcd[0]
        for i in range(3):
            if p >> i & 1:
                tmp += abcd[i+1]
            else:
                tmp -= abcd[i+1]
        if tmp == 7:
            op = '{:03b}'.format(p).replace('0', '-').replace('1', '+')[::-1]
            for i in range(3):
                ret += '{}{}'.format(op[i], abcd[i+1])
            ret += '=7'
            break
    print(ret)
    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    abcd = tuple(map(int, args[0]))
    ret = str(abcd[0])
    for p in range(2**3):
        tmp = abcd[0]
        for i in range(3):
            if p >> i & 1:
                tmp += abcd[i+1]
            else:
                tmp -= abcd[i+1]
        if tmp == 7:
            op = '{:03b}'.format(p).replace('0', '-').replace('1', '+')
            for i in reversed(range(3)):
                ret += '{}{}'.format(op[i], abcd[i+1])
            ret += '=7'
            break

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Wrong Answer

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    abcd = tuple(map(int, args[0]))
    ret = str(abcd[0])
    for p in range(2**4):
        tmp = abcd[0]
        for i in range(3):
            if p >> i & 1:
                tmp += abcd[i+1]
            else:
                tmp -= abcd[i+1]
        if tmp == 7:
            op = '{:03b}'.format(p).replace('0', '-').replace('1', '+')
            for i in range(3):
                ret += '{}{}'.format(op[i], abcd[i+1])
            ret += '=7'
            break

    return ret


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))