Problem:


Score : 300 points

Problem Statement

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

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

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

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

Constraints

0≤A,B,C,D≤9

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

ABCD

Output

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

Use the signs + and -.

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

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

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

Sample Input 3

3242

Sample Output 3

3+2+4-2=7



Sample input:
1222


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

Submission status: Wrong Answer

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

if a+b+c+d==7:
  print('a+b+c+d=7')
elif a-b+c+d==7:
  print('a-b+c+d=7')
elif a-b-c+d==7:
  print('a-b-c+d=7')
elif a-b+c-d==7:
  print('a-b+c-d=7')
elif a-b-c-d==7:
  print('a-b-c-d=7')
elif a+b-c+d==7:
  print('a+b-c+d=7')
elif a+b-c-d==7:
  print('a+b-c-d=7')
else:
  print('a+b+c-d=7')

Submission status: Wrong Answer

Solution code:
A,B,C,D=input()
digits=3
op=[""]*digits
for i in range(1<<digits):
    for j in range(digits):
        if (i>>j)&1:
            op[j]="+"
        else:
            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)
        break

Submission status: Wrong Answer

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

for i in range(2**3):
  tmp = A[0]
  for j in range(3):
    if (i >> j) & 1:
      tmp += A[j+1]
    else:
      tmp -= A[j+1]
  if tmp == 7:
    ops = [S[j] + ['-','+'][(i >> j) & 1] for j in range(3)]
    print(''.join(ops) + S[3] + '=7')
    #exit()

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")
        exit

Submission status: Wrong Answer

Solution code:
def dfs(i,f,ans):
  if i<3:
    dfs(i+1,f+"+"+s[i+1],ans+int(s[i+1]))
    dfs(i+1,f+"-"+s[i+1],ans-int(s[i+1]))
  elif ans==7:
    print(f+"=7")
s=input()
dfs(0,s[0],int(s[0]))

Submission status: Wrong Answer

Solution code:
s = input()
ls = [int(i) for i in s]
n = len(ls)
i = 1
ans = ls[0]

def dfs(i, s, ans):
    if i==n:
        print(i, 'floor', s, ans)
        return ans==7, s, ans
    else:
        #print(i, 'left', s, ans)
        p = i + s.count('+') + s.count('-')
        s_temp = s[:p]+'-'+s[p:]
        ans_temp = ans - ls[i]
        tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
        if tf:
            return True, s_temp, ans_temp
        else:
            #print(i, 'right', s, ans)
            p = i + s.count('+') + s.count('-')
            s_temp = s[:p]+'+'+s[p:]
            ans_temp = ans + ls[i]
            tf, s_temp, ans_temp = dfs(i+1, s_temp, ans_temp)
            return tf, s_temp, ans_temp
            

tf, s, ans = dfs(1, s, ans)
print(s+'=7')

Submission status: Wrong Answer

Solution code:
def dfs(array: list, index: int, calc: str, result: int):
    if index == len(array):
        if result == 7:
            S = "{}=7".format(calc)
            return S

    if index == 0:
        dfs(array, index + 1, array[index], int(array[index]))
    elif index < len(array):
        dfs(array, index + 1, calc + "-" + array[index], result - int(array[index]))
        dfs(array, index + 1, calc + "+" + array[index], result + int(array[index]))

array = list(input())
S = dfs(array, 0, "", 0)
print(S)

Submission status: Wrong Answer

Solution code:
def dfs(array: list, index: int, calc: str, result: int):
    if index == len(array):
        if result == 7:
            return print("{}=7".format(calc))
            exit(0)

    if index == 0:
        dfs(array, index + 1, array[index], int(array[index]))
    elif index < len(array):
        dfs(array, index + 1, calc + "-" + array[index], result - int(array[index]))
        dfs(array, index + 1, calc + "+" + array[index], result + int(array[index]))

array = list(input())
dfs(array, 0, "", 0)

Submission status: Wrong Answer

Solution code:
from sys import stdin 

ABCD = stdin.readline().rstrip()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

def func1(ABCD,k):
    if k==len(ABCD)-1:
        return [[ABCD[k]],["-"+ABCD[k]]]
    prev_output = func1(ABCD,k+1)
    output = []
    if k==0:
        for ele in prev_output:
            temp = [ABCD[k]]
            temp.extend(ele)
            output.append(temp)
        return output

    for ele in prev_output:
        temp = [ABCD[k]]
        temp.extend(ele)
        output.append(temp)

        temp = ["-"+ABCD[k]]
        temp.extend(ele)
        output.append(temp)
    return output

def search_combi(combinations):
    for combi in combinations:
        tot_sum = 0
        for ele in combi:
            tot_sum+=int(ele)
        if tot_sum==7:
            return combi

combinations = func1(ABCD,0)
#print("search_copmbi:",search_combi(combinations))
def make_answer(numbers):
    output_string=""
    for i,num in enumerate(numbers):
        num_int = int(num)
        if i==0:
            output_string += num
        else:
            if num_int<0:
                output_string += "-"+num[1]
            else:
                output_string += "+"+num
    return output_string


print(make_answer(search_combi(combinations)))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = input()
m = len(n)-1
for i in range(2 ** m):
    ops = []
    N = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
    for j in range(m):
        if (i >> j) & 1:
            ops.append("+")
        else:
            N[j + 1] *= -1
            ops.append("-")
    if sum(N) == 7:
        print(N)
        print(n[0]+ops[0]+n[1]+ops[1]+n[2]+ops[2]+n[3]+"=7")
        break

Submission status: Wrong Answer

Solution code:
*A, = list(input())
s = ['+', '-']
for i in range(2**3):
    formula = A[0]
    for j in range(3):
        if i >> j & 1:
            formula += s[0]
        else:
            formula += s[1]
        formula += A[j+1]
    if eval(formula) == 7:
        print(formula)
        exit()

Submission status: Wrong Answer

Solution code:
s=input()
s=list(s)
n=len(s)
n-=1
o=[]
for i in range(2**n):
    op = [0]*n
    for j in range(n):
        if ((i>>j)&1):
            op[n-1-j]=1
    o.append(op)

ans=''
for oo in o:
    t=[]
    tmp=0
    t.append(s[0])
    tmp=int(s[0])
    for i,ooo in enumerate(oo):
        if ooo==0:
            t.append('+')
            tmp+=int(s[i+1])
                   
        else:
            t.append('-')
            tmp-=int(s[i+1])
        t.append(s[i+1])
        if tmp==7:
            t.append('=7')
            print(''.join(t))
            exit(0)

Submission status: Wrong Answer

Solution code:
x = input()
p = ['+','-']
def cal(a,b,c,x):
    res = int(x[0])
    if a:res-=int(x[1])
    else:res+=int(x[1])
    if b:res-=int(x[2])
    else:res+=int(x[2])
    if c:res-=int(x[3])
    else:res+=int(x[3])
    if res == 7:
        return True
    else:return False
    
        
for i in range(2):
    for j in range(2):
        for k in range(2):
            if cal(i,j,k,x):
                print(x[0]+p[i]+x[1]+p[j]+x[2]+p[k]+x[3]+'=7')
                break

Submission status: Wrong Answer

Solution code:
n = input()
op = [bin(i)[2:].zfill(3) for i in range(8)]
ans = [n[0]]
for i in range(8):
    cnt = int(n[0])
    for j in range(3):
        if op[i][j] == "0":
            cnt += int(n[j+1])
            ans.append("+")
        else:
            cnt -= int(n[j+1])
            ans.append("-")
        ans.append(n[j+1])
    if cnt == 7:
        ans += ["=", "7"]
        print("".join(ans))
        exit()

Submission status: Wrong Answer

Solution code:
s = list(str(input()))

for i in range(2**3):
    t = ['']
    ans = int(s[0])
    for j in range(3):
        if (i >> j) & 1:
            t.append('+')
            ans += int(s[j+1])
        else:
            t.append('-')
            ans -= int(s[j+1])
    if ans == 7:
        siki = ''
        for i in range(4):
            siki += t[i]+s[i]
        siki += '=7'
        print(siki)

Submission status: Wrong Answer

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

def calc(x, y, sym):
    if sym == 0:
        return x + y
    else:
        return x - y

def symbol(sym):
    if sym == 0:
        return '+'
    else:
        return '-'

for i in range(2):
    for j in range(2):
        for k in range(2):
            tmp = calc(a[0], a[1], i)
            tmp = calc(tmp, a[2], j)
            tmp = calc(tmp, a[3], k)
            if tmp == 7:
                b = list(map(symbol, [i, j, k]))
                print("{}{}{}{}{}{}{}=7".format(a[0], b[0], a[1], b[1], a[2], b[2], a[3]))
                break

Submission status: Wrong Answer

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

for i in range(1<<n):
    sum=0
    st=''
    for j in range(n):

        if i & (1 <<j):sum +=int(a[j]); st+= '+' + a[j] 
        else: st+= '-' + a[j]

    if sum==7:break

print(st[1:] + '=7')

Submission status: Wrong Answer

Solution code:
l=input()
num=[int(l[i]) for i in range(4)]
pm=['+','-']
for i in pm:
  a,b,c,d=num[0],num[1],num[2],num[3]
  for j in pm:
    for k in pm:
      if i=='-':
        b=b*(-1)
      if j=='-':
        c=c*(-1)
      if k=='-':
        d==d*(-1)
      if a+b+c+d==7:
        print(str(a)+i+str(abs(b))+j+str(abs(c))+k+str(abs(d))+'='+'7')
        exit()

Submission status: Wrong Answer

Solution code:
s = list(input())
import sys
def bitlist(n, a, b):
  res = []
  for i in range(2**n):
    pattern = []
    for j in range(n):
      if (i >> j) & 1:
        pattern.insert(0, a)
      else:
        pattern.insert(0, b)
    res.append(pattern)
  return res

n = len(s)
lst = bitlist(n-1, "+", "-")
for i in range(2**(n-1)):
  calc = s[0]
  for j in range(n-1):
    calc += lst[i][j] + s[j+1]
  if eval(calc) == 7:
    calc += "=7"
    print(calc)

Submission status: Wrong Answer

Solution code:
import re
s = input()

def dfs(i,f):
  
  if i == len(s)-1:
    ans = sum(list(map(int, re.split('[+]',f))))
    f = f.replace('+-','-')
    
    if ans == 7:
      print(f + '=7')
      exit()
    
  else:
    dfs(i+1, f + s[i+1:i+2])
    dfs(i+1, f + '+' + s[i+1:i+2])
    dfs(i+1, f + '+-' + s[i+1:i+2])
      
dfs(0,s[0])

Submission status: Wrong Answer

Solution code:
s = input()


def dfs(i,f):
  
  if i == len(s)-1:
    ans = sum(list(map(int, f.split('+'))))
    if ans == 7:
      print(f + '=7')
    
  else:
    dfs(i+1, f + s[i+1:i+2])
    dfs(i+1, f + '+' + s[i+1:i+2])
      

dfs(0,s[0])

Submission status: Wrong Answer

Solution code:
k=input()
a=int(k[0])%7
b=int(k[1])%7
c=int(k[2])%7
d=int(k[3])%7
if (a+b+c+d)%7==0:print(k[0]+'+'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a-b+c+d)%7==0:print(k[0]+'-'+k[1]+'+'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c+d)%7==0:print(k[0]+'+'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b+c-d)%7==0:print(k[0]+'+'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c+d)%7==0:print(k[0]+'-'+k[1]+'-'+k[2]+'+'+k[3]+'='+'7')
elif (a+b-c-d)%7==0:print(k[0]+'+'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')
elif (a-b+c-d)%7==0:print(k[0]+'-'+k[1]+'+'+k[2]+'-'+k[3]+'='+'7')
elif (a-b-c-d)%7==0:print(k[0]+'-'+k[1]+'-'+k[2]+'-'+k[3]+'='+'7')

Submission status: Wrong Answer

Solution code:
s = input()
A, B, C, D = int(s[0]), int(s[1]), int(s[2]), int(s[3])
print(A,B,C,D)
N = 3


for i in range(2**N):
    sum = int(s[0])
    f = s[0]
    for j in range(N):
        if i>>j & 1:
            sum += int(s[j+1])
            f += "+" + s[j+1]
        else:
            sum -= int(s[j+1])
            f += "-" + s[j+1]

    if sum == 7:
        print(f + "=7")
        break

Submission status: Wrong Answer

Solution code:
s=input()

for bit in range(1 << 3):#
    ans=int(s[0])
    f=s[0]
    
    for j in range(3):
        if bit & (1 << j):
            ans+=int(s[j+1])
            f+='+'
        else:
            ans-=int(s[j+1])
            f+='-'
        
        f+=s[j+1]
    
    if ans == 7:
        print(f + "=7")

Submission status: Wrong Answer

Solution code:
s=input()
item=["+","-"]
 
last = ""
for op1 in item:
  for op2 in item:
    for op3 in item:
      ans = s[0] + op1 + s[1] + op2 + s[2] + op3 +s[3]
      if eval(ans)==7:
        last = ans
print(last)

Submission status: Wrong Answer

Solution code:
s=input()
item=["+","-"]

for op1 in item:
  for op2 in item:
    for op3 in item:
      ans = s[0] + op1 + s[1] + op2 + s[2] + op3 +s[3]
      if eval(ans)==7:
        print(ans+"=7")
        break

Submission status: Wrong Answer

Solution code:
s=int(input())
s=list(map(str,str(s)))
l=len(s)-1

for i in range(2**l):
    listA=['+']*len(s)
    for j in range(l):
        if ((i>>j)&1):
            listA[j]='-'
    listB=[]
    for o,p in zip(s,listA):
        listB.append(o)
        listB.append(p)
    del listB[-1]
    listC=''.join(listB)
    ans=eval(listC)
    if ans==7:
        print('{}=7'.format(listC))
        break

Submission status: Wrong Answer

Solution code:
import sys
import os

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    *S, = iss()
    print(S)
    E = ['+', '-']
    tmp = [0] * 7
    for e in E:
        tmp[0] = S[0]
        tmp[1] = e
        for e in E:
            tmp[2] = S[1]
            tmp[3] = e
            for e in E:
                tmp[4] = S[2]
                tmp[5] = e
                tmp[6] = S[3]
                ans = ''.join(map(str, tmp))
                if eval(ans) == 7:
                    print(ans + '=7')
                    exit()


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys

n = input()

code_1 = ['+', '-']
code_2 = ['+', '-']
code_3 = ['+', '-']

answer = ''
flag = False
for i in range(2):
    for j in range(2):
        for k in range(2):
            sum_num = 0
            if code_1[i] == '+':
                sum_num += int(n[0]) + int(n[1])
            else:
                sum_num += int(n[0]) - int(n[1])
            if code_2[j] == '+':
                sum_num += int(n[2])
            else:
                sum_num -= int(n[2])
            if code_3[k] == '+':
                sum_num += int(n[3])
            else:
                sum_num -= int(n[3])
            if sum_num == 7:
                answer = n[0] + code_1[i] + n[1] + code_2[j] + n[2] + code_3[k] + n[3]
                flag = True
            if flag:
                break

        if flag:
            break
    
    if flag:
        break


print(answer)

Submission status: Wrong Answer

Solution code:
S = input()
 
n = len(S)
S_list = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]
 
#1... -  0...+
def bit_to_notation(bit):
  bitlist = [0 for i in range(n-1)] 
  for i in range(n-1):
    if ((bit >> i) == 1):
      bitlist[n-2-i] = "-"
    else:
      bitlist[n-2-i] = "+"
  return bitlist
 
notation = 2 ** (n-1)
for bit in range(notation):
  sum4 = 0
  for j in range(n):
    if((bit >> j) & 1):
      sum4 -= S_list[n-1-j]
    else:
      sum4 += S_list[n-1-j]
      
  if(sum4 == 7):
    
    bitlist = bit_to_notation(bit)
    print(str(S_list[0]) + bitlist[0] + str(S_list[1]) + bitlist[1] 
          + str(S_list[2]) + bitlist[2]  + str(S_list[3]) + "=7")
    break

Submission status: Wrong Answer

Solution code:
S = input()

n = len(S)
S_list = [int(S[0]), int(S[1]), int(S[2]), int(S[3])]

#1... -  0...+
def bit_to_notation(bit):
  bitlist = [0 for i in range(n-1)] 
  for i in range(n-1):
    if ((bit >> i) == 1):
      bitlist[n-2-i] = "-"
    else:
      bitlist[n-2-i] = "+"
  return bitlist

notation = 2 ** (n-1)
for bit in range(notation):
  sum4 = 0
  for j in range(n):
    if((bit >> j) & 1):
      sum4 -= S_list[n-1-j]
    else:
      sum4 += S_list[n-1-j]
      
  if(sum4 == 7):
    
    bitlist = bit_to_notation(bit)
    print(str(S_list[0]) + bitlist[0] + str(S_list[1]) + bitlist[1] 
          + str(S_list[2]) + bitlist[2]  + str(S_list[3]))
    break

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, input())
pm = [1, -1]
op = ["+", "-"]
for i in range(2):
  for j in range(2):
    for k in range(2):
      if a + pm[i]*b + pm[j]*c + pm[k]*d == 7:
        ans = [op[i], op[j], op[k]]
        break
print("".join(map(str, [a, ans[0], b, ans[1], c, ans[2], d])))

Submission status: Wrong Answer

Solution code:
A = list(map(int,input())) #リストにしておけば入力変わっても対応できるので
#print(A)
n = len(A) - 1
for i in range(2**n):
    pattern = ['-']*n #さきにーの配列にしておく＞条件満たしたら＋に
    ans= A[0]
    #print("num {} :".format(i), end = "" )
    for j in range(n):
        if ((i >> j) & 1):
            pattern[n-j-1]='+'  #pattern[j]だと，bitが逆から始まる
            ans+=A[j+1]
        else:
            #pattern.append('-0')
            ans-=A[j+1]

    else:
        if ans == 7:
            print(A[0], end='')
            for k in range(n):
                print(pattern[k],end='')
                print(A[k+1],end='')
            else:
                print('=7')
            break

Submission status: Wrong Answer

Solution code:
A = list(map(int,input())) #リストにしておけば入力変わっても対応できるので
#print(A)
n = len(A) - 1
for i in range(2**n):
    pattern = ['-']*n #さきにーの配列にしておく＞条件満たしたら＋に
    ans= A[0]
    #print("num {} :".format(i), end = "" )
    for j in range(n):
        if ((i >> j) & 1):
            pattern[n-j-1]='+'  #pattern[j]だと，bitが逆から始まる
            ans+=A[j+1]
        else:
            #pattern.append('-0')
            ans-=A[j+1]

    # = 7 check
    if ans == 7:
        print(A[0], end='')
        for k in range(n):
            print(pattern[k],end='')
            print(A[k+1],end='')

        print('=7')
        break

Submission status: Wrong Answer

Solution code:
import sys
s=input()
a=[int(s[i]) for i in range(4)]
for b in [a[1],-a[1]]:
    for c in[a[2],-a[2]]:
        for d in [a[3],-a[3]]:
            if a[0]+b+c+d==7:
                s=str(a[0])
                for x in [b,c,d]:
                    s+="+"+str(x) if x>0 else str(x)
                s+="=7"
                print(s)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys
s=input()
a=[int(s[i]) for i in range(4)]
p=[[a[1],"+"],[-a[1],"-"]]
q=[[a[2],"+"],[-a[2],"-"]]
r=[[a[3],"+"],[-a[3],"-"]]
for b,tb in p:
    for c,tc in q:
        for d,td in r:
            if a[0]+b+c+d==7:
                print(a[0],tb,b,tc,c,td,d,"=7");sys.exit()

Submission status: Wrong Answer

Solution code:
num = input()

#print(num)
flag = "loop"
op_list = ["+","-"]
for i in op_list:
  if flag == "break":
    break
  for j in op_list:
    if flag == "break":
      break
    for k in op_list:
      if i == "+":
        ans = int(num[0]) + int(num[1])
      else:
        ans = int(num[0]) - int(num[1])
      if i == "+":
        ans += int(num[2])
      else:
        ans -= int(num[2])
      if i == "+":
        ans += int(num[3])
      else:
        ans -= int(num[3])
      if ans == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        flag = "break"
        break

Submission status: Wrong Answer

Solution code:
abcd = str(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):
            tmp = a + sign[i] + b + sign[j] + c + sign[k] + d  
            if eval(tmp) == 7:
                print(tmp+'=7')

Submission status: Wrong Answer

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

res = []
for i in range(2**4):
    s = S[0]
    c = []
    for j in range(3):
        m = i >> j & 1
        if m == 0:
            s = s + S[j+1]* -1
            c.append("-")
        else:
            s = s + S[j+1]
            c.append("+")

    if s == 7:
        print(str(S[0])+""+c[0]+""+str(S[1])+""+c[1]+""+str(S[2])+""+c[2]+str(S[3]))
        break

Submission status: Wrong Answer

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

for i in range(1 << 3):
    op = [None] * 3
    a = A
    b = B if (i >> 0) & 1 else -B
    op[0] = '+' if (i >> 0) & 1 else '-'

    c = C if (i >> 1) & 1 else -C
    op[1] = '+' if (i >> 1) & 1 else '-'

    d = D if (i >> 2) & 1 else -C
    op[2] = '+' if (i >> 2) & 1 else '-'

    if sum([a, b, c, d]) == 7:
        break

print('{}{}{}{}{}{}{}=7'.format(A, op[0], B, op[1], C, op[2], D))

Submission status: Wrong Answer

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

if A+B+C+D==7:
  print("{}+{}+{}+{}==7".format(A,B,C,D))
elif A+B+C-D==7:
  print("{}+{}+{}-{}==7".format(A,B,C,D))
elif A+B-C+D==7:
  print("{}+{}-{}+{}==7".format(A,B,C,D))
elif A+B-C-D==7:
  print("{}+{}-{}-{}==7".format(A,B,C,D))
elif A-B+C+D==7:
  print("{}-{}+{}+{}==7".format(A,B,C,D))
elif A-B+C-D==7:
  print("{}-{}+{}-{}==7".format(A,B,C,D))
elif A-B-C+D==7:
  print("{}-{}-{}+{}==7".format(A,B,C,D))
elif A-B-C-D==7:
  print("{}-{}-{}-{}==7".format(A,B,C,D))

Submission status: Wrong Answer

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

if A+B+C+D==7:
  print("{}+{}+{}+{}".format(A,B,C,D))
elif A+B+C-D==7:
  print("{}+{}+{}-{}".format(A,B,C,D))
elif A+B-C+D==7:
  print("{}+{}-{}+{}".format(A,B,C,D))
elif A+B-C-D==7:
  print("{}+{}-{}-{}".format(A,B,C,D))
elif A-B+C+D==7:
  print("{}-{}+{}+{}".format(A,B,C,D))
elif A-B+C-D==7:
  print("{}-{}+{}-{}".format(A,B,C,D))
elif A-B-C+D==7:
  print("{}-{}-{}+{}".format(A,B,C,D))
elif A-B-C-D==7:
  print("{}-{}-{}-{}".format(A,B,C,D))

Submission status: Wrong Answer

Solution code:

def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"


if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    for i in range(1 << bin_pattern_digit):
        # 初期値:一番左の桁の値。
        result = int(abcd[0:1])
        for j in range(bin_pattern_digit):
            # +を入れた場合
            # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
            #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
            if i & 1 << j:
                # result += int(abcd[j + 1:j + 2])
                result += int(abcd[j + 1])
            # -を入れた場合
            else:
                # result -= int(abcd[j + 1:j + 2])
                result -= int(abcd[j + 1])

        # 合計が7なら終了
        if result == 7:
            break

    # 注意：
    # bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
    # 数値と同じで、先頭0は消される = 桁数が可変であるため。
    # i & 1 << 0  # 1桁目が真か確認。
    # i & 1 << 1  # 2桁目が真か確認。
    # -dev-
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")

Submission status: Wrong Answer

Solution code:
def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"

if __name__ == "__main__":
    abcd = input()
    bin_pattern_digit = len(abcd) - 1

    for i in range(1 << bin_pattern_digit):
        # 初期値:一番左の桁の値。
        result = int(abcd[0:1])
        for j in range(bin_pattern_digit):
            # +を入れた場合
            # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
            #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
            if i & 1 << j:
                result += int(abcd[j + 1:j + 2])
            # -を入れた場合
            else:
                result -= int(abcd[j + 1:j + 2])

        # 合計が7なら終了
        if result == 7:
            break

    # 注意：
    # bit変数(i)の結果を確認する場合、文字列とスライスの併用(str(bit(i[0:1])))は使えない。
    # 数値と同じで、先頭0は消される = 桁数が可変であるため。
    # i & 1 << 0  # 1桁目が真か確認。
    # i & 1 << 1  # 2桁目が真か確認。
    # -dev-
    print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=7")

Submission status: Wrong Answer

Solution code:
abcd = input()


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

f = abcd[0]
dfs(0, f, int(f))

Submission status: Wrong Answer

Solution code:

def conv_bin(i, digit):
    if i & 1 << digit:
        return "+"
    else:
        return "-"

abcd = input()
bin_pattern_digit = len(abcd) - 1
 
for i in range(1 << bin_pattern_digit):
    # 初期値:一番左の桁の値。
    result = int(abcd[0:1])
    for j in range(bin_pattern_digit):
        # +を入れた場合
        # 例：1234のパターン1「+」2の場合：i=0の時に+2(abcd[1:2])する必要がある。
        #                 3「-」4の場合：i=2の時に-4(abcd[3:4])する必要がある。
        if i & 1 << j:
            result += int(abcd[j + 1:j + 2])
        # -を入れた場合
        else:
            result -= int(abcd[j + 1:j + 2])
 
    # 合計が7なら終了
    if result == 7:
        break
 
print(abcd[0:1] + conv_bin(i, 2) + abcd[1:2] + conv_bin(i, 1) + abcd[2:3] + conv_bin(i, 0) + abcd[3:4] + "=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("%d+%d+%d+%d=7"%(a,b,c,d))
  exit()

Submission status: Wrong Answer

Solution code:
import sys
s=input()
a,b,c,d=int(s[0]),int(s[1]),int(s[2]),int(s[3])
if a+b+c+d==7:
  print('a+b+c+d=7')
  sys.exit()
if a+b+c-d==7:
  print('a+b+c-d=7')
  sys.exit()
if a+b-c+d==7:
  print('a+b-c+d=7')
  sys.exit()      
if a-b+c+d==7:
  print('a-b+c+d=7')
  sys.exit()
if a+b-c-d==7:
  print('a+b-c-d=7')
  sys.exit()
if a-b-c+d==7:
  print('a-b-c+d=7')
  sys.exit()
if a-b+c-d==7:
  print('a-b+c-d=7')
  sys.exit()
if a-b-c-d==7:
  print('a-b-c-d=7')
  sys.exit()

Submission status: Wrong Answer

Solution code:
def main():
  N = input()
  operators = [["+","+","+"],["+","+","-"],["+","-","+"],["-","+","+"],["+","-","-"],["-","+","+"],["-","-","+"],["-","-","-"]]
  for x,y,z in operators:
        tmp = N[0]+x+N[1]+y+N[2]+z+N[3]
        if eval(tmp) == 7:
              print(tmp+"=7")
              break

if __name__ == "__main__":
      main()

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ans1 = '+'
ans2 = '+'
ans3 = '+'
m=7-a
for B in[b,-b]:
    for C in[c,-c]:
        for D in[d,-d]:
            if B+C+D==m:
                if B==-b:
                    ans1="-"
                if C==-c:
                    ans2="-"
                if D==-d:
                    ans3="-"
                break
print(a,ans1,b,ans2,c,ans3,d)

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
ans1 = '+'
ans2 = '+'
ans3 = '+'
m=7-a
for B in[b,-b]:
    for C in[c,-c]:
        for D in[d,-d]:
            if B+C+D==m:
                if B==-b:
                    ans1="-"
                if C==-c:
                    ans2="-"
                if D==-d:
                    ans3="-"
                exit()
print(a,ans1,b,ans2,c,ans3,d)

Submission status: Wrong Answer

Solution code:
s = input()
a = int(s[0])
b = int(s[1])
c = int(s[2])
d = int(s[3])
op1 = '+'
op2 = '+'
op3 = '+'
for B in [b, -b]:
    for C in [c, -c]:
        for D in [d, -d]:
            if a + B + C + D == 7:
                if B < 0:
                    op1 = '-'
                if C < 0:
                    op2 = '-'
                if D < 0:
                    op3 = '-'
                print(str(a)+op1+str(b)+op2+str(c)+op3+str(d)+'=7')
    break

Submission status: Wrong Answer

Solution code:
import sys

S=input()
lst = ['-']*3
ans=0
for i in range(1<<3):
    start=0
    for j in range(3):
        if 1&(i>>j):
            lst[2-j] = '+'
    total = ''
    for n, m in zip(S, lst+['']):
        total += (n+m)
    if eval(total) == 7:
        print(total + '=7')
        break

Submission status: Wrong Answer

Solution code:
a = input()

plusminus = ['+', '-']

def calc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    else:
        ValueError

def cnt_calc(a, op1, op2, op3):
    return calc(
                int(a[3]),
                calc(
                    int(a[2]),
                    calc(
                        int(a[0]), int(a[1]), op1
                    ),
                    op2
                ),
                op3
            )


for i in plusminus:
    for j in plusminus:
        for k in plusminus:
            if cnt_calc(a, i, j, k) == 7:
                print(a[0] + i + a[1] + j + a[2] + k + a[3] + '=7')
                exit(0)

Submission status: Wrong Answer

Solution code:
a = input()

plusminus = ['+', '-']

ans = []

def calc(a, b, op):
    if op == '+':
        return a + b
    elif op == '-':
        return a - b
    else:
        ValueError

def cnt_calc(a, op1, op2, op3):
    return calc(
                int(a[3]),
                calc(
                    int(a[2]),
                    calc(
                        int(a[0]), int(a[1]), op1
                    ),
                    op2
                ),
                op3
            )


for i in plusminus:
    for j in plusminus:
        for k in plusminus:
            if cnt_calc(a, i, j, k) == 7:
                print(a[0] + i + a[1] + j + a[2] + k + a[3] + '=7')
                exit(0)

Submission status: Wrong Answer

Solution code:
import sys

def main():
    a = [int(x) for x in input()]
    ans = str()
    total = 0
    for i in range(2):
        ans += str(a[0])
        if i == 0:
            total += a[0]+a[1]
            ans += '+'
        else:
            total += a[0]-a[1]
            ans += '-'
        ans += str(a[1])
        for j in range(2):
            if j == 0:
                total += a[2]
                ans += '+'
            else:
                total -= a[2]
                ans += '-'
            ans += str(a[2])
            for k in range(2):
                if k == 0:
                    total += a[3]
                    ans += '+'
                else:
                    total -= a[3]
                    ans += '-'
                ans += str(a[3])
                if total == 7:
                    ans += '=7'
                    print(ans)
                    sys.exit()
                else:
                    total = 0
                    ans = str()

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import itertools

a=list(map(int,list(input())))

#print(a)

for i in itertools.product([0,1], repeat=3):
    r=list(i)
    sump=a[0]
    for ii in range(3):
        if r[ii]==0:
            sump=sump-a[ii+1]
        else:
            sump=sump+a[ii+1]
#    print(sump,r) 
    if sump==7:
        stra=str(a[0])
        for ii in range(3):
            if r[ii]==0:
                stra=stra+"-"+str(a[ii+1])
            else :
                stra=stra+"+"+str(a[ii+1])
        print(stra)
        break