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:

def abc079_c():
    stlist = input()

    stlist = "0290"

    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
                exit()
            return

        #+
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        #-
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()

Submission status: Wrong Answer

Solution code:
def abc079_c():
    stlist = input()


    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
            exit()

        #+
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        #-
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()

Submission status: Wrong Answer

Solution code:

def abc079_c():
    stlist = input()

    stlist = "1222"

    def DFS(i,sum,li):
        if i == len(stlist)-1:
            if sum == 7:
                print(str(stlist[0])+str(li[0])+str(stlist[1])+str(li[1])+str(stlist[2])+str(li[2])+str(stlist[3])+"=7")
            return

        #+
        li[i]="+"
        DFS(i+1,sum+int(stlist[i+1]),li)

        #-
        li[i]="-"
        DFS(i+1,sum-int(stlist[i+1]),li)

    DFS(0,int(stlist[0]),[[] for i in range(3)])










abc079_c()

Submission status: Wrong Answer

Solution code:
S = input()
for i in range(1 << 3):
    op = ['+'] * 3
    for j in range(3):
        if i >> j:
            op[j] = '-'
    res = ''.join([s + p for s, p in zip(S, op)])
    res += S[-1]
    if eval(res) == 7:
        res += '=7'
        print(res)
        break

Submission status: Wrong Answer

Solution code:
#-*-coding:utf-8-*-

def check(a,b,c,d,ans_pattern):
    ans_list=[b,c,d]
    ans=a
    for i in range(3):
        if ans_pattern[i]=="+":
            ans+=ans_list[i]
        else:
            ans-=ans_list[i]
    if ans==7:
        print("{}{}{}{}{}{}{}=7".format(a,ans_pattern[0],b,ans_pattern[1],c,ans_pattern[2],d))

def main2():
    #000なら+++
    #001なら++-
    a,b,c,d=map(int,input())
    for i in range(2**3):
        ans_pattern=["+","+","+"]
        for j in range(3):
            if (i >> j)&1:
                ans_pattern[j]="-"
        check(a,b,c,d,ans_pattern)

if __name__=="__main__":
    main2()

Submission status: Wrong Answer

Solution code:
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


nums = list(map(int, S()))
ans = ''
for i in range(2 ** 3):
    res = nums[0]
    ans = str(nums[0])
    for j in range(3):
        if i >> j != 0:
            res += nums[j + 1]
            ans += f'+{nums[j + 1]}'
        else:
            res -= nums[j + 1]
            ans += f'-{nums[j + 1]}'
    if res == 7:
        ans += '=7'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
#引数としてopを追加
#opには計算で用いた演算子が文字列として格納されている
def func(i,x,op):
    #ベースケース
    if i == 4:
        if x == 7: return op
        else: return ""

    #足す場合
    opP = func(i+1, x + int(S[i]), op+"+")
    if opP != "": return opP

    #引く場合
    opM = func(i+1, x - int(S[i]), op+"-")
    if opM != "": return opM

    return ""

Submission status: Wrong Answer

Solution code:
import itertools
A=input()
for i in list(itertools.product(range(2),repeat=3)):
  c=''
  c+=A[0]
  bns=int(A[0])
  for j in range(3):
    if i[j]==0:
      bns+=int(A[j+1])
      c+='+'+A[j+1]
    else:
      bns-=int(A[j+1])
      c+='-'+A[j+1]
  if bns==7:
    print(c)
    exit()

Submission status: Wrong Answer

Solution code:
list = list(input())

a, b, c, d = map(int, list)


def plus(items, key):
    if(key == 1):
        return items[0] + items[1]
    else:
        return items[0] - items[1]


def numToOp(num):
    return "+" if num == 1 else "-"


ans = 0
opList = [1, 1, 1]
i = 0
while ans != 7:
    aPlusB = plus([a, b], opList[0])
    aPlusBPlusC = plus([aPlusB, c], opList[1])
    ans = plus([aPlusBPlusC, d], opList[2])
    # print(f"{i}回目：ans == {ans}, opList == {opList}")

    if ans != 7 and i <= 4:
        opList[i % 3] *= -1
        i += 1
    elif i == 5:
        opList = [1, -1, 1]
        i += 1
    elif i == 6:
        opList = [-1, 1, -1]
        i += 1

# print(opList)

print(
    f"{a}{numToOp(opList[0])}{b}{numToOp(opList[1])}{c}{numToOp(opList[2])}{d}=7")

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
ans = ""
for i in range(2 ** 3):
  for j in range(1, 4):
    if i >> j & 1:
      a[j] *= -1
    if sum(a) == 7:
      ans += (str)(a[0])
      for j in range(1, 4):
        if a[j] >= 0:
          ans += "+" + (str)(a[j])
        else:
          ans += (str)(a[j])
      ans += "=7"
      break
  else:
    continue
  break
else:
  print("none")
print(ans)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
ans = ""
for i in range(2 ** 3):
  for j in range(1, 4):
    if i << j & 1:
      a[j] *= -1
    if sum(a) == 7:
      ans += (str)(a[0])
      for j in range(1, 4):
        if a[j] >= 0:
          ans += "+" + (str)(a[j])
        else:
          ans += (str)(a[j])
      ans += "=7"
      break
  else:
    continue
  break
print(ans)

Submission status: Wrong Answer

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

f, g = a+b, a-b
h, i, j, k = f+c, f-c, g+c, g-c
l, m, n, o, p, q, r, s = h + d, h - d, i + d, i - d, j + d, j - d, k + d, k - d
if(l == 7):
  print(str(a) + " + " + str(b) + " + " + str(c) + " + " + str(d))
elif(m == 7):
  print(str(a) + " + " + str(b) + " + " + str(c) + " - " + str(d))
elif(n == 7):
  print(str(a) + " + " + str(b) + " - " + str(c) + " + " + str(d))
elif(o == 7):
  print(str(a) + " + " + str(b) + " - " + str(c) + " - " + str(d))
elif(p == 7):
  print(str(a) + " - " + str(b) + " + " + str(c) + " + " + str(d))
elif(q == 7):
  print(str(a) + " - " + str(b) + " + " + str(c) + " - " + str(d))
elif(r == 7):
  print(str(a) + " - " + str(b) + " - " + str(c) + " + " + str(d))
elif(s == 7):
  print(str(a) + " - " + str(b) + " - " + str(c) + " - " + str(d))

Submission status: Wrong Answer

Solution code:
num = list(input())
op = [1, 1, 1]
def ans(result, op):
    if result == 7:
        for i in range(3):
            if op[i] == 1:
                op[i] = '+'
            else:
                op[i] = '-'
        print(f'{num[0]}{op[0]}{num[1]}{op[1]}{num[2]}{op[2]}{num[3]}=7')
        exit()


result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]
ans(result, op)

op = [-1, 1, -1]
result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]
ans(result, op)

for i in range(3):
    op = [1, 1, 1]
    op[i] = -1
    result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]

    ans(result, op)

for j in range(2):
    op = [1, 1, 1]
    op[-j] = -1
    result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]

    ans(result, op)

Submission status: Wrong Answer

Solution code:
num = list(input())
op = [1, 1, 1]

def ans(result, op):
    if result == 7:
        for i in range(3):
            if op[i] == 1:
                op[i] = '+'
            else:
                op[i] = '-'
        print(f'{num[0]}{op[0]}{num[1]}{op[1]}{num[2]}{op[2]}{num[3]}=7')
        exit()


result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]

ans(result, op)
for i in range(2):
    op[i] = -1
    result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]

    ans(result, op)

for j in range(2):
    op = [1, 1, 1]
    op[-j] = -1
    result = int(num[0]) + int(num[1])*op[0] + int(num[2])*op[1] + int(num[3])*op[2]

    ans(result, op)

Submission status: Wrong Answer

Solution code:
num = input()

x = ["+", "-"]

for i in x:
  for j in x:
    for k in x:
      n = eval(num[0]+i+num[1]+j+num[2]+k+num[3])
      if n == 7:
        print(num[0]+i+num[1]+j+num[2]+k+num[3]+"=7")
        break
    break
  break

Submission status: Wrong Answer

Solution code:
a=list(input())
for i in range(4):
  a[i]=int(a[i])
x=sum(a)-7
dict={0:'+',1:'-'}
for i in range(2):
  for j in range(2):
    for k in range(2):
        if x==(i*a[1]+j*a[2]+k*a[3])*2:
          print(a[0],dict[i],a[1],dict[j],a[2],dict[k],a[3],'=7',sep='')
          break

Submission status: Wrong Answer

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

for bit in range(1 << 3):
    t = str(nums[0])
    s = nums[0]
    for i in range(3):
        if (bit >> i) & 1:
            s += nums[i + 1]
            t += "+" + str(nums[i + 1])
        else:
            s -= nums[i - 1]
            t += "-" + str(nums[i + 1])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = input()


for i in range(8):
    ans = ""
    for j in range(3):
        ans += n[j]
        if ((i >> j) and 1):
            ans += "+"
        else:
            ans += "-"
    ans += n[-1]
    if eval(ans) == 7:
        print(ans + "=7")
        exit()

Submission status: Wrong Answer

Solution code:
from itertools import product
abcd = list(map(int, list(input())))


for ops in product(['+', '-'], repeat=3):
    temp = abcd[0]
    ans = str(abcd[0])
    for i, op in enumerate(ops):
        if op=='+':
            temp+=abcd[i+1]
            ans+='+'+str(abcd[i+1])
        else:
            temp-=abcd[i+1]
            ans+='+'+str(abcd[i+1])
    if temp==7:
        ans+='=7'
        break
print(ans)

Submission status: Wrong Answer

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

for i in range(2):
    for j in range(2):
        for k in range(2):
            if i%2==0 and j%2==0 and k%2==0:
                ans = a+b+c+d
                ans_s = f"{a}+{b}+{c}+{d}"
            elif i%2==0 and j%2==0 and k%2==1:
                ans = a+b+c-d
                ans_s = f"{a}+{b}+{c}-{d}"
            elif i%2== 0 and j%2==1 and k%2==1:
                ans = a+b-c-d
                ans_s = f"{a}+{b}-{c}-{d}"
            elif i%2== 1 and j%2==1 and k%2==1:
                ans = a-b-c-d
                ans_s = f"{a}-{b}-{c}-{d}"
            elif i%2==1 and j%2==1 and k%2==0:
                ans = a-b-c+d
                ans_s = f"{a}-{b}-{c}+{d}"
            elif i%2==1 and j%2==0 and k%2==0:
                ans = a-b+c+d
                ans_s = f"{a}-{b}+{c}+{d}"
            else:
                ans = a-b-c-d
                ans_s = f"{a}-{b}-{c}-{d}"
            
            if ans == 7:
                print(ans_s+"=7")
                exit()

Submission status: Wrong Answer

Solution code:
from copy import deepcopy
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions
from operator import itemgetter
import itertools
import copy


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

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

if s[0]+s[1]+s[2]+s[3] == 7:
    print(str(s[0]), '+', str(s[1]), '+',
          str(s[2]), '+', str(s[3]), '=', 7, sep='')
    exit()
if s[0]+s[1]-s[2]+s[3] == 7:
    print(str(s[0]), '+', str(s[1]), '-', str(s[2]),
          '+', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]-s[1]+s[2]+s[3] == 7:
    print(str(s[0]), '-', str(s[1]), '+', str(s[2]),
          '+', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]-s[1]-s[2]+s[3] == 7:
    print(str(s[0]), '-', str(s[1]), '-', str(s[2]),
          '+', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]-s[1]+s[2]-s[3] == 7:
    print(str(s[0]), '-', str(s[1]), '+', str(s[2]),
          '-', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]-s[1]-s[2]-s[3] == 7:
    print(str(s[0]), '-', str(s[1]), '-', str(s[2]),
          '-', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]-s[1]+s[2]-s[3] == 7:
    print(str(s[0]), '-', str(s[1]), '+', str(s[2]),
          '-', str(s[3]),  '=', 7, sep='')
    exit()
if s[0]+s[1]-s[2]-s[3] == 7:
    print(str(s[0]), '+', str(s[1]), '-', str(s[2]),
          '-', str(s[3]),  '=', 7, sep='')
    exit()

Submission status: Wrong Answer

Solution code:
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

s=list(SI())
a=int(s[0])
ops=["+","-"]
for i in product(ops,repeat=3):
    ans=a
    for j in range(3):
        if i[j]=="+":
            ans+=int(s[j+1])
        else:
            ans-=int(s[j+1])
    if ans==7:
        u=i
        print(i)
        break
print(s[0],end="")
for i in range(3):
    print(u[i]+s[i+1],end="")
print("=7")

Submission status: Wrong Answer

Solution code:

def a(s,i):
    if i == l-1:
        if eval(s)==7:
            return s+"=7"
        return
    a(s+"+"+N[i+1],i+1)
    a(s+"-"+N[i+1],i+1)

N = input()
l = len(N)

print(a(N[0],0))

Submission status: Wrong Answer

Solution code:
import operator

vals = input()
nums = list(map(int, tuple(vals)))

def dump(a,b,c):
    if a == operator.add:
        a = '+'
    else:
        a = '-'
    if b == operator.add:
        b = '+'
    else:
        b = '-'
    if c == operator.add:
        c = '+'
    else:
        c = '-'
    print(vals[0] + a + vals[1] + b + vals[2] + c + vals[3] + '=7')

for a in (operator.add, operator.sub):
    for b in (operator.add, operator.sub):
        for c in (operator.add, operator.sub):
            if c(b(a(nums[0], nums[1]), nums[2]), nums[3]) == 7:
                dump(a, b, c)
                break

Submission status: Wrong Answer

Solution code:
import operator

vals = input()
nums = list(map(int, tuple(vals)))

def dump(a,b,c):
    if a == operator.add:
        a = '+'
    else:
        a = '-'
    if b == operator.add:
        b = '+'
    else:
        b = '-'
    if c == operator.add:
        c = '+'
    else:
        c = '-'
    print(vals[0] + a + vals[1] + b + vals[2] + c + vals[3] + '=7')

for a in (operator.add, operator.sub):
    for b in (operator.add, operator.sub):
        for c in (operator.add, operator.sub):
            if c(b(a(nums[0], nums[1]), nums[2]), nums[3]) == 7:
                print(a, b, c)
                dump(a, b, c)
                break

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = input()
    for i in range(2**3):
        op = ['+', '+', '+']
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break

    main()

Submission status: Wrong Answer

Solution code:
def main():
    A, B, C, D = input()
    op = ['+', '+', '+']
    for i in range(2**3):
        for j in range(len(op)):
            if (i >> j) & 1:
                op[j] = '-'
        if eval(A + op[0] + B + op[1] + C + op[2] + D) == 7:
            print(A + op[0] + B + op[1] + C + op[2] + D + '=7')
            break
if __name__  == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
a,b,c,d = input()
for i in ["+","-"]:
    for j in ["+","-"]:
        for k in ["+","-"]:
                if eval(a+i+b+j+c+k+d) == 7:
                    print(a+i+b+j+c+k+d+ "=7")

Submission status: Wrong Answer

Solution code:
s = int(input())
a = s // 1000
b = s // 100 % 10
c = s // 10 % 10
d = s % 10

def p_mark(j):
    if j % 2 == 0:
        return '+'
    else:
        return '-'

for i in range(2 ** 3):
    j = i
    p = a

    x = p_mark(j)

    if x == '+':
        p += b
    else:
        p -= b

    j = j // 10

    y = p_mark(j)

    if y == '+':
        p += c
    else:
        p -= c

    j = j // 10

    z = p_mark(j)

    if z == '+':
        p += d
    else:
        p -= d

    if p == 7:
        print(str(a) + x + str(b) + y + str(c) + z + str(d) + '=7')
        break

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
for q in range(1, 3):
    f = ""
    f += a + ("+" if q % 2 else "-")
    for w in range(1, 3):
        f += b + ("+" if w % 2 else "-")
        for e in range(1, 3):
            if eval(f + c + ("+" if e % 2 else "-") + d) == 7:
                print(f + c + ("+" if e % 2 else "-") + d + "=7")
                exit(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
l = [int(i) for i in s]
for i in range(2**3):
    ans = l[0]
    siki = s[0]
    for j in range(3):
        if i>>j & 1:
            ans += l[j+1]
            siki += "+"+s[j]
        else:
            ans -= l[j+1]
            siki += "-"+s[j]
    if ans == 7:
        print(siki+"=7")
        break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
s = input()
l = [int(i) for i in s]
for i in range(2**3):
    ans = l[0]
    siki = s[0]
    for j in range(3):
        if i>>j & 1:
            ans += l[j+1]
            siki += "+"+s[j]
        else:
            ans -= l[j+1]
            siki += "-"+s[j]
    if ans == 7:
        print(siki+"=7")
        exit()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
s = input()
l = [int(i) for i in s]
for i in range(8):
    t = [abs(p) for p in l]
    op = ["+"]*3
    for j in range(3):
        if i>>j & 1:
            op[j] = "-"
            l[j+1] *= -1
    if sum(l) == 7:
        print(str(t[0])+op[0]+str(t[1])+op[1]+str(t[2])+op[2]+str(t[3])+"=7")
        sys.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:
a, b, c, d = list(input())
for i in range(2 ** 3):
    ls = ['+'] * 3
    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')

Submission status: Wrong Answer

Solution code:
import math

abcd = int(input())

a = abcd // 1000
b = (abcd - a * 1000) // 100
c = (abcd - a * 1000 - b * 100) // 10
d = abcd % 10

for i in range(2**3):
    siki = []
    for j in range(3):
        if(i >> j & 1):
            siki.append("+")
        else:
            siki.append("-")
    siki2 = str(a) + siki[0] + str(b) + siki[1] + str(c) + siki[2] + str(d)
    if(eval(siki2) == 7):
        print(siki2+"=7")

Submission status: Wrong Answer

Solution code:
a,b,c,d = (int(i) for i in input())
 
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:
abcd = list(input())
abcd = [int(i) for i in abcd]

for i in range(2**3):
  bag=["+"]*3
  #print("pattern {}: ".format(i), end="")
  for j in range(3):
    if ((i>>j) & 1):
      bag[j]="-"
  #print(bag)
  s=abcd[0]
  for ii in range(len(bag)):
    if bag[ii] == "+":
      s+=abcd[ii+1]
    else:
      s-=abcd[ii+1]
    #print(s)
    
    if s == 7:
      print("{}{}{}{}{}{}{}={}".format(abcd[0],bag[0],abcd[1],bag[1],abcd[2],bag[2],abcd[3],s))
      exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
n= 2**(len(s)-1)
ans = 'inf'
for i in range(n):
    total = int(s[0])
    str = s[0]
    for j in range(1,len(s)):
        if i>>(len(s)-j-1)&1:
            total += int(s[j])
            str += '+' + s[j]
        else:
            total -= int(s[j])
            str += '-' + s[j]
    if total == 7:
        ans = str
print(str+'=7')

Submission status: Wrong Answer

Solution code:
s = input()
n= 2**(len(s)-1)
ans = 'inf'
for i in range(n):
    total = int(s[0])
    str = s[0]
    for j in range(1,len(s)):
        if i>>(len(s)-j)&1:
            total += int(s[j])
            str += '+' + s[j]
        else:
            total -= int(s[j])
            str += '-' + s[j]
    if total == 7:
        ans = str
print(str+'=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("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")
elif a-b-c+d==7:
    print("a-b-c+d=7")

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1 << (3)):
    f = s[0]
    
    for i in range(3):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    if sum(list(map(int, f.split('+')))) == 7:
        f += "=7"
        print(f)
        exit()

Submission status: Wrong Answer

Solution code:
s = input()

for bit in range(1 << (3)):
    f = s[0]
    
    for i in range(3):
        # if bit & (1 << i)で、bitにiが含まれているか（フラグが立っているか）を判定してくれるらしい
        if bit & (1 << i):
            f += '+'
        f += s[i + 1]
    if sum(list(map(int, f.split('+')))) == 7:
        print(f)
        exit()

Submission status: Wrong Answer

Solution code:
from sys import stdin
l = list(stdin.readline().rstrip())
s = [int(i) for i in l]
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f)
            exit()
    else:
        dfs(i+1, f + '+' + str(s[i]), sum + s[i])
        dfs(i+1, f + '-' + str(s[i]), sum - s[i])
dfs(0, str(s[0]), s[0])

Submission status: Wrong Answer

Solution code:
a,b,c,d=map(int,list(input()))
n=3
ans=''
for i in range(n**2):
  op=[]
  for j in range(n):
    if (i>>j & 1):
      op.append(True)
    else:
      op.append(False)
  tmp=a
  tmp=tmp+b if op[0] else tmp-b
  tmp=tmp+c if op[1] else tmp-c
  tmp=tmp+d if op[2] else tmp-d
  if tmp==7:
    ans=str(a)
    ans+='+' if op[0] else '-'
    ans+=str(b)
    ans+='+' if op[1] else '-'
    ans+=str(c)
    ans+='+' if op[2] else '-'
    ans+=str(d)
    break
print(ans)

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("{0}+{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C+D == 7:
	print("{0}-{1}+{2}+{3}=7".format(A,B,C,D))
elif A-B+C-D == 7:
	print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))
elif A-B-C-D == 7:
	print("{0}-{1}-{2}-{3}=7".format(A,B,C,D))

elif A+B-C+D == 7:
	print("{0}+{1}-{2}+{3}=7".format(A,B,C,D))
elif A-B-C+D == 7:
	print("{0}-{1}-{2}+{3}=7".format(A,B,C,D))

elif A+B+C-D == 7:
	print("{0}+{1}+{2}-{3}=7".format(A,B,C,D))
elif A+B-C-D == 7:
	print("{0}-{1}+{2}-{3}=7".format(A,B,C,D))

Submission status: Wrong Answer

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

    def dfs(i, f):
        if i == 3:
            return f.split(",")
        return dfs(i+1, f + "+" + s[i+1]) + dfs(i+1, f + "-" + s[i-1])
    for i in dfs(0, s[0]):
        if eval(i) == 7:
            print(i + "=7")
            exit()
resolve()

Submission status: Wrong Answer

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

    for i in range(8):
        op1 = "+" if i>>0 & 1 else "-"
        op2 = "+" if i>>1 & 1 else "-"
        op3 = "+" if i>>2 & 1 else "-"
        test = a + op1 + b + op2 + c + op3 + d
        if eval(test) == 7:
            print(test + "=7")
resolve()

Submission status: Wrong Answer

Solution code:
def solve(A,n):
    x=2**n
    for i in range(x):
        count=A[0]
        for j in range(n):
            if (i>>j) & 1:
                count+=A[j+1]
            else:
                count-=A[j+1]
        if count==7:
            return i

n=3
A=list(map(int,input()))
i=solve(A,n)
ans=str(A[0])
for j in range(n):
    if (i>>j) & 1:
        ans+="+"+str(A[j])
    else:
        ans+="-"+str(A[j])
ans+="=7"
print(ans)

Submission status: Wrong Answer

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

l = [0] * 8
l[0] = a + b + c + d
l[1] = a + b + c - d
l[2] = a + b - c + d
l[3] = a + b - c - d
l[4] = a - b + c + d
l[5] = a - b + c - d
l[6] = a - b - c + d
l[7] = a - b - c - d

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

Submission status: Wrong Answer

Solution code:
a = list(map(int, input()))
b = [a[1], -a[1]]
c = [a[2], -a[2]]
d = [a[3], -a[3]]
for i in b:
    if(i>=0):
        b_ = '+'
    else: b_ = '-'
    for j in c:
        if(i>=0):
            c_ = '+'
        else: c_ = '-'
        for k in d:
            if(k>=0):
                d_ = '+'
            else: d_ = '-'
            
            ans = a[0] + i + j + k
            if ans==7:
                print(str(a[0]),b_, str(a[1]), c_, str(a[2]), d_, str(a[3]))
                break
            break
        break
    break

Submission status: Wrong Answer

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

for i in op:
  for j in op:
    for k in op:
      o=a+i+b+j+c+k+d
      ans=eval(o)
      if ans==7:
        print(o+"+=7")
        sys.exit()

Submission status: Wrong Answer

Solution code:

A,B,C,D = input()
A = int(A)
B = int(B)
C = int(C)
D = int(D)
sum = 0
ope = ["", "",""]
for i in range(2):

    for j in range(2):

        for k in range(2):
            if (i == 0):
                sum += A + B
                ope[0] = "+"
            if (i == 1):
                sum += A - B
                ope[0] = "-"
            if (j == 0):
                sum += C
                ope[1] = "+"
            if (j == 1):
                sum -= C
                ope[1] = "-"
            if (k == 0):
                sum += D
                ope[2] = "+"
                if (sum == 7):
                    break
            if(k==1):
                sum -= D
                ope[2] = "-"
                if (sum == 7):
                    break
        if (sum == 7):
            break
        else:
            sum=0
    if (sum == 7):
        break
print("{}{}{}{}{}{}{}=7".format(A,ope[0],B,ope[1],C,ope[2],D))