from functools import reduce
ip = [
['192.168.1.1','168.95.98.254','168.95.83.70','220.128.2.226','220.128.1.101','168.95.25.13'],
['192.168.1.1','168.95.98.254','168.95.82.6','220.128.1.6','220.128.1.101','36.226.251.254']
]
nodeDict = {
'192.168.1.1': '0',
'168.95.98.254': '1',
'168.95.83.70': '2',
'220.128.2.226': '3',
'220.128.1.101': '4',
'168.95.25.13': '5',
'168.95.82.6': '6',
'220.128.1.6': '7',
'36.226.251.254': '8'
}
def genPath(ipList):
_ = list(map(lambda x: nodeDict.get(x), ipList))
return list("".join(z) for z in zip(_[:-1], _[1:]))
paths = [genPath(path) for path in ip]
h1 = reduce(lambda x, y: set(x)|set(y), paths)
ZnJvbSBmdW5jdG9vbHMgaW1wb3J0IHJlZHVjZQoKaXAgPSBbCglbJzE5Mi4xNjguMS4xJywnMTY4Ljk1Ljk4LjI1NCcsJzE2OC45NS44My43MCcsJzIyMC4xMjguMi4yMjYnLCcyMjAuMTI4LjEuMTAxJywnMTY4Ljk1LjI1LjEzJ10sCglbJzE5Mi4xNjguMS4xJywnMTY4Ljk1Ljk4LjI1NCcsJzE2OC45NS44Mi42JywnMjIwLjEyOC4xLjYnLCcyMjAuMTI4LjEuMTAxJywnMzYuMjI2LjI1MS4yNTQnXQpdCgpub2RlRGljdCA9IHsKCScxOTIuMTY4LjEuMSc6ICcwJywKCScxNjguOTUuOTguMjU0JzogJzEnLAoJJzE2OC45NS44My43MCc6ICcyJywKCScyMjAuMTI4LjIuMjI2JzogJzMnLAoJJzIyMC4xMjguMS4xMDEnOiAnNCcsCgknMTY4Ljk1LjI1LjEzJzogJzUnLAoJJzE2OC45NS44Mi42JzogJzYnLAoJJzIyMC4xMjguMS42JzogJzcnLAoJJzM2LjIyNi4yNTEuMjU0JzogJzgnCn0KCmRlZiBnZW5QYXRoKGlwTGlzdCk6CglfID0gbGlzdChtYXAobGFtYmRhIHg6IG5vZGVEaWN0LmdldCh4KSwgaXBMaXN0KSkKCXJldHVybiBsaXN0KCIiLmpvaW4oeikgZm9yIHogaW4gemlwKF9bOi0xXSwgX1sxOl0pKQoJCgpwYXRocyA9IFtnZW5QYXRoKHBhdGgpIGZvciBwYXRoIGluIGlwXQpoMSA9IHJlZHVjZShsYW1iZGEgeCwgeTogc2V0KHgpfHNldCh5KSwgcGF0aHMp