This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Hebbian | |
from math import exp | |
def hebbian(x_list, w, c, flg): | |
o = 0 | |
dptr = 0 | |
for xx in x_list: | |
net = [] | |
for i in range(len(xx)): | |
net.append(xx[i]*w[i]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import ceil | |
def columnarEncrypt(message, key): | |
print('your message is ', message) | |
message = message.replace(' ', '') | |
matrix_size = len(key) | |
rows = len(message)/len(key) | |
message = message.ljust(ceil(rows)*len(key), 'X') | |
print('message after padding', message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MaxHeap | |
{ | |
private int[] Heap; | |
private int size; | |
private int maxsize; | |
private static final int FRONT = 1; | |
public MaxHeap(int maxsize) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bitswaprequired(a, b): | |
count = 0 | |
c = a^b | |
while(c != 0): | |
count += c & 1 | |
c = c >> 1 | |
return count | |
print(bitswaprequired(12, 7)) | |
#OUTPUT = 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arr = [1, 2, 5, 4, 6, 8, 9, 2, 1, 4, 5, 8, 9] | |
v = 0 | |
for i in range(len(arr)): | |
v = v ^ arr[i] | |
print(value) | |
#OUTPUT = 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |