Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

#Python, (削除) 158 (削除ここまで)(削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

Python, (削除) 158 (削除ここまで)(削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

r=range
s=int(raw_input())
a=map(chr,range(65,91))
for i in r(0,s)+r(0,s-1)[::-1]:
 print (' '.join(a[:i+1]+a[:i][::-1])).center(s*4-2,' '))

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

EDITS:

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces.

#Python, (削除) 158 (削除ここまで)(削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

r=range
s=int(raw_input())
a=map(chr,range(65,91))
for i in r(0,s)+r(0,s-1)[::-1]:
 print (' '.join(a[:i+1]+a[:i][::-1])).center(s*4-2,' '))

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

EDITS:

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces.

Python, (削除) 158 (削除ここまで)(削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

r=range
s=int(raw_input())
a=map(chr,range(65,91))
for i in r(0,s)+r(0,s-1)[::-1]:
 print (' '.join(a[:i+1]+a[:i][::-1])).center(s*4-2,' '))

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

EDITS:

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces.

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces. ; added 233 characters in body
Source Link

#Python, (削除) 158 (削除ここまで) 154(削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

import string
r = ranger=range
s = ints=int(raw_input())
a = string.uppercasea=map(chr,range(65,91))
for i in r(0,s) + r+r(0,s-1)[::-1]:
 print (a[0:i+1] +' a[0'.join(a[:i+1]+a[:i][::-1])).center(s*2s*4-12,' '))

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

EDITS:

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces.

#Python, (削除) 158 (削除ここまで) 154 bytes

import string
r = range
s = int(raw_input())
a = string.uppercase
for i in r(0,s) + r(0,s-1)[::-1]:
 print (a[0:i+1] + a[0:i][::-1]).center(s*2-1,' ')

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

#Python, (削除) 158 (削除ここまで) (削除) 154 (削除ここまで)(削除) 140 (削除ここまで) 139 bytes

r=range
s=int(raw_input())
a=map(chr,range(65,91))
for i in r(0,s)+r(0,s-1)[::-1]:
 print (' '.join(a[:i+1]+a[:i][::-1])).center(s*4-2,' '))

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

EDITS:

Thanks @Rod for the pointer to the helpful link to the Python code golf topic and also for reminding me that the letters need spaces between them. Also thanks @wec for the general tips about removing spaces.

Saved 4 bytes thanks to a comment @nedla2004 made to @nephi12
Source Link

#Python, 158(削除) 158 (削除ここまで) 154 bytes

import string
r = range
s = int(raw_input())
a = string.uppercase
z = s*2-1
for i in ranger(0,s) + ranger(0,s-1)[::-1]:
 print (a[0:i+1] + a[0:i][::-1]).center(zs*2-1, ' ')

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

#Python, 158 bytes

import string
s = int(raw_input())
a = string.uppercase
z = s*2-1
for i in range(0,s) + range(0,s-1)[::-1]:
 print (a[0:i+1] + a[0:i][::-1]).center(z, ' ')

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

#Python, (削除) 158 (削除ここまで) 154 bytes

import string
r = range
s = int(raw_input())
a = string.uppercase
for i in r(0,s) + r(0,s-1)[::-1]:
 print (a[0:i+1] + a[0:i][::-1]).center(s*2-1, ' ')

This is my first post so be gentle! I made heavy use of [::-1] to reverse strings, so maybe there's some optimization to be had there. Comments welcome.

Source Link
Loading

AltStyle によって変換されたページ (->オリジナル) /