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

81%
+7 −0
Challenges Print the Great Numeric Pyramid

Python 2, 76 bytes i=27 while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1 Try it online! Computes the digit in row i from the bottom, position j as min(i,j,27-i-j). F...

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

Answer
#6: Post edited by user avatar xnor‭ · 2020-11-14T05:41:39Z (over 3 years ago)
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • Computes the digit in row `i`, position `j` as `min(i,j,27-i-j)`.
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of leading zeroes:
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • Computes the digit in row `i` from the bottom, position `j` as `min(i,j,27-i-j)`.
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of leading zeroes:
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
#5: Post edited by user avatar xnor‭ · 2020-11-14T05:41:08Z (over 3 years ago)
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • Computes the digit in row `i`, position `j` as `min(i,j,27-i-j)`.
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of zeroes.
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • Computes the digit in row `i`, position `j` as `min(i,j,27-i-j)`.
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of leading zeroes:
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
#4: Post edited by user avatar xnor‭ · 2020-11-14T05:40:05Z (over 3 years ago)
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of zeroes.
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • Computes the digit in row `i`, position `j` as `min(i,j,27-i-j)`.
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of zeroes.
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
#3: Post edited by user avatar xnor‭ · 2020-11-14T05:38:49Z (over 3 years ago)
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
  • For comparison, a bad effect to compute the row numbers arithmetically, made harder by the presence of zeroes.
  • **109 bytes**
  • <!-- language-all: lang-python -->
  • for i in range(28):print" "*(27-i)+" ".join(str(10**min(27-i,i/2)/9*(10**max(2*i-27,-~i/2)/9)*10).zfill(i+1))
  • [Try it online!][TIO-khh9drk9]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh9drk9]: https://tio.run/##JckxEoIwEEbhq2SodhcCZBvU21AI/A5umJgCLbx6xKH75r3tnZdoWsoUk4ODuTTafCe98G1LsFy5SkgHD64Pto8Io1dOFHqR5@H/atApd1c547iTCrwOjf@egyX03H4mrCuhDsyl/AA "Python 2 – Try It Online"
#2: Post edited by user avatar xnor‭ · 2020-11-14T05:20:23Z (over 3 years ago)
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=26
  • while~i:print' '*i+' '.join(`min(i,j,26-i-j)`for j in range(27-i));i-=1
  • [Try it online!][TIO-khh8ohqk]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8ohqk]: https://tio.run/##DcSxCoAgFAXQva9wSyuDHAyK/qUGqyv1FBGipV9/eYYT33wGMsxYjK2eE5f7MMUEyrWoG7Tl3geQXO8SOt8Zq6G9WveQhBcgkTY6nDSjhlIz9DIw/w "Python 2 – Try It Online"
  • # [Python 2], 76 bytes
  • <!-- language-all: lang-python -->
  • i=27
  • while~i:print' '*i+' '.join(`min(i,j,27-i-j)`for j in range(28-i));i-=1
  • [Try it online!][TIO-khh8qgcy]
  • [Python 2]: https://docs.python.org/2/
  • [TIO-khh8qgcy]: https://tio.run/##DcSxCoAgFAXQva9wSyuDXIyif6nB6ko9RYRo6ddfnuHEN5@BDDMWY6vnxOU@TDGBci3qBm259wEk17uEznfGamiv1j0k4QVIpI0OJ82oodQMvQzMPw "Python 2 – Try It Online"
#1: Initial revision by user avatar xnor‭ · 2020-11-14T05:19:49Z (over 3 years ago)
# [Python 2], 76 bytes

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

    i=26
    while~i:print' '*i+' '.join(`min(i,j,26-i-j)`for j in range(27-i));i-=1

[Try it online!][TIO-khh8ohqk]

[Python 2]: https://docs.python.org/2/
[TIO-khh8ohqk]: https://tio.run/##DcSxCoAgFAXQva9wSyuDHAyK/qUGqyv1FBGipV9/eYYT33wGMsxYjK2eE5f7MMUEyrWoG7Tl3geQXO8SOt8Zq6G9WveQhBcgkTY6nDSjhlIz9DIw/w "Python 2 – Try It Online"