Skip to content

Instantly share code, notes, and snippets.

View maazrk's full-sized avatar
💭

Maaz Khan maazrk

💭
  • BrowserStack
  • India
View GitHub Profile
#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])
@maazrk
maazrk / columnarCipher.py
Last active August 1, 2017 18:43
An implementation of columnar transposition cipher
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)
class MaxHeap
{
private int[] Heap;
private int size;
private int maxsize;
private static final int FRONT = 1;
public MaxHeap(int maxsize)
{
@maazrk
maazrk / bitSwapRequired.py
Created July 9, 2017 16:39
Write a function to determine the number of bits required to convert integer A to integer B.
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
@maazrk
maazrk / nonRepeatedElementXOR.py
Last active January 27, 2022 04:06
Find the non-repeating element
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
@maazrk
maazrk / 0_reuse_code.js
Created March 28, 2017 09:28
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console