Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created June 21, 2020 15:26
Show Gist options
  • Save DongguemYoo/bc5c46cbea10ffbc7e8cfa196f1a6c2c to your computer and use it in GitHub Desktop.
Save DongguemYoo/bc5c46cbea10ffbc7e8cfa196f1a6c2c to your computer and use it in GitHub Desktop.
[정올] 1291 구구단 python
# 포인트 strFormat = '%-1s * %-1s = %+2s' 문자열을 원하는 형태로 정렬 +,-를 이용해서 우,좌 정렬을 할수있다.
def gugudan(n):
strFormat = '%-1s * %-1s = %+2s'
s = ''
start = int(n[0])
end =0
FloorValue =1
if start == int(max(n)):
end = int(min(n))
FloorValue = -1
else:
end = int(max(n))
for i in range(1,10):
s =''
for j in range(int(start),int(end)+FloorValue,FloorValue):
if int(j) != int(end):
s += strFormat %(str(j),str(i),str(int(j)*i))+" "
else:
s += strFormat % (str(j), str(i), str(int(j) * i))
print(s)
while(True):
isable = True
result =[]
data = input().split()
for j in range(0, len(data)):
if int(data[j]) <2 or int(data[j])>9:
print('INPUT ERROR!')
isable=False
break
else:
if len(result) == 0:
result.append(data[j])
else:
for i in range(0,len(result)):
if result[i]!=data[j]:
result.append(data[j])
if len(result)!= 0 and isable:
gugudan(result)
# for i in range(1,10):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment