[ create a new paste ] login | about

Link: http://codepad.org/9vAueM6r    [ raw code | output | fork ]

tackle - Python, pasted on Sep 2:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
listL = ['aaa', 'bbb', 'ccc', 'bbb', 'eee', 'hhhh']
listR = ['bbb', 'ddd', 'eee', 'fff', 'ggg', 'iiiii']
 
setL = set(listL)
setR = set(listR)
 
print '[left only] %s' % ' '.join(sorted(list(setL - setR)))
print '[right only] %s' % ' '.join(sorted(list(setR - setL)))
print '[both] %s' % ' '.join(sorted(list(setL & setR)))
 
all_items = sorted(list(setL | setR))
max_left_item_length = max([len(v) for v in setL])
output_format = '%%-%ds | %%s' % max_left_item_length
for out in [(v in setL and v or '', v in setR and v or '') for v in all_items]:
    print output_format % out


Output:
1
2
3
4
5
6
7
8
9
10
11
12
[left only] aaa ccc hhhh
[right only] ddd fff ggg iiiii
[both] bbb eee
aaa  | 
bbb  | bbb
ccc  | 
     | ddd
eee  | eee
     | fff
     | ggg
hhhh | 
     | iiiii


Create a new paste based on this one


Comments: