Skip to content

Instantly share code, notes, and snippets.

View darshinshah's full-sized avatar

Darshin Shah darshinshah

  • United States of America
View GitHub Profile
@darshinshah
darshinshah / KERBEROS_SIMULATION.py
Last active September 12, 2018 07:13
A simulation of KERBEROS in Python
import numpy as np
userDB = ['Anmol','Mohit','Meet','Darshin','Prasham','Yash','Harsh','Shaunak','Rushad']
kdc_name = 'MyKDC'
session_key1 = 1
tgt_private_key = 3
user_private_key = 5
session_key2 = 2
service_key_private = 10
def client_login(username,user_ip):
@darshinshah
darshinshah / Astar.py
Created September 6, 2018 10:05
A Star (A*) Search Using Heuristic - Implementation in Python
import numpy as np
def initialize():
graph=np.array([
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,140, 118, 0 ,0, 75],
[0, 0 ,0 ,0 ,0 ,211 ,90 ,0 ,0 ,0 ,0 ,0 ,0 ,101 ,0 ,0 ,0 ,85 ,0 ,0],
[0 ,0 ,0 ,120 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,138 ,146 ,0 ,0 ,0 ,0 ,0],
[0 ,0 ,120 ,0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[0, 211, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0],
@darshinshah
darshinshah / Snakes Game using JavaScript.html
Created August 24, 2018 15:12
Snakes Game using JavaScript
<canvas id="gameCanvas"></canvas>
<script>
window.onload = function(){
canv = document.getElementById("gameCanvas"); //canvas id used for something????
canv.width=screen.width;
canv.height=screen.height;
ctx = canv.getContext("2d"); //context of the game i.e. 2D
document.addEventListener("keydown",keyPush); //listening for a keyboard input
setInterval(game,1000/14); //refreshing or rendering the game in these many seconds
@darshinshah
darshinshah / Airlines Static Program in JAVA.java
Created August 24, 2018 15:12
Airlines Static Program in JAVA
import java.io.*;
import java.util.*;
class project
{
double pr,at=0.03,fs=0.05;//at=airport taxes(3%), fs=fuel surcharge(5%);
int a,a1,a2,a3,a4,a5,b1,b2,b3,b4,b5,c1,c2,c3,c4,c5,ch,j,l,b,n,k=0,m=0,q=0,f=0,g=0,h=0,o=0,p=0,pay,r=0,s=0,t=0,u=0,x,y,z,cl,num,year,dat,mon,enter,flag;
String or="",de="",cot="",dt,em,mod="",ad1,ad2,ad3,ad4,ad5,ad6,ad7,ad8; //or=origin,de=destination,n=flight number,pr=price
long ph_no;
String name[]=new String[100];
@darshinshah
darshinshah / Greedy Best First Search in Python.py
Created August 24, 2018 15:11
Greedy Best First Search in Python
import numpy as np
from queue import PriorityQueue
def initialize():
graph=np.array([
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,0 ,0 ,1],
[0 ,0 ,0 ,0 ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,1 ,0 ,0],
[0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,1 ,0 ,0 ,0 ,0 ,0],
[0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0],
[0 ,0 ,0 ,0 ,0 ,0 ,0 ,1 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0],
@darshinshah
darshinshah / Winner-Take-It-All Neural Network in Python.py
Created August 24, 2018 15:10
Winner-Take-It-All Neural Network in Python
import numpy as np
#numpy is used for working with arrays
inputX, outputY = input("Enter the number of input and output nodes:").split(' ')
inputX= int(inputX)
outputY= int(outputY)
alpha = 0.8
lines=np.zeros((outputY,inputX))
outs = [0]*outputY
Xvals = [0]*inputX
Xvals = np.asarray(Xvals)
@darshinshah
darshinshah / Vernam Cipher in Python.py
Created August 24, 2018 15:10
Vernam Cipher in Python
ciphertext=input("Enter the text: ")
ciphertext = ciphertext.lower()
key=input("Enter the Key: ")
key = key.lower()
hi=[0]*len(ciphertext)
if(len(ciphertext)==len(key)):
print("Length are same : ")
for i in range(0,len(key)):
hi[i]=chr(((ord(ciphertext[i])+ord(key[i])-194)%26)+97)
print(hi)
@darshinshah
darshinshah / RSA Algorithm in Python.py
Created August 24, 2018 15:10
RSA Algorithm in Python
p = int(input('Enter the First Prime No. : '))
q = int(input('Enter the Second Prime No. : '))
n=p*q
z=(p-1)*(q-1)
def gcd(x, y):
while(y):
x, y = y, x % y
return x
@darshinshah
darshinshah / Ellipse Mid Point Algorithm in Python.cpp
Created August 24, 2018 15:09
Ellipse Mid Point Algorithm in Python
from graphics import *
import time
def DrawEllipse(R1,R2):
global p2
x = 0
y = R2
r1 = R1*R1
r2= R2*R2
p1 = r2-(r1*R2) + (r1/4)
@darshinshah
darshinshah / DDA Line Drawing Algorithm in Python.py
Created August 24, 2018 15:09
DDA Line Drawing Algorithm in Python
from graphics import *
import time
def DAA(x1, y1, x2, y2):
dx = abs(x2 - x1)
dy = abs(y2 - y1)
slope = float(dy) / float(dx)
win = GraphWin('DAA Line', 600, 600)
if slope > 1:
temp1 = x1