Input will be one or more space separated characters followed by a long string on STDIN or as an argument when called from the shell.
a C WAtcIaElCpVqDRavOUejlgumcRCpfIWlaRFZpIoPYsWjsBSdlYfitfAPHpemiLpjaHheUGpFVQoZCnSCFgvpVzcoibdffoPRoJJwLIjVicPCdcvITXaQDjtMgrxQMZCkZNFmNqwGQYaSyPpdLOkAVHGVoVBiIksZCQHEaIxcRGwpIAmlChuhGEDajeJVXoCwFFuIvhEoqMuwrCDmZPcQxeaqJjynGWVjSaCCxWfupDbbEEFufDyealmbLxKfwlWCsSXwpPtuayxNVCodeEjeCIeHBYioeTogujuUFlWydOwInWGbsvlSwlwgfQaAmNTWPjsgqSCGzsJYfqGklpeLujFyrZJmNymUzpXLTkZcyPgPakAXTTfKlnnTCkjxxSZltwnLMOUCxlHOtLIUTqcbejXqyrwQgMaPUKcHBDZwMrCgwfVZUzxbdODBbBqEbpFLUOcPpVmsgLnfMXRWaddGnK
- Your task is to line-wrap the string at a suitable length so that there is at least one column completely filled by each input character. All lines should be wrapped to the same length (except possibly the last one if it's shorter.)
In this case, the solution could be wrapping at 50 characters giving the output
WAtcIaElCpVqDRavOUejlgumcRCpfIWlaRFZpIoPYsWjsBSdlY fitfAPHpemiLpjaHheUGpFVQoZCnSCFgvpVzcoibdffoPRoJJw LIjVicPCdcvITXaQDjtMgrxQMZCkZNFmNqwGQYaSyPpdLOkAVH GVoVBiIksZCQHEaIxcRGwpIAmlChuhGEDajeJVXoCwFFuIvhEo qMuwrCDmZPcQxeaqJjynGWVjSaCCxWfupDbbEEFufDyealmbLx KfwlWCsSXwpPtuayxNVCodeEjeCIeHBYioeTogujuUFlWydOwI nWGbsvlSwlwgfQaAmNTWPjsgqSCGzsJYfqGklpeLujFyrZJmNy mUzpXLTkZcyPgPakAXTTfKlnnTCkjxxSZltwnLMOUCxlHOtLIU TqcbejXqyrwQgMaPUKcHBDZwMrCgwfVZUzxbdODBbBqEbpFLUO cPpVmsgLnfMXRWaddGnK
The fifteenth (
a) and twenty-seventh (
C) all form a single column of the given input characters.
The last line may or may not be complete.
There can be more than one solutions. Any one of them can be considered valid.
Returning the string as-is is NOT allowed. (For those claiming that it forms one-row columns). The columns of the input characters must have at least two rows. You may assume that the input string is longer than 10 characters.
If there is no possible solution, your program must indicate this in some way(return status, printing "no solution", etc.) which you must mention.
Input will only include [a-zA-Z]
This is code-golf
Here's the actual program(python) that I use to generate these strings.
import random a = 10 b = 50 s = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' for i in xrange(a): c = '' for j in xrange(b): c += (random.choice(s)) print c
I then rectangle-edit to get columns full of input characters and strip newlines, deleting random number of characters from the end of the last line.