Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Challenges

Post History

66%
+2 −0
Challenges Create an Alphabet Diamond

Python 3, 99 bytes r=[*range(26)] a="ABCDEFGHIJKLMNOPQRSTUVWXYZ" for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1]) Try it online!

posted 3y ago by celtschk‭  ·  edited 3y ago by celtschk‭

Answer
#2: Post edited by user avatar celtschk‭ · 2021-09-11T06:33:25Z (about 3 years ago)
Typing the alphabet directly turned out to be shorter
  • # [Python 3], 102 bytes
  • <!-- language-all: lang-python -->
  • r=[*range(26)]
  • a="".join([chr(i+65) for i in r])
  • for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1])
  • [Try it online!][TIO-ktfes5jl]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-ktfes5jl]: https://tio.run/##RYwxCoAwDAB3XxE6NZYKVnQo@JLSoYjaOKQSXHx9FReXg@PgzvvKhYdaZQ6tJN5X7SaMTZqV6o5CrMOSRZOZRoStCBAQg0RsfjESrPPe9tGfQnxpBap9N5bQpOApvqSvY60P "Python 3 – Try It Online"
  • # [Python 3], 99 bytes
  • <!-- language-all: lang-python -->
  • r=[*range(26)]
  • a="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  • for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1])
  • [Try it online!][TIO-ktfevokn]
  • [Python 3]: https://docs.python.org/3/
  • [TIO-ktfevokn]: https://tio.run/##K6gsycjPM/7/v8g2WqsoMS89VcPITDOWK9FWydHJ2cXVzd3D08vbx9fPPyAwKDgkNCw8IjJKiSstv0ghUyEzT6FIuyha18jKStcw1qqgKDOvRENJQUkLaIZupqZ2YrRVZiyQzATLa/7/DwA "Python 3 – Try It Online"
#1: Initial revision by user avatar celtschk‭ · 2021-09-11T06:30:41Z (about 3 years ago)
# [Python 3], 102 bytes

<!-- language-all: lang-python -->

    r=[*range(26)]
    a="".join([chr(i+65) for i in r])
    for i in r+r[-2::-1]:print(" "*(26-i)+a[:i]+a[i::-1])

[Try it online!][TIO-ktfes5jl]

[Python 3]: https://docs.python.org/3/
[TIO-ktfes5jl]: https://tio.run/##RYwxCoAwDAB3XxE6NZYKVnQo@JLSoYjaOKQSXHx9FReXg@PgzvvKhYdaZQ6tJN5X7SaMTZqV6o5CrMOSRZOZRoStCBAQg0RsfjESrPPe9tGfQnxpBap9N5bQpOApvqSvY60P "Python 3 – Try It Online"