Starting from a list like this:
list = ["1-5", "1-6", "2-5", "2-6", "2-7", "2-8", "3-6", "3-7", "3-8", "4-1"]
I need to get this dict:
dict = {
"1-5": {"1-5": 1, "1-6":1, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"1-6": {"1-5": 1, "1-6":1, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"2-5": {"1-5": 0, "1-6":0, "2-5":1, "2-6":1, "2-7":1, "2-8":1, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"2-6": {"1-5": 0, "1-6":0, "2-5":1, "2-6":1, "2-7":1, "2-8":1, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"2-7": {"1-5": 0, "1-6":0, "2-5":1, "2-6":1, "2-7":1, "2-8":1, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"2-8": {"1-5": 0, "1-6":0, "2-5":1, "2-6":1, "2-7":1, "2-8":1, "3-6":0, "3-7":0, "3-8":0, "4-1":0},
"3-6": {"1-5": 0, "1-6":0, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":1, "3-7":1, "3-8":1, "4-1":0},
"3-7": {"1-5": 0, "1-6":0, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":1, "3-7":1, "3-8":1, "4-1":0},
"3-8": {"1-5": 0, "1-6":0, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":1, "3-7":1, "3-8":1, "4-1":0},
"4-1": {"1-5": 0, "1-6":0, "2-5":0, "2-6":0, "2-7":0, "2-8":0, "3-6":0, "3-7":0, "3-8":0, "4-1":1}
}
Basically the two dimensions are the same list. It's a square matrix and the binary values are based on the following condition:
If right(i,1) = right(j,1):
dict[i][j] = 1
else
dict[i][j] = 0
If the indexes i,j of the element dict[i][j] start with the same number (could be more than one, ex. "11-5") then dict[i][j] = 1, else dict[i][j] = 0
How can i write this in python?