8
1
Given two lists that contain no duplicate elements a
and b
, find the crossover between the two lists and output an ASCII-Art Venn Diagram. The Venn Diagram will use a squarified version of the traditional circles for simplicity.
Example
Given:
a = [1, 11, 'Fox', 'Bear', 333, 'Bee']
b = ['1', 333, 'Bee', 'SchwiftyFive', 4]
Output (Order is 100% arbitrary, as long as the Venn Diagram is correct):
+-----+----+-------------+
|11 |333 |SchwiftyFive |
|Fox |Bee |4 |
|Bear |1 | |
+-----+----+-------------+
The program may either consider '1' == 1
or '1' != 1
, up to your implementation. You may also choose to just handle everything as strings, and only accept string input.
Given:
a=[]
b=[1,2,3]
Output (Notice how the two empty parts still have the right-pad space):
+-+-+--+
| | |1 |
| | |2 |
| | |3 |
+-+-+--+
Given:
a=[1]
b=[1]
Output:
+-+--+-+
| |1 | |
+-+--+-+
Rules
- Elements of the Venn Diagram are left-aligned and padded to the max length entry plus 1.
- The ordering of the elements within sub-sections of the Venn-Diagram are arbitrary.
- Corners of the Venn Diagram (where
|
meets-
) must be represented by a+
. - You are garuanteed that
a.join(b).length() > 0
, if both are empty, you may do whatever.- You may even print a picture of Abe Lincoln, don't care.
- This is code-golf, ascii-art and set-theory.
Bonus
Charcoal renders boxes like this naturally, but the whole set theory part... Don't know how well it does that. +100 bounty for the shortest charcoal submission before I am able to add a bounty to the question (2 days from being asked).
3Personally, I feel that being able to support
'1' == 1
is a bit too much of a stretch – user41805 – 2017-05-11T19:07:16.067@KritixiLithos fair enough, updated the challenge spec so that it doesn't hurt those who have started. It is now your choice on how you want string to integer comparison to work, both choices being equally valid submissions. – Magic Octopus Urn – 2017-05-11T19:09:10.940
1Can we assume that the input will only contain strings? – Rod – 2017-05-11T19:10:08.083
Related. – Martin Ender – 2017-05-11T19:12:13.180
@Rod well, to be honest, yeah, sure; lets just go with that. – Magic Octopus Urn – 2017-05-11T19:24:01.577
In the first example, why does the middle box have two right-padding spaces? – L3viathan – 2017-05-11T21:57:29.657
1@L3viathan one mobile edit and your post is over. – Magic Octopus Urn – 2017-05-11T22:13:53.380