Problem:


Score : 300 points

Problem Statement

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

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

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

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

Constraints

0≤A,B,C,D≤9

All input values are integers.

It is guaranteed that there is a solution.

Input

Input is given from Standard Input in the following format:

ABCD

Output

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

Use the signs + and -.

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

Sample Input 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

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

Sample Input 3

3242

Sample Output 3

3+2+4-2=7



Sample input:
1222


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

Submission status: Wrong Answer

Solution code:
abcd = input()

for mask in range(1 << 3):
  res = int(abcd[0])
  ans = abcd[0]
  
  for i in range(3):
    if ((mask >> i) & 1) == 1:
      res += int(abcd[i + 1])
      ans += '+' + abcd[i + 1]
    else:
      res -= int(abcd[i + 1])
      ans += '-' + abcd[i + 1]
  
  if res == 7:
    print('{}=7', ans)
    break

Submission status: Wrong Answer

Solution code:
s=list(input())
a,b,c,d=s[0],s[1],s[2],s[3]
aa,bb,cc,dd=int(a),int(b),int(c),int(d)
ops=['+']*3

def sumsum(a,b,c,d):
    return a+b+c+d

if sumsum(aa,bb,cc,dd)==7:
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb==7:
    ops[0]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc==7:
    ops[1]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*dd==7:
    ops[2]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc==7:
    ops[0],ops[1]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc-2*dd==7:
    ops[1],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*dd==7:
    ops[0],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*bb-2*dd==7:
    ops='-'*3
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()

Submission status: Wrong Answer

Solution code:
s=list(input())
print(s)
a,b,c,d=s[0],s[1],s[2],s[3]
aa,bb,cc,dd=int(a),int(b),int(c),int(d)
ops=['+']*3

def sumsum(a,b,c,d):
    return a+b+c+d

print(sumsum(aa,bb,cc,dd))
if sumsum(aa,bb,cc,dd)==7:
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb==7:
    ops[0]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc==7:
    ops[1]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*dd==7:
    ops[2]='-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*cc==7:
    ops[0],ops[1]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*cc-2*dd==7:
    ops[1],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*dd==7:
    ops[0],ops[2]='-','-'
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()
    exit()
if sumsum(aa,bb,cc,dd)-2*bb-2*bb-2*dd==7:
    ops='-'*3
    print(a+ops[0]+b+ops[1]+c+ops[2]+d)
    exit()

Submission status: Wrong Answer

Solution code:
N = input()

answer = ""

for i in range(1 << 3):
    exp = N[0]
    for j in range(3):
        if i >> j & 1:
            exp += "+"
        else:
            exp += "-"
        exp += N[j + 1]
    if eval(exp) == 7:
        answer = exp
        break

print(answer)

Submission status: Wrong Answer

Solution code:
a, b, c, d = map(int, list(input()))
Lis = ["+", "-"]
for k in range(8):
    bi = list(map(int, bin(k).replace('b', '0')))
    bi.reverse()
    res = a+b if not bi[0] else a-b
    res += c if not bi[1] else -c
    res += d if not bi[2] else -d
    if res == 7:
        print(''.join([str(a), Lis[bi[0]], str(b), Lis[bi[1]],
                       str(c), Lis[bi[2]], str(d)]))
        break

Submission status: Wrong Answer

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

for ops in product('+-', repeat=3):
    tmp = li[0]
    for o, n in zip(ops, li[1:]):
        if o == '+':
            tmp += n
        else:
            tmp -= n
    if tmp == 7:
        ans = str(li[0])
        for o, n in zip(ops, li[1:]):
            ans += o + str(n)

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
l=["+","-"]
for i in range(2):
  for j in range(2):
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Submission status: Wrong Answer

Solution code:
s=input()
l=["+","-"]
for i in range(2):
  for j in range(2):
    for p in range(2):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        break
print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Submission status: Wrong Answer

Solution code:
s=input()
l=["+","-"]
for i in range(1):
  for j in range(1):
    for p in range(1):
      if eval(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3])==7:
        break
print(s[0]+l[i]+s[1]+l[j]+s[2]+l[p]+s[3]+"=7")

Submission status: Wrong Answer

Solution code:
import sys


s=input()

for i in range(2**(len(s)-1)):
    x=""
    for j in s:
        x+=j
        if i%2==1:
            x+=","
        i//=2
    #print(x)
    row = list(map(int,x.split(',')))
    #print(row)
    if len(row)==1:
        y = str(row)
        count = eval(y)
        #print(count)
        if count == 7:
            print(t+'=7')
            sys.exit()
    else:
        for i in range(2**(len(row)-1)):
            num = 0
            t=''
            for j in row:
                t+=str(j)
                num += 1
                if num == len(row):
                    break
                if i%2==0:
                    t+='+'
                else:
                    t+='-'
                i//=2
            #print(t)
            count = eval(t)
            #print(count)
            if count == 7:
                print(t+'=7')
                sys.exit()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def S(self):
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = ip.S()
    h = ["+", "-"]

    o = False  # フラグ

    for i in h:
        for j in h:
            for k in h:
                p = s[0] + i + s[1] + j + s[2] + k + s[3]

                if eval(p) == 7:
                    p += "=7"
                    print(p)
                    o = True
                    break
        if o:
            break


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def S(self):
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = ip.S()
    h = ["+", "-"]

    o = False  # フラグ

    for i in h:
        for j in h:
            for k in h:
                p = s[0]
                p += i
                p += s[1]
                p += j
                p += s[2]
                p += k
                p += s[3]
                if eval(p) == 7:
                    p += "=7"
                    print(p)
                    o = True
                    break
        if o:
            break


main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import sys
# import bisect
# import math
# import numpy as np


"""Template"""


class IP:
    """
    入力を取得するクラス
    """
    def __init__(self):
        self.input = sys.stdin.readline

    def I(self):
        """
        1文字の取得に使います
        :return: 数
        """
        return int(self.input())

    def S(self):
        return self.input()

    def IL(self):
        """
        1行を空白で区切りリストにします(int
        :return: リスト
        """
        return list(map(int, self.input().split()))

    def SL(self):
        """
        1行の文字列を空白区切りでリストにします
        :return: リスト
        """
        return list(map(str, self.input().split()))

    def ILS(self, n):
        """
        1列丸々取得します(int
        :param n: 行数
        :return: リスト
        """
        return [int(self.input()) for _ in range(n)]

    def SLS(self, n):
        """
        1列丸々取得します（str
        :param n: 行数
        :return: リスト
        """
        return [self.input() for _ in range(n)]


class Idea:
    def __init__(self):
        pass

    def HF(self, p):
        """
        Half enumeration
        半分全列挙です
        pの要素の和の組み合わせを作ります。
        ソート、重複削除行います
        :param p: list : 元となるリスト
        :return: list : 組み合わせられた和のリスト
        """
        return sorted(set(p[i] + p[j] for i in range(len(p)) for j in range(i, len(p))))

    def Bfs2(self, a):
        """
        bit_full_search2
        bit全探索の改良版
        全探索させたら2進数のリストと10進数のリストを返す
        :return: list２つ : １個目 2進数(16桁)  2個目 10進数
        """
        # 参考
        # https://blog.rossywhite.com/2018/08/06/bit-search/
        # https://atcoder.jp/contests/abc105/submissions/4088632
        value = []
        for i in range(1 << len(a)):
            output = []

            for j in range(len(a)):
                if self.bit_o(i, j):
                    """右からj+1番目のiが1かどうか判定"""
                    # output.append(a[j])
                    output.append(a[j])
            value.append([format(i, 'b').zfill(16), sum(output)])

        value.sort(key=lambda x: x[1])
        bin = [value[k][0] for k in range(len(value))]
        val = [value[k][1] for k in range(len(value))]
        return bin, val

    def SR(self, s):
        """
        昇順ソート（reverse書くのが面倒
        返り値はありません。注意して下さい。
        SR(s) と書いたらsが昇順ソートされるだけです。
        Sort Reverse
        :param s: ソートしたいリスト
        :return: None
        """
        s.sort(reverse=True)

    def bit_n(self, a, b):
        """
        bit探索で使います。0以上のときにTrue出します
        自然数だからn
        :param a: int
        :param b: int
        :return: bool
        """
        return bool((a >> b & 1) > 0)

    def bit_o(self, a, b):
        """
        bit探索で使います。1のときにTrue出すよ
        oneで1
        :param a: int
        :param b: int
        :return: bool
        """
        return bool(((a >> b) & 1) == 1)

    def ceil(self, x, y):
        """
        Round up
        小数点切り上げ割り算
        :param x: int
        :param y: int
        :return: int
        """
        return -(-x//y)

    def ave(self, a):
        """
        平均を求めます
        :param a: list
        :return: int
        """
        return sum(a) / len(a)


"""ここからメインコード"""


def main():
    # 1文字に省略
    r, e = range, enumerate
    ip = IP()
    id = Idea()

    """この下から書いてね"""
    s = ip.S()
    h = ["-", "+"]

    o = False  # フラグ

    for i in h:
        for j in h:
            for k in h:
                p = s[0]
                p += i
                p += s[1]
                p += j
                p += s[2]
                p += k
                p += s[3]
                if eval(p) == 7:
                    p += "=7"
                    print(p)
                    o = True
                    break
        if o:
            break


main()

Submission status: Wrong Answer

Solution code:
S = input()
opt = ['+', '-']

for i in opt:
    for j in opt:
        for k in opt:
            temp = S[0] + i + S[1] + j + S[2] + k + S[3]
            ans = eval(temp)
            if ans == 7:
                break
print(''.join(list(temp)), end = '')
print('=7')

Submission status: Wrong Answer

Solution code:
S = input()
opt = ['+', '-']

for i in opt:
    for j in opt:
        for k in opt:
            temp = S[0] + i + S[1] + j + S[2] + k + S[3]
            ans = eval(temp)
            if ans == 7:
                print(''.join(list(temp)), end = '')
                print('=7')
                break

Submission status: Wrong Answer

Solution code:
D = input()

ops = []
for i in range(1 << 3):
    op = ""
    xx = bin(i)[2::].zfill(3)
    for x in xx:
        if x=="0":
            op += "+"
        else:
            op += "-"
    ops.append(op)

for op in ops:
    res = D[0]
    for i in range(3):
        res += op[i]+D[i+1]
    if eval(res)==7:
        print(res)
        break

Submission status: Wrong Answer

Solution code:
abcd = input()
ans=''
for i in range(8):
    op1 = '+' if (1 & i) != 0 else '-'
    op2 = '+' if (3 & i) != 0 else '-'
    op3 = '+' if (5 & i) != 0 else '-'
    s = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
    if eval(s) == 7: ans = s + '=7'
print(ans)

Submission status: Wrong Answer

Solution code:
abcd = input()
ans=''
for i in range(8):
    op1 = '+' if (1 & i) != 0 else '-'
    op2 = '+' if (3 & i) != 0 else '-'
    op3 = '+' if (7 & i) != 0 else '-'
    s = abcd[0] + op1 + abcd[1] + op2 + abcd[2] + op3 + abcd[3]
    if eval(s) == 7: ans = s + '=7'
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, d = list(input())
opt = ['+', '-']

for i in opt:
    for j in opt:
        for k in opt:
            f = a + i + b + j + c + k + d
            if eval(f) == 7:
                print(f + '=7')

Submission status: Wrong Answer

Solution code:
import itertools
S=input()
TT=itertools.product(["+","-"],repeat=3)
for T in TT:
    A=S[0]+T[0]+S[1]+T[1]+S[2]+T[2]+S[3]
    if eval(A)==7:
        print(A)
        exit()

Submission status: Wrong Answer

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

oplist = ['+', '-']

for op1 in oplist:
    for op2 in oplist:
        for op3 in oplist:
            f = A + op1 + B + op2 + C + op3 + D
            ans = eval(f)
            if ans == 7:
                print(f)
                quit()

Submission status: Wrong Answer

Solution code:
num = input()
ssa = [int(x) for x in num]
if ssa[0]+ssa[1]+ssa[2]+ssa[3] == 7:print('{}+{}+{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]+ssa[3] == 7:print('{}-{}+{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]+ssa[3] == 7:print('{}-{}-{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]-ssa[2]-ssa[3] == 7:print('{}-{}-{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]+ssa[3] == 7:print('{}+{}-{}+{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]-ssa[2]-ssa[3] == 7:print('{}+{}-{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]-ssa[1]+ssa[2]-ssa[3] == 7:print('{}-{}+{}-{}'.format(num[0],num[1],num[2],num[3]))
elif ssa[0]+ssa[1]+ssa[2]-ssa[3] == 7:print('{}+{}+{}-{}'.format(num[0],num[1],num[2],num[3]))

Submission status: Wrong Answer

Solution code:
import sys

a = list(input())
for i in range(2):
    for j in range(2):
        for k in range(2):
            if i % 2 == 0:
                sym1 = '+'
            else:
                sym1 = '-'
            if j % 2 == 0:
                sym2 = '+'
            else:
                sym2 = '-'
            if k % 2 == 0:
                sym3 = '+'
            else:
                sym3 = '-'
            word = a[0] + sym1 + a[1] + sym2 + a[2] + sym3 + a[3]

            ans = eval(word)
            if ans == 7:
                print(word)
                sys.exit()

Submission status: Wrong Answer

Solution code:
A = input()
a,b,c,d = A[0],A[1],A[2],A[3]
e1 = a+'+'+b+'+'+c+'+'+d
e2 = a+'+'+b+'+'+c+'-'+d
e3 = a+'+'+b+'-'+c+'+'+d
e4 = a+'+'+b+'-'+c+'-'+d
e5 = a+'-'+b+'+'+c+'+'+d
e6 = a+'-'+b+'+'+c+'-'+d
e7 = a+'-'+b+'-'+c+'+'+d
e8 = a+'-'+b+'+'+c+'-'+d
if eval(e1) == 7:
    print(e1)
elif eval(e2) == 7:
    print(e2)
elif eval(e3) == 7:
    print(e3)
elif eval(e4) == 7:
    print(e4)
elif eval(e5) == 7:
    print(e5)
elif eval(e6) == 7:
    print(e6)
elif eval(e7) == 7:
    print(e7)
elif eval(e8) == 7:
    print(e8)

Submission status: Wrong Answer

Solution code:
abcd = str(input())
n = 3
for bits in range(1 << n):
    x1 = '+'
    x2 = '+'
    x3 = '+'
    for i in range(n):
        if (bits >> i & 1) == 1:
            print(i)
            if i == 0:
                x1 = '-'
            if i == 1:
                x2 = '-'
            if i == 2:
                x3 = '-'
    check1 = abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3]
    check2 = eval(abcd[0] + x1 + abcd[1] + x2 + abcd[2] + x3 + abcd[3])
    print(check1)
    if check2 == 7:
        ans = check1
print(ans+'=7')

Submission status: Wrong Answer

Solution code:
L = input()
N = [int(i) for i in list(L)]
def check(n):
  if n == -1:
    return '-'
  else:
    return '+'
for i in range(2):
  for j in range(2):
    for k in range(2):
      if N[0] + N[1] * pow(-1, i) + N[2] * pow(-1, j) + N[3] * pow(-1, k) == 7:
        ii = check(pow(-1, i))
        jj = check(pow(-1, j))
        kk = check(pow(-1, k))
        print(str(N[0]) + ii + str(N[1]) + jj + str(N[2]) + kk + str(N[3]) + "==7")
        exit(0)

Submission status: Wrong Answer

Solution code:

n = list(map(int,list(input())))
limit = 7
d = [ [] for i in range(len(n))]
op = [ [] for i in range(len(n))]

for i,val in enumerate(n):
	if i == 0:
		d[0].append(n[0])
		op[0].append("")
	else:
		for j in d[i-1]:
			d[i].append(j+val)
			d[i].append(j-val)
		for j in op[i-1]:
			op[i].append(j + "+")
			op[i].append(j + "-")


_op = op[len(n)-1][d[len(n)-1].index(limit)]

s = ""
for i,val in enumerate(n):
	s += str(val)
	if i == len(n)-1:
		break
	else:
		s += _op[i]

print(s)

Submission status: Wrong Answer

Solution code:
num_text = list(input())
a = int(num_text[3])
b = int(num_text[2])
c = int(num_text[1])
d = int(num_text[0])
sum = 0
flg = 0
sum = d + c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1

Submission status: Wrong Answer

Solution code:
num_text = list(input())
a = int(num_text[3])
b = int(num_text[2])
c = int(num_text[1])
d = int(num_text[0])
sum = 0
flg = 0
sum = d + c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1

Submission status: Wrong Answer

Solution code:
flg = 0

def jage(sum,a,b,c,d,flg2):
    global flg
    if sum == 7 and flg2== 0:
        print(str(d)+'+'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
        flg = 1


num_text = int(input())
a = num_text%10
b = (num_text%100 -a) //10
c = (num_text%1000 -a -b)//100
d = num_text//1000
sum = 0
flg = 0
sum = d + c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d + c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'+'+str(c)+'+'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c + b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'+'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b + a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'+'+str(a) + '='+str(sum))
    flg = 1
sum = d - c - b - a
if sum == 7 and flg== 0:
    print(str(d)+'-'+str(c)+'-'+str(b)+'-'+str(a) + '='+str(sum))
    flg = 1

Submission status: Wrong Answer

Solution code:
from sys import exit
def fun(arr,i,j,k):
    ans = 0
    if i == '+':
        ans += arr[0]+arr[1]
    else:
        ans += (arr[0]-arr[1])
    if j == '+':
        ans += arr[2]
    else:
        ans -= arr[2]
    if k == '+':
        ans += arr[3]
    else:
        ans += arr[3]
    return ans
s = raw_input().strip()
s = [int(x) for x in s]
for i in ['+','-']:
    for j in ['+','-']:
        for k in ['+','-']:
            if fun(s,i,j,k) == 7:
                print str(s[0])+i+str(s[1])+j+str(s[2])+k+str(s[3])+"=7"
                exit(0)

Submission status: Wrong Answer

Solution code:
def fun(arr,i,j,k):
    ans = 0
    if i == '+':
        ans += arr[0]+arr[1]
    else:
        ans += (arr[0]-arr[1])
    if j == '+':
        ans += arr[2]
    else:
        ans -= arr[2]
    if k == '+':
        ans += arr[3]
    else:
        ans += arr[3]
    return ans
s = raw_input().strip()
s = [int(x) for x in s]
for i in ['+','-']:
    for j in ['+','-']:
        for k in ['+','-']:
            if fun(s,i,j,k) == 7:
                print str(s[0])+i+str(s[1])+j+str(s[2])+k+str(s[3])+"=7"
                exit()

Submission status: Wrong Answer

Solution code:
S = input()
op = ["+", "-"]
for a in op:
    for b in op:
        for c in op:
            f = S[0] + a + S[1] + b + S[2] + c + S[3]
            if eval(f) == 7:
                print(f + "=7")
                break
            break
        break

Submission status: Wrong Answer

Solution code:
S = input()
op = ["+", "-"]
for a in op:
    for b in op:
        for c in op:
            f = S[0] + a + S[1] + b + S[2] + c + S[3]
            if eval(f) == 7:
                print(f + "=7")
                break

Submission status: Wrong Answer

Solution code:
abcd = input()

for i in range(1<<3):
	formula = abcd[0]
	for j in range(3):
		formula += "+-"[(i>>j)%2]
		formula += abcd[j+1]
	if eval(formula) == 7:
		print(formula + "=7")

Submission status: Wrong Answer

Solution code:
num_str = list(str(input()))
num = []
for i in range(4):
    num.append(int(num_str[i]))
if num[0] + num[1] + num[2] + num[3] == 7:
    print(num[0], "+", num[1], "+", num[2], "+", num[3], "=7", sep="")
    
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(num[0], "-" ,num[1] ,"+", num[2] ,"+" ,num[3] ,"=7", sep="")
    
elif num[0] + num[1] - num[2] + num[3] == 7:
    print(num[0], "+" ,num[1] ,"-" ,num[2], "+", num[3] ,"=7", sep="")
    
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(num[0], "+", num[1], "+" ,num[2], "-", num[3], "=7", sep="")
    
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(num[0] ,"-" ,num[1], "-" ,num[2] ,"+" ,num[3] ,"=7", sep="")
    
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(num[0] ,"-" ,num[1] ,"+" ,num[2] ,"-", num[3], "=7", sep="")
    
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(num[0] ,"+", num[1], "+" ,num[2] ,"+", num[3],"=7", sep="")
    
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(num[0], "+" ,num[1] ,"+" ,num[2], "+" ,num[3], "=7", sep="")

Submission status: Wrong Answer

Solution code:
def check(operate_list, num_list):
    res = num_list[0]
    for i, op in enumerate(operate_list):
        if op == "+":
            res += num_list[i+1]
        elif op == "-":
            res -= num_list[i+1]
    return res == 7

def concat(operate_list, num_list):
    string = num_list[0]
    for op, num in zip(operate_list, num_list[1:]):
        # it is beautiful!
        string += op
        string =+ num
    string += "=7"
    return string

def main():
    line = sys.stdin.readline().strip()
    num_list = []
    for s in line:
        num_list.append(int(s))
    result = ""
    stack = []
    stack.append([])
    N = len(num_list)
    while(len(stack) != 0):
        l = stack.pop()
        if len(l) == N-1:
            if check(l, num_list):
                result = concat(l, num_list)
                break
        else:
            stack.append(l + ["+"]) # careful code
            stack.append(l + ["-"])

    print(result)