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

2 of 2
added explanation
ETHproductions
  • 50.3k
  • 6
  • 96
  • 241

Japt, 8 bytes

ËùDV*EvV

Test it online!

Explanation

 Ë ùDV*EvV
UmDE{DùDV*EvV} Ungolfed
 Implicit: U = s, V = n
UmDE{ } Replace each char D and (0-)index E in U by this function:
 EvV Take 1 if the index is divisible by V; 0 otherwise.
 V* Multiply this by V. This gives V for every Vth index; 0 for others.
 DùD Pad D with itself to this length. This gives V copies of D for every
 Vth index; 1 copy of D for others.
 Implicit: output last expression

I have to credit the idea to use ù to @Shaggy's answer here. I don't know that I ever would have thought of it myself...

ETHproductions
  • 50.3k
  • 6
  • 96
  • 241

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