Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Fit a word into an alphabet grid

Inspired by a meme I saw earlier today.

Challenge description

Consider an infinite alphabet grid:

ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
ABCDEFGHIJKLMNOPQRSTUVWXYZ
...

Take a word (CODEGOLF in this example) and make it a subsequence of the grid, replacing unused letters by a space and removing letters at the end of the infinite grid altogether:

 C O 
 DE G O 
 L 
 F

Examples

STACKEXCHANGE

 ST 
A C K 
 E X 
 C H 
A N 
 G 
 E

ZYXWVUTSRQPONMLKJIHGFEDCBA

 Z
 Y 
 X 
 W 
 V 
 U 
 T 
 S 
 R 
 Q 
 P 
 O 
 N 
 M 
 L 
 K 
 J 
 I 
 H 
 G 
 F 
 E 
 D 
 C 
 B 
A

F

 F

ANTIDISESTABLISHMENTARIANISM

A N T 
 I 
 D I S 
 E ST 
AB L 
 I S 
 H M 
 E N T 
A R 
 I 
A N 
 I S 
 M

Notes

  • Trailing whitespaces are allowed.
  • You don't need to pad (削除) the last (削除ここまで) any line with spaces. For example, if the input is ABC, you may output just ABC without 23 trailing spaces.
  • You may assume input will match [A-Z]+ regex.
  • Alternatively, you may use lower-case alphabet, in which case output will match [a-z]+.
  • You must use a newline (\n, \r\n or equivalent) to separate lines, that is a list of strings is not a proper output format.
  • This is a challenge, so make your code as short as possible!

Answer*

Draft saved
Draft discarded
Cancel
1
  • 1
    \$\begingroup\$ 63 Bytes using splatting. Tried to use |% *ht to save some bytes but looks like it broke even. \$\endgroup\$ Commented Oct 9, 2019 at 17:10

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