Last active
June 20, 2020 15:15
-
-
Save prkagrawal/c0a2b56fc6a7f5672ebfa363668a2047 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = int(input()) | |
# Part 1 | |
for i in range(n): | |
s = [] | |
for j in range(n): | |
if i+j-n >= 0: | |
s.append(str(i+j-n)) | |
else: | |
s.append(" ") | |
t = s[::-1] | |
s.append(str(i)) | |
s = s + t | |
s = ''.join(s) | |
print(s) | |
# Part 2 | |
t = [] | |
s = [] | |
for j2 in range(n): | |
s.append(str(j2)) | |
t = s[::-1] | |
s.append(str(n)) | |
s = s + t | |
s = ''.join(s) | |
print(s) | |
# Part 3 | |
for i3 in range(n): | |
s = [] | |
t = [] | |
for j3 in range(n): | |
if j3-i3-1 >= 0: | |
s.append(str(j3-i3-1)) | |
else: | |
s.append(" ") | |
t = s[::-1] | |
s.append(str(n-1-i3)) | |
s = s + t | |
s = ''.join(s) | |
print(s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment