给定两个不包含重复元素a和b的列表,找到两个列表之间的交叉,并输出一个ASCII。为了简单起见,Venn图将使用传统圆圈的规模化版本。
a = [1, 11, 'Fox', 'Bear', 333, 'Bee']
b = ['1', 333, 'Bee', 'SchwiftyFive', 4]+-----+----+-------------+
|11 |333 |SchwiftyFive |
|Fox |Bee |4 |
|Bear |1 | |
+-----+----+-------------+程序可以考虑'1' == 1或'1' != 1,直至您的实现。您还可以选择将所有内容都作为字符串处理,并且只接受字符串输入。
a=[]
b=[1,2,3]+-+-+--+
| | |1 |
| | |2 |
| | |3 |
+-+-+--+a=[1]
b=[1]+-+--+-+
| |1 | |
+-+--+-+|与-相遇的地方)的角必须由+表示。a.join(b).length() > 0都是空的,你可以做任何事情。木炭很自然地呈现出这样的盒子,但是整套理论部分.不知道它做得有多好。+100赏金,以最短的木炭提交,然后我才能增加一个赏金的问题(2天后被问)。
发布于 2021-01-25 10:21:30
ʒå}©K®¹®Kr)õζ'|ìøε€SζøJ}ø'|δªðý¬„|+`:D¬мS'-:.ø»ʒ # Filter the first (implicit) input-list by:
å # Check if the current item is in the second (implicit) input-list
}© # After the filter: store this overlap in variable `®` (without popping)
K # Pop and remove those items from the second (implicit) input-list
® # Push overlap `®`
¹ # Push the first input-list again
®K # Remove overlap `®`
r # Reverse the three lists on the stack
) # And wrap them into a list
ζ # Zip/transpose this list, swapping rows/columns,
õ # with "" as filler if the lists are of unequal length
'|ì '# Prepend an "|" in front of each inner string
ø # Zip/transpose back, swapping rows/columns
ε # Map over each row:
€ # Map over each string in this row:
S # Convert it to a list of characters
ζ # Zip/transpose, swapping rows/columns, with " " as default filler
ø # And then zip/transpose back
J # And join the strings back together
}ø # After the map: zip/transpose back
δ # Map over each row:
'| ª '# And append an "|" to it
ðý # Then join each inner-most list by spaces
¬ # Push the first row (without popping the list)
„|+`: # Replace all "|" with "+"
D # Duplicate this string
¬ # Push its first characters (without popping), which is a "+"
м # Remove all "+" from the duplicated string
S # Convert what remains to a list of characters
'-: '# Replace each character (except for "+") with "-"
.ø # Surround the list of rows with this string as leading/trailing items
» # And finally join the list by newlines
# (after which the result is output implicitly)https://codegolf.stackexchange.com/questions/120121
复制相似问题