Submission #1783528


Source Code Expand

Copy
def buildstr(d,mask):
    s = '+'
    for i in xrange(len(mask)):
        s += d[i]
        if mask[i] == '1':
            s += '+'
        else:
            s += '-'
    s += d[-1]
    return s

def eval(s):
    add = True
    tot = 0
    for i in xrange(4):
        if s[2*i] == '-':
            add = False
        else:
            add = True
        if add:
            tot += int(s[2*i+1])
        else:
            tot -= int(s[2*i+1])
    return tot

d = list(raw_input())
for i in xrange(8):
    mask = bin(8+i)[3:]
    temp = buildstr(d,mask)
    if eval(temp) == 7:
        print temp[1:]+"=7"
        break

Submission Info

Submission Time
Task C - Train Ticket
User kcborys
Language Python2 (2.7.6)
Score 300
Code Size 649 Byte
Status
Exec Time 10 ms
Memory 2696 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 300 / 300 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
01.txt 10 ms 2692 KB
02.txt 10 ms 2692 KB
03.txt 10 ms 2692 KB
04.txt 10 ms 2692 KB
05.txt 10 ms 2692 KB
06.txt 10 ms 2692 KB
07.txt 10 ms 2692 KB
08.txt 10 ms 2692 KB
09.txt 10 ms 2692 KB
10.txt 10 ms 2692 KB
11.txt 10 ms 2696 KB
12.txt 10 ms 2692 KB
13.txt 10 ms 2692 KB
14.txt 10 ms 2696 KB
15.txt 10 ms 2692 KB
16.txt 10 ms 2692 KB
sample_01.txt 10 ms 2692 KB
sample_02.txt 10 ms 2696 KB
sample_03.txt 10 ms 2692 KB