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 Revisions

1 of 2
Neil
  • 184.4k
  • 12
  • 76
  • 290

Retina 0.8.2, 100 bytes


33$*.
.
$'¶
^.+
$&0$&
+1`(?<=(.)*)((0)\.\.|(0+|\.\.?)(.)).*¶.(?<-1>.)*(?(1)^)(?!.)
$&3ドル5ドル
.(.+).
1ドル

Try it online! Explanation:


33$*.
.
$'¶

Create a triangle of .s. The generation code below requires each line to start with a ., and creating a triangle is slightly golfier as well as probably faster.

^.+
$&0$&

Add 0 on the first line and append some more .s.

+1`

Make replacements one at a time. This is the code will actually generate a . below the two .s at the end of a line, and we only want this to apply as a last resort.

(?<=(.)*)((0)\.\.|(0+|\.\.?)(.)).*¶.(?<-1>.)*(?(1)^)(?!.)
$&3ドル5ドル

Look for either a 0.. pattern, where the 0 is captured, or either a 0. (but not 0..), 00., or 000 pattern, where the . is captured (in the case of 000, the next . is captured), or a .0, ..0 or ... (or at the end of a line ..) pattern, where the last character is captured, and append this character to the next line, if it would go underneath the middle character.

.(.+).
1ドル

Trim the leading and trailing . from each line.

Neil
  • 184.4k
  • 12
  • 76
  • 290

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