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

deleted 20 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 26 bytes

".ɓœṡnŒs$Œg§ḟ0ドル%5Ḍœrƭ0ドルj9t

A full program that accepts a string and prints the Rockstar poetic number literal.

Try it online! Or see the test-suite.

How?

".ɓœṡnŒs$Œg§ḟ0ドル%5Ḍœrƭ0ドルj9t - Main Link: list of characters, Poem
".ɓ - start a new chain f(Poem, Dot='.')
 œṡ - split Poem at the first Dot
 nŒs$ - not equal swapped-case? (vectorises)
 Œg - group runs of equal elements
 (only vectorises at depth 1)
 § - sums
 ḟ0ドル - filter zeros from each
 %5 - mod ten
 € - for each:
 ƭ - alternate between:
 Ḍ - 1) convert from decimal
 -> integer part as an integer
 œr 0 - 2) trim zeros from right
 -> decimal part as a digit list
 j9 - join with a Dot
 t - trim any Dots from either side
 (removes a potential trailing dot)
 - implicit, smashing print

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