An acrostic is a style of poem/writing where the beginning character of each line, when read vertically, also produces a word or message. For example,
Together Everyone Achieves More
also spells out the word
TEAM when the first column is read vertically.
Acrostics are a subset of mesostics, where the vertical word can be anywhere in the horizontal words. For example, the
TEAM one above could also be written as a mesostic as follows
togeTher everyonE Achieves More
along with several other variations.
The challenge here will be to produce an acrostic or mesostic from a given list of input words.
- A list of words in any any suitable format.
- The list will only contain words made from lowercase
- The list is guaranteed to form an acrostic or a mesostic (no need to handle bogus input).
- One of the words in the input will form the vertical word, while the rest make the horizontal words - part of the challenge here is to find the appropriate vertical word, so it cannot be taken separately.
- The ASCII-art acrostic or mesostic formed from the input words, written to STDOUT or returned, in any reasonable format.
- The corresponding vertical word must be capitalized (as in the examples).
- Leading spaces to get the vertical word to line up appropriately are required. Trailing spaces, and leading/trailing newlines are optional. Extra leading spaces are fine as well, so long as the words align correctly.
- If both an acrostic and mesostic are possible, output only the acrostic.
- If more than one acrostic/mesostic is possible, your code can output any or all of them.
- Either a full program or a function are acceptable.
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
['together', 'team', 'everyone', 'achieves', 'more'] Together Everyone Achieves More ['aaa', 'aaa', 'aaa', 'aaa'] Aaa Aaa Aaa # One output, or multiple (of the same) output is allowed ['aaa', 'aaa', 'aab', 'baa'] Aaa Aaa Baa # This is the only allowed output, since others would be mesostic, which are lower priority ['live', 'every', 'love', 'very', 'ohio'] Live Ohio Very Every # Note that 'live' couldn't be the vertical word since then it would be a mesostic, which is lower priority output ['cow', 'of', 'fox'] cOw Fox # A shorter mesostic test case ['late', 'ballroom', 'anvil', 'to', 'head'] anviL bAllroom To hEad