Given an input list of non-empty strings, output an ASCII art representation of a tournament, based on the following drawing rules:
- The number of strings is guaranteed to be of quantity
2,4,8,16,etc.
- The first two strings play each other, and the next two play each other, and so on. This is the first round.
- For each game, choose the winner randomly with equal probability.
- For the next round, the winner of the first game plays the winner of the second game, the winner of the third game plays the winner of the fourth game, and so on. Subsequent rounds follow the pattern.
- There is eventually one overall winner.
- For pretty output (required) the strings must all be prepended and appended with an underscore
_
. - In order for the brackets to line up appropriately, each entry must be padded with
_
to all be the same length for that round. - You can choose whether the padding is prepended or appended, so long as it's consistent.
- Instead, you can choose to pre-pad all strings to be the same length, rather than on a per-round basis. Whichever is golfier for your code.
Further Rules
- Leading or trailing newlines or whitespace are all optional, so long as the characters themselves line up correctly.
- Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
- If possible, please include a link to an online testing environment so other people can try out your code!
- Standard loopholes are forbidden.
- This is code-golf so all usual golfing rules apply, and the shortest code (in bytes) wins.
Examples
Example with cities ['Boston', 'New York', 'Charlotte', 'Atlanta', 'St. Paul', 'Chicago', 'Los Angeles', 'Phoenix']
:
_Boston______
\_New York____
_New York____/ \
\_New York_
_Charlotte___ / \
\_Charlotte___/ \
_Atlanta_____/ \
\_St. Paul_
_St. Paul____ /
\_St. Paul____ /
_Chicago_____/ \ /
\_St. Paul_/
_Los Angeles_ /
\_Los Angeles_/
_Phoenix_____/
Example with ['Lions', 'Tigers', 'Bears', 'Oh My']
:
_Lions__
\_Tigers_
_Tigers_/ \
\_Tigers_
_Bears__ /
\_Bears__/
_Oh My__/