@ajsindri/

Reinin Dichotomy Combination Genorator

Python 2.7

by Andrew Joynton

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#Harmony Calcuation for dichotomy level reinin structures 

#Dichotomies in vector order
P=   'P'    #0001
T=   'T'    #0010
TP=  'TP'   #0011
N=   'N'    #0100
NP=  'NP'   #0101
NT=  'NT'   #0110
NTP= 'NTP'  #0111
E=   'E'    #1000
EP=  'EP'   #1001
ET=  'ET'   #1010
ETP= 'ETP'  #1011
EN=  'EN'   #1100
ENP= 'ENP'  #1101
ENT= 'ENT'  #1110
ENTP='ENTP' #1111

#Reorders vectors when printed
reorder = [0,8,4,2,1,12,10,9,6,5,3,14,13,11,7,15]

#List of dichotomies in vector order
cellList = ['IDENTITY',P,T,TP,N,NP,NT,NTP,E,EP,ET,ETP,EN,ENP,ENT,ENTP]

#Dichotomy variable from index number
nameList = ['IDENTITY','P','T','TP','N','NP','NT','NTP','E','EP','ET','ETP','EN','ENP','ENT','ENTP']

#List Index
list1=    [''] #0000
listP=    [''] #0001
listT=    [''] #0010
listTP=   [''] #0011
listN=    [''] #0100
listNP=   [''] #0101
listNT=   [''] #0110
listNTP=  [''] #0111
listE=    [''] #1000
listEP=   [''] #1001
listET=   [''] #1010
listETP=  [''] #1011
listEN=   [''] #1100
listENP=  [''] #1101
listENT=  [''] #1110
listENTP= [''] #1111

listList = [list1,listP,listT,listTP,listN,listNP,listNT,listNTP,listE,listEP,listET,listETP,listEN,listENP,listENT,listENTP]


#FUNCTIONS

#Print list items with line space at end
def printList(arg1):
	i = 1
	loop=len(arg1)
	while (i < loop):
		
		if i == 1:
		  print("")
		  print('7 Small Group Level Relationships:')
		
		if i == 8:
		  print("")
		  print('28 Dyad Level Relationships:')
		
		if i == 36:
		  print("")
		  print('56 Type Level Relationships:')
		
		print(arg1[i])
		i = i + 1
	print ("")

#Add new item to bottom of list
def addLast(item,list):
	list.insert(len(list),item)

#vector addition for two dichotomy vectors strings
def vectorAdd (vector1,vector2):
	vector1=str(vector1)
	vector2=str(vector2)
	a=( int(vector1[0]) + int(vector2[0]) )%2 #Mod 2 addition, 1+0=1  1+1=0
	b=( int(vector1[1]) + int(vector2[1]) )%2
	c=( int(vector1[2]) + int(vector2[2]) )%2
	d=( int(vector1[3]) + int(vector2[3]) )%2
	vector3=str(a)+str(b)+str(c)+str(d)  #Recontructs output vector string
	return(vector3)

#Converts boolean vector to integer equivelent to use with list indexing	
def vectorToInt (vector):
	vector=str(vector)
	a=int(vector[0])*8+int(vector[1])*4+int(vector[2])*2+int(vector[3])
	return a

#Converts a number 0-15 into a vector string
def intToVector (integer):
	integer = ''.join(str(1 & int(integer) >> i) for i in range(4)[::-1])
	return integer

	
#PROGRAM

#Small group level constructions, 7 for each dichotomy
w=1
while (w<16):
	vw=intToVector(reorder[w]) #w as a vector
	
	x=w+1
	while (x<16):
		vx=intToVector(reorder[x]) #x as a vector
		
		if vw!=vx: 
			formula = '='+cellList[reorder[w]]+'*'+cellList[reorder[x]]
			location = listList[vectorToInt(vectorAdd(vw,vx))]
			addLast( formula, location)
		
		x=x+1
	w=w+1

#Dyad level constructions, 28 for each dichotomy
w=1
while (w<16):
	vw=intToVector(reorder[w]) #w as a vector
	x=w+1
	while (x<16):
		vx=intToVector(reorder[x]) #x as a vector
		
		if w!=x: 
			y=x+1
			while (y<16):
				vy=intToVector(reorder[y]) #y as a vector
				if vectorAdd(vw,vx)!=vy:
					formula = '='+cellList[reorder[w]]+'*'+cellList[reorder[x]]+'*'+cellList[reorder[y]]
					location = listList[vectorToInt(vectorAdd(vectorAdd(vw,vx),vy))]
					addLast( formula, location)
				y=y+1
		x=x+1
	w=w+1

#Type level constructions, 56 for each dichotomy
w=1
while (w<16):
	vw=intToVector(reorder[w]) #w as a vector
	x=w+1
	while (x<16):
		vx=intToVector(reorder[x]) #x as a vector
		
		if w!=x: 
			y=x+1
			while (y<16):
				vy=intToVector(reorder[y]) #y as a vector
				if vectorAdd(vw,vx)!=vy and vw!=vy and vx!=vy:
					z=y+1
					while (z<16):
						vz=intToVector(reorder[z]) #z as a vector
						
						v4=vectorAdd(vw,vx)
						v5=vectorAdd(vw,vy)
						v6=vectorAdd(vx,vy)
						v7=vectorAdd(vectorAdd(vw,vx),vy)
						
						if (vz!=v4) and (vz!=v5) and (vz!=v6) and (vz!=v7):
							formula = '='+cellList[reorder[w]]+'*'+cellList[reorder[x]]+'*'+cellList[reorder[y]]+'*'+cellList[reorder[z]]
							location = listList[vectorToInt(vectorAdd(vectorAdd(vectorAdd(vw,vx),vy),vz))]
							addLast( formula, location)
						z=z+1
				y=y+1
		x=x+1
	w=w+1

#PRINT RESULTS

i=1
while i<16:
  
	print(nameList[reorder[i]])
	printList(listList[reorder[i]])
	print('----------------------------------')
	print('')
	
	i=i+1
	
#END PROGRAM