Problem:


7 セグメント

  電卓などでよく目にするデジタル数字を表示している画面は、デジタル数字が 7 つの部分(セグメン
ト)で構成されることから、「7セグメントディスプレイ」と呼ばれています。

ワカマツ社で新しく売り出す予定の製品は、7セグメントディスプレイを製品に組み込むことになり、社員であるあなたは、与えられた数字を 7 セグメントディスプレイに表示するプログラムを作成することになりました。

  この7セグメントディスプレイは、次の切り替えの指示が送られてくるまで表示状態は変わりません。7 ビットからなるシグナルを送ることで、それぞれ対応したセグメントの表示情報を切り替える事ができます。ビットとは 1 か 0 の値を持つもので、ここでは 1 が「切り替え」、0 が「そのまま」を表します。

  各ビットとセグメントの対応関係は下の図のようになっています。シグナルは 7 つのビットを"gfedcba"の順番に送ります。例えば、非表示の状態から「0」を表示するためには"0111111"をシグナルとしてディスプレイに送らなければなりません。「0」から「5」に変更する場合には"1010010"を送ります。続けて「5」を「1」に変更する場合には"1101011"を送ります。

 表示したい n (1 ≤ n ≤ 100) 個の数字を入力とし、それらの数字 di (0 ≤ di ≤ 9) を順に 7 セグメントディスプレイに正しく表示するために必要なシグナル列を出力するプログラムを作成してください。なお、7 セグメントディスプレイの初期状態は全て非表示の状態であるものとします。

Input

複数のデータセットの並びが入力として与えられます。入力の終わりは-1 ひとつの行で示されます。
各データセットは以下の形式で与えられます。

n
d1
d2
:
dn

データセットの数は 120 を超えません。

Output

入力データセットごとに、数字をディスプレイに正しく出力するために必要なシグナルの列を出力してください。

Sample Input

3
0
5
1
1
0
-1

Output for the Sample Input

0111111
1010010
1101011
0111111



Sample input:
3
0
5
1
1
0
-1


Sample output:
0111111
1010010
1101011
0111111

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

seven_seg = {
        0: '0111111',
        1: '0000110',
        2: '1011011',
        3: '1001111',
        4: '1100110',
        5: '1101101',
        6: '1111101',
        7: '0100111',
        8: '1111111',
        9: '1101111'
        }

while True:
    seven_seg_state = ['0'] * 7
    n = int(input())
    if n == -1:
        break
    for _ in range(n):
        in_data = int(input())
        for i, s in enumerate(seven_seg_state):
            if seven_seg[in_data][i] == s:
                print("0", end="")
            else:
                print("1", end="")
            s = seven_seg[in_data][i]

        print()

Submission status: Wrong Answer

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Wrong Answer

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Wrong Answer

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=int(raw_input())
		e=0
		for i in range(n):
			a=ref[int(raw_input())]
			print "{:07b}".format(a^e)
			e=a
	except:
		break

Submission status: Wrong Answer

Solution code:
def signal(a,e):
	s=""
	for i in range(7):
		s+="0" if a[i]==e[i] else "1"
	return s

ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
while 1:
	try:
		n=int(raw_input())
		if n==-1:break
		e="0000000"
		for i in range(n):
			a=ref[int(raw_input())]
			print signal(a,e)
			e=a
	except:
		break

Submission status: Accepted

Solution code:
NUM = (
        0b0111111,
        0b0000110,
        0b1011011,
        0b1001111,
        0b1100110,
        0b1101101,
        0b1111101,
        0b0100111,
        0b1111111,
        0b1101111,
        )

while 1:
    n = int(input())
    if n == -1:break

    current = 0
    for i in range(n):
        num = NUM[int(input())]
        print(format(current ^ num,'b').zfill(7))
        current = num

Submission status: Accepted

Solution code:
import sys
f = sys.stdin

segment =[0b0111111,
0b0000110,
0b1011011,
0b1001111,
0b1100110,
0b1101101,
0b1111101,
0b0100111,
0b1111111,
0b1101111]

while True:
    n = int(f.readline())
    if n == -1:
        break
        
    display = 0
    for i in [int(f.readline()) for _ in range(n)]:
        print(bin(display ^ segment[i])[2:].zfill(7))
        display = segment[i]

Submission status: Accepted

Solution code:
Num_seg = [[0,1,1,1,1,1,1],[0,0,0,0,1,1,0],[1,0,1,1,0,1,1],[1,0,0,1,1,1,1],[1,1,0,0,1,1,0],[1,1,0,1,1,0,1],[1,1,1,1,1,0,1],[0,1,0,0,1,1,1],[1,1,1,1,1,1,1],[1,1,0,1,1,1,1]]
while True:
    n = int(input())
    if n == -1:
        break
    num_b = int(input())
    seg = ""
    for h in range(7):
        seg = seg + str(Num_seg[num_b][h])
    
    print(seg)
    for i in range(n - 1):
        num_a = int(input())
        seg = ""
        for j in range(7):
            if Num_seg[num_b][j] == Num_seg[num_a][j]:
                seg = seg + "0"
            else:
                seg = seg + "1"
        num_b = num_a
    
        print(seg)

Submission status: Accepted

Solution code:
s=[0b0111111,0b0000110,0b1011011,0b1001111,0b1100110,0b1101101,0b1111101,0b0100111,0b1111111,0b1101111]
while 1:
    n=int(input())
    if n<0:break
    a=0
    for _ in range(n):
        b=int(input())
        print(bin(a^s[b])[2:].zfill(7))
        a=s[b]

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

seven_seg = {
        0: '0111111',
        1: '0000110',
        2: '1011011',
        3: '1001111',
        4: '1100110',
        5: '1101101',
        6: '1111101',
        7: '0100111',
        8: '1111111',
        9: '1101111'
        }

while True:
    seven_seg_state = ['0'] * 7
    n = int(input())
    if n == -1:
        break
    for _ in range(n):
        in_data = int(input())
        for i in range(7):
            if seven_seg[in_data][i] == seven_seg_state[i]:
                print("0", end="")
            else:
                print("1", end="")
            seven_seg_state[i] = seven_seg[in_data][i]

        print()

Submission status: Accepted

Solution code:
# Aizu Problem 0228: Seven Segments

import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


digits = [63, 6, 91, 79, 102, 109, 125, 39, 127, 111]

while True:
    n = int(input())
    if n == -1:
        break
    e = 0
    for i in range(n):
        a = digits[int(input())]
        print("{:07b}".format(a^e))
        e = a

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0228

"""
import sys
from sys import stdin
input = stdin.readline


LED_pattern = [
    ##-gfedcba
    0b0111111,                #  0
    0b0000110,                #  1
    0b1011011,                #  2
    0b1001111,                #  3
    0b1100110,                #  4
    0b1101101,                #  5
    0b1111101,                #  6
    0b0100111,                #  7
    0b1111111,                #  8
    0b1101111,                #  9
    0b0000000                 #  all OFF
]


def solve(cp, np):
    a = LED_pattern[cp]
    b = LED_pattern[np]
    return bin(a ^ b)[2:].zfill(7)


def main(args):
    while True:
        n = int(input())
        if n == -1:
            break
        cp = 10                 #  all OFF
        for _ in range(n):
            d = int(input())
            ans = solve(cp, d)
            cp = d
            print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
# AOJ 0228: Seven Segments
# Python3 2018.6.25 bal4u

p = [[1,1,1,1,1,1,0], [0,1,1,0,0,0,0], [1,1,0,1,1,0,1], [1,1,1,1,0,0,1], [0,1,1,0,0,1,1], \
     [1,0,1,1,0,1,1], [1,0,1,1,1,1,1], [1,1,1,0,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,0,1,1]]

while True:
	n = int(input())
	if n < 0: break
	a = [0]*7
	for i in range(n):
		d = int(input())
		ans = ''
		for j in range(6,-1,-1):
			k = (a[j] ^ p[d][j]) & 1
			ans += '1' if k else '0'
			if k: a[j] = 1-a[j]
		print(ans)

Submission status: Accepted

Solution code:
dic = {0:"0111111", 1:"0000110", 2:"1011011", 3:"1001111", 4:"1100110",
       5:"1101101", 6:"1111101", 7:"0100111", 8:"1111111", 9:"1101111"}

while True:
  n = int(input())
  if n == -1:
    break
  dig = "0" * 7
  for _ in range(n):
    d = dic[int(input())]
    put = ""
    for i in range(7):
      if dig[i] != d[i]:
        put += "1"
      else:
        put += "0"
    print(put)
    dig = d

Submission status: Accepted

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=int(raw_input())
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[int(raw_input())]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass

Submission status: Accepted

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=input()
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[input()]
			print "{:07b}".format(a^e)
			e=a
	except:
		pass

Submission status: Accepted

Solution code:
seg = [[0, 1, 1, 1, 1, 1, 1],
[0, 0, 0, 0, 1, 1, 0], 
[1, 0, 1, 1, 0, 1, 1], 
[1, 0, 0, 1, 1, 1, 1],
[1, 1, 0, 0, 1, 1, 0], 
[1, 1, 0, 1, 1, 0, 1], 
[1, 1, 1, 1, 1, 0, 1], 
[0, 1, 0, 0, 1, 1, 1], 
[1, 1, 1, 1, 1, 1, 1], 
[1, 1, 0, 1, 1, 1, 1]]

while True :
    n = int(input())
    if n == -1 :
        break
    pre = [0]*7
    for i in range(n) :
        num = int(input())
        post = seg[num]
        for j in range(7) :
            if pre[j] == post[j] :
                print(0, end='')
            else :
                print(1, end='')
        print()
        pre = post

Submission status: Accepted

Solution code:
# AOJ 0228: Seven Segments
# Python3 2018.6.25 bal4u
 
p = [[1,1,1,1,1,1,0], [0,1,1,0,0,0,0], [1,1,0,1,1,0,1], [1,1,1,1,0,0,1], [0,1,1,0,0,1,1], \
     [1,0,1,1,0,1,1], [1,0,1,1,1,1,1], [1,1,1,0,0,1,0], [1,1,1,1,1,1,1], [1,1,1,1,0,1,1]]
 
while True:
    n = int(input())
    if n < 0: break
    a = [0]*7
    for i in range(n):
        d = int(input())
        ans = ''
        for j in range(6,-1,-1):
            k = (a[j] ^ p[d][j]) & 1
            ans += '1' if k else '0'
            if k: a[j] = 1-a[j]
        print(ans)

Submission status: Accepted

Solution code:
nums = ["0111111", "0000110", "1011011", "1001111", "1100110",
        "1101101", "1111101", "0100111", "1111111", "1101111"]

while 1:
    n = int(input())
    if n == -1:
        break

    sig = "0000000"
    for _ in range(n):
        d = int(input())
        num = nums[d]
        out = ""
        for s, n in zip(sig, num):
            if s == n:
                out += "0"
            else:
                out += "1"

        print(out)
        sig = num

Submission status: Runtime Error

Solution code:
L=[
"0111111",
"0000110",
"1011011",
"1001111",
"1100110",
"1101101",
"1111101",
"0100111",
"1111111",
"1111110"]
while True:
    n=input()
    if n==-1:break
    t="0000000"
    for i in range(n):
        a=input()
        print "".join("1" if L[a][i]<>t[i] else "0" for i in range(len(L[a])))
        t=L[a]

Submission status: Runtime Error

Solution code:
L=[
"0111111",
"0000110",
"1011011",
"1001111",
"1100110",
"1101101",
"1111101",
"0100111",
"1111111",
"1111110"]
while True:
    n=input()
    if n==-1:break
    t="0000000"
    for i in range(n):
        a=input()
        print "".join("1" if i<>j else "0" for i,j in zip(L[a],t))
        t=L[a]

Submission status: Runtime Error

Solution code:
L=[
"0111111",
"0000110",
"1011011",
"1001111",
"1100110",
"1101101",
"1111101",
"0100111",
"1111111",
"1111110"]
while True:
    n=input()
    if n==-1:break
    t="0000000"
    for i in range(n):
        a=input()
#        print "".join("1" if i<>j else "0" for i,j in zip(L[a],t))
        f=""
        for j,k in zip(L[a],t):
            f+="1" if j<>k else "0"
        print f
        t=L[a]

Submission status: Runtime Error

Solution code:
L=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1111110"]
while True:
    n=input()
    if n==-1:break
    t="0000000"
    for i in range(n):
        a=input()
        print "".join(["1" if i<>j else "0" for i,j in zip(L[a],t)])
        t=L[a]

Submission status: Runtime Error

Solution code:
D={0: '0111111', 1: '0000110', 2: '1011011', 3: '1001111', 4: '1100110', 5: '1101101', 6: '1111101', 7: '0100111', 8: '1111111\
', 9: '1111110'}
while True:
    n=input()
    if n==-1:break
    t="0000000"
    for i in range(n):
        a=input()
        print "".join(["1" if i<>j else "0" for i,j in zip(D[a],t)])
        t=D[a]

Submission status: Runtime Error

Solution code:
dig = ["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
dc = [ ["".join(str(int(dig[i][k])^int(dig[j][k])) for k in range(7)) for j in range(10)] for i in range(10)]
while 1:
    n = input()
    if n==-1: break
    buf = -1
    for i in range(n):
        num = input()
        if buf==-1:
            print dig[num]
        else:
            print dc[buf][num]
        buf = num

Submission status: Runtime Error

Solution code:
def signal(a,e):
	s=""
	for i in range(7):
		s+="0" if a[i]==e[i] else "1"
	return s
		

ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
while 1:
	n=input()
	if n==-1:break
	e="0000000"
	for i in range(n):
		a=ref[int(raw_input())]
		print signal(a,e)
		e=a

Submission status: Runtime Error

Solution code:
def signal(a,e):
	s=""
	for i in range(7):
		s+="0" if a[i]==e[i] else "1"
	return s

ref=["0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111"]
while 1:
	n=int(raw_input())
	if n==-1:break
	e="0000000"
	for i in range(n):
		a=ref[int(raw_input())]
		print signal(a,e)
		e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=input()
	if n==-1:break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print "{:07b}".format(a^e)
		e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=input()
	if n==-1:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==10:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n<0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n+1==0:break
	e=0
	#for i in range(n):
	#	a=ref[int(raw_input())]
	#	print "{:07b}".format(a^e)
	#	e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==0:break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print "{:07b}".format(a^e)
		e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n<=0:break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print "{:07b}".format(a^e)
		e=a

Submission status: Runtime Error

Solution code:
loop do
  n =gets.to_i
  break if n==-1
end

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:
		break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print ("{:07b}".format(a^e))
		e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	n=int(raw_input())
	if n==-1:break
	e=0
	for i in range(n):
		a=ref[int(raw_input())]
		print "{:07b}".format(a^e)
		e=a

Submission status: Runtime Error

Solution code:
ref=[63,6,91,79,102,109,125,39,127,111]
while 1:
	try:
		n=int(raw_input())
		if n==-1:break
		e=0
		for i in range(n):
			a=ref[int(raw_input())]
			print "{:07b}".format(a^e)
			e=a
	except SyntaxError:
		pass