|
|
|
|
1000 abc 1100 def |
|
|
| I am XORing list_1 value with the key[i] |
def TEST ( _dict_pattern ): # suppose you send it a map containing things like { ( 0, 1, 1 ) : anything }
list_1 = [] # initialises output value as empty
_dict_2 = {}
for key in sorted( _dict_pattern.keys() ): # iterates through the map; let's start with key ( 0, 1, 1 )
list_1 = [] # (re)-initialise the output value as empty
list_1.append(orient) # now the list is [0]
for i in range(0,len(key)): # i ranges through 0, 1, 2 (the positions in the key)
result = (xor((list_1[-1]), key[i])) # xor the current last value in the list with the latest key position
# List starts [0]
# XOR 0 with 0 ... still 0, so
# List becomes [0,0]
# XOR 1 with 0 ... giving 1, so
# List becomes [0,0,1]
# XOR 1 with 1 ... giving 0, so
# List becomes [0,0,1,0]
list_1.append(result) # So now this particular pair is (0,1,1) : [0,0,1,0]
_dict_2[key] = list_1 # Changes this particular dictionary entry to (0,1,1) : [0,0,1,0] |
|
|
011 0010 100 0111 |
| Shruthi LS wrote: |
|---|
| Can you please help me in getting this c++ version of the code. |