28
2
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.
Input
- A list of words in any any suitable format.
- The list will only contain words made from lowercase
[a-z]
. - 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.
Output
- 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.
Rules
- 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.
Examples
['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
It seems that in the cases where an acrostic is produced, the list will be in that order? – Leaky Nun – 2016-08-24T19:51:19.603
Can you have a shorter mesostic testcase? – Leaky Nun – 2016-08-24T20:33:11.153
1Are extra leading spaces allowed? – PurkkaKoodari – 2016-08-25T06:12:23.223
It doesn't say that the input is guaranteed to be sorted correctly, but judging from the test cases, they are. Are they? – aross – 2016-08-25T08:10:43.513
@aross They aren't (e.g. the
live ohio very every
test case, or the last one). – Martin Ender – 2016-08-25T08:18:28.433Dear god. I'll pass then – aross – 2016-08-25T08:30:52.137
2@Pietu1998 Sure, that's fine -- the important thing is that the words are lined up. I'll edit in that clarification. – AdmBorkBork – 2016-08-25T12:19:47.157