mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
increment 1
This commit is contained in:
parent
90979777c7
commit
718b99ae39
|
@ -1,38 +0,0 @@
|
|||
import numpy as np
|
||||
import math
|
||||
import cv2
|
||||
|
||||
def Representational(r,g,b):
|
||||
return (0.299*r+0.287*g+0.114*b)
|
||||
|
||||
def calculate(img):
|
||||
b,g,r = cv2.split(img)
|
||||
pixelAt = Representational(r,g,b)
|
||||
return pixelAt
|
||||
|
||||
def main():
|
||||
|
||||
#Loading images (orignal image and compressed image)
|
||||
orignal_image = cv2.imread('orignal_image.png',1)
|
||||
compressed_image = cv2.imread('compressed_image.png',1)
|
||||
|
||||
#Getting image height and width
|
||||
height,width = orignal_image.shape[:2]
|
||||
|
||||
orignalPixelAt = calculate(orignal_image)
|
||||
compressedPixelAt = calculate(compressed_image)
|
||||
|
||||
diff = orignalPixelAt - compressedPixelAt
|
||||
error = np.sum(np.abs(diff) ** 2)
|
||||
|
||||
error = error/(height*width)
|
||||
|
||||
#MSR = error_sum/(height*width)
|
||||
PSNR = -(10*math.log10(error/(255*255)))
|
||||
|
||||
print("PSNR value is {}".format(PSNR))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 26 KiB |
Binary file not shown.
Before Width: | Height: | Size: 29 KiB |
Binary file not shown.
Before Width: | Height: | Size: 82 KiB |
|
@ -1,33 +0,0 @@
|
|||
import math
|
||||
|
||||
|
||||
def bisection(function, a, b): # finds where the function becomes 0 in [a,b] using bolzano
|
||||
|
||||
start = a
|
||||
end = b
|
||||
if function(a) == 0: # one of the a or b is a root for the function
|
||||
return a
|
||||
elif function(b) == 0:
|
||||
return b
|
||||
elif function(a) * function(b) > 0: # if none of these are root and they are both positive or negative,
|
||||
# then his algorithm can't find the root
|
||||
print("couldn't find root in [a,b]")
|
||||
return
|
||||
else:
|
||||
mid = (start + end) / 2
|
||||
while abs(start - mid) > 0.0000001: # until we achieve precise equals to 10^-7
|
||||
if function(mid) == 0:
|
||||
return mid
|
||||
elif function(mid) * function(start) < 0:
|
||||
end = mid
|
||||
else:
|
||||
start = mid
|
||||
mid = (start + end) / 2
|
||||
return mid
|
||||
|
||||
|
||||
def f(x):
|
||||
return math.pow(x, 3) - 2*x - 5
|
||||
|
||||
|
||||
print(bisection(f, 1, 1000))
|
|
@ -1,16 +0,0 @@
|
|||
import math
|
||||
|
||||
def intersection(function,x0,x1): #function is the f we want to find its root and x0 and x1 are two random starting points
|
||||
x_n = x0
|
||||
x_n1 = x1
|
||||
while True:
|
||||
x_n2 = x_n1-(function(x_n1)/((function(x_n1)-function(x_n))/(x_n1-x_n)))
|
||||
if abs(x_n2 - x_n1)<0.00001 :
|
||||
return x_n2
|
||||
x_n=x_n1
|
||||
x_n1=x_n2
|
||||
|
||||
def f(x):
|
||||
return math.pow(x,3)-2*x-5
|
||||
|
||||
print(intersection(f,3,3.5))
|
|
@ -1,34 +0,0 @@
|
|||
import numpy
|
||||
|
||||
def LUDecompose (table):
|
||||
#table that contains our data
|
||||
#table has to be a square array so we need to check first
|
||||
rows,columns=numpy.shape(table)
|
||||
L=numpy.zeros((rows,columns))
|
||||
U=numpy.zeros((rows,columns))
|
||||
if rows!=columns:
|
||||
return
|
||||
for i in range (columns):
|
||||
for j in range(i-1):
|
||||
sum=0
|
||||
for k in range (j-1):
|
||||
sum+=L[i][k]*U[k][j]
|
||||
L[i][j]=(table[i][j]-sum)/U[j][j]
|
||||
L[i][i]=1
|
||||
for j in range(i-1,columns):
|
||||
sum1=0
|
||||
for k in range(i-1):
|
||||
sum1+=L[i][k]*U[k][j]
|
||||
U[i][j]=table[i][j]-sum1
|
||||
return L,U
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
matrix =numpy.array([[2,-2,1],[0,1,2],[5,3,1]])
|
||||
L,U = LUDecompose(matrix)
|
||||
print(L)
|
||||
print(U)
|
|
@ -1,15 +0,0 @@
|
|||
def newton(function,function1,startingInt): #function is the f(x) and function1 is the f'(x)
|
||||
x_n=startingInt
|
||||
while True:
|
||||
x_n1=x_n-function(x_n)/function1(x_n)
|
||||
if abs(x_n-x_n1)<0.00001:
|
||||
return x_n1
|
||||
x_n=x_n1
|
||||
|
||||
def f(x):
|
||||
return (x**3)-2*x-5
|
||||
|
||||
def f1(x):
|
||||
return 3*(x**2)-2
|
||||
|
||||
print(newton(f,f1,3))
|
|
@ -1,36 +0,0 @@
|
|||
# Implementing Newton Raphson method in Python
|
||||
# Author: Haseeb
|
||||
|
||||
from sympy import diff
|
||||
from decimal import Decimal
|
||||
|
||||
def NewtonRaphson(func, a):
|
||||
''' Finds root from the point 'a' onwards by Newton-Raphson method '''
|
||||
while True:
|
||||
c = Decimal(a) - ( Decimal(eval(func)) / Decimal(eval(str(diff(func)))) )
|
||||
|
||||
a = c
|
||||
|
||||
# This number dictates the accuracy of the answer
|
||||
if abs(eval(func)) < 10**-15:
|
||||
return c
|
||||
|
||||
|
||||
# Let's Execute
|
||||
if __name__ == '__main__':
|
||||
# Find root of trigonometric function
|
||||
# Find value of pi
|
||||
print ('sin(x) = 0', NewtonRaphson('sin(x)', 2))
|
||||
|
||||
# Find root of polynomial
|
||||
print ('x**2 - 5*x +2 = 0', NewtonRaphson('x**2 - 5*x +2', 0.4))
|
||||
|
||||
# Find Square Root of 5
|
||||
print ('x**2 - 5 = 0', NewtonRaphson('x**2 - 5', 0.1))
|
||||
|
||||
# Exponential Roots
|
||||
print ('exp(x) - 1 = 0', NewtonRaphson('exp(x) - 1', 0))
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
# server
|
||||
|
||||
import socket # Import socket module
|
||||
|
||||
port = 60000 # Reserve a port for your service.
|
||||
s = socket.socket() # Create a socket object
|
||||
host = socket.gethostname() # Get local machine name
|
||||
s.bind((host, port)) # Bind to the port
|
||||
s.listen(5) # Now wait for client connection.
|
||||
|
||||
print('Server listening....')
|
||||
|
||||
while True:
|
||||
conn, addr = s.accept() # Establish connection with client.
|
||||
print('Got connection from', addr)
|
||||
data = conn.recv(1024)
|
||||
print('Server received', repr(data))
|
||||
|
||||
filename = 'mytext.txt'
|
||||
f = open(filename, 'rb')
|
||||
in_data = f.read(1024)
|
||||
while (in_data):
|
||||
conn.send(in_data)
|
||||
print('Sent ', repr(in_data))
|
||||
in_data = f.read(1024)
|
||||
f.close()
|
||||
|
||||
print('Done sending')
|
||||
conn.send('Thank you for connecting')
|
||||
conn.close()
|
||||
|
||||
|
||||
# client side server
|
||||
|
||||
import socket # Import socket module
|
||||
|
||||
s = socket.socket() # Create a socket object
|
||||
host = socket.gethostname() # Get local machine name
|
||||
port = 60000 # Reserve a port for your service.
|
||||
|
||||
s.connect((host, port))
|
||||
s.send("Hello server!")
|
||||
|
||||
with open('received_file', 'wb') as f:
|
||||
print('file opened')
|
||||
while True:
|
||||
print('receiving data...')
|
||||
data = s.recv(1024)
|
||||
print('data=%s', (data))
|
||||
if not data:
|
||||
break
|
||||
# write data to a file
|
||||
f.write(data)
|
||||
|
||||
f.close()
|
||||
print('Successfully get the file')
|
||||
s.close()
|
||||
print('connection closed')
|
|
@ -1,36 +0,0 @@
|
|||
"""
|
||||
File transfer protocol used to send and receive files using FTP server.
|
||||
Use credentials to provide access to the FTP client
|
||||
|
||||
Note: Do not use root username & password for security reasons
|
||||
Create a seperate user and provide access to a home directory of the user
|
||||
Use login id and password of the user created
|
||||
cwd here stands for current working directory
|
||||
"""
|
||||
|
||||
from ftplib import FTP
|
||||
ftp = FTP('xxx.xxx.x.x') # Enter the ip address or the domain name here
|
||||
ftp.login(user='username', passwd='password')
|
||||
ftp.cwd('/Enter the directory here/')
|
||||
|
||||
"""
|
||||
The file which will be received via the FTP server
|
||||
Enter the location of the file where the file is received
|
||||
"""
|
||||
|
||||
def ReceiveFile():
|
||||
FileName = 'example.txt' """ Enter the location of the file """
|
||||
LocalFile = open(FileName, 'wb')
|
||||
ftp.retrbinary('RETR ' + FileName, LocalFile.write, 1024)
|
||||
ftp.quit()
|
||||
LocalFile.close()
|
||||
|
||||
"""
|
||||
The file which will be sent via the FTP server
|
||||
The file send will be send to the current working directory
|
||||
"""
|
||||
|
||||
def SendFile():
|
||||
FileName = 'example.txt' """ Enter the name of the file """
|
||||
ftp.storbinary('STOR ' + FileName, open(FileName, 'rb'))
|
||||
ftp.quit()
|
|
@ -1,44 +0,0 @@
|
|||
# Finding Articulation Points in Undirected Graph
|
||||
def computeAP(l):
|
||||
n = len(l)
|
||||
outEdgeCount = 0
|
||||
low = [0] * n
|
||||
visited = [False] * n
|
||||
isArt = [False] * n
|
||||
|
||||
def dfs(root, at, parent, outEdgeCount):
|
||||
if parent == root:
|
||||
outEdgeCount += 1
|
||||
visited[at] = True
|
||||
low[at] = at
|
||||
|
||||
for to in l[at]:
|
||||
if to == parent:
|
||||
pass
|
||||
elif not visited[to]:
|
||||
outEdgeCount = dfs(root, to, at, outEdgeCount)
|
||||
low[at] = min(low[at], low[to])
|
||||
|
||||
# AP found via bridge
|
||||
if at < low[to]:
|
||||
isArt[at] = True
|
||||
# AP found via cycle
|
||||
if at == low[to]:
|
||||
isArt[at] = True
|
||||
else:
|
||||
low[at] = min(low[at], to)
|
||||
return outEdgeCount
|
||||
|
||||
for i in range(n):
|
||||
if not visited[i]:
|
||||
outEdgeCount = 0
|
||||
outEdgeCount = dfs(i, i, -1, outEdgeCount)
|
||||
isArt[i] = (outEdgeCount > 1)
|
||||
|
||||
for x in range(len(isArt)):
|
||||
if isArt[x] == True:
|
||||
print(x)
|
||||
|
||||
# Adjacency list of graph
|
||||
l = {0:[1,2], 1:[0,2], 2:[0,1,3,5], 3:[2,4], 4:[3], 5:[2,6,8], 6:[5,7], 7:[6,8], 8:[5,7]}
|
||||
computeAP(l)
|
|
@ -1,43 +0,0 @@
|
|||
# Check whether Graph is Bipartite or Not using BFS
|
||||
|
||||
# A Bipartite Graph is a graph whose vertices can be divided into two independent sets,
|
||||
# U and V such that every edge (u, v) either connects a vertex from U to V or a vertex
|
||||
# from V to U. In other words, for every edge (u, v), either u belongs to U and v to V,
|
||||
# or u belongs to V and v to U. We can also say that there is no edge that connects
|
||||
# vertices of same set.
|
||||
def checkBipartite(l):
|
||||
queue = []
|
||||
visited = [False] * len(l)
|
||||
color = [-1] * len(l)
|
||||
|
||||
def bfs():
|
||||
while(queue):
|
||||
u = queue.pop(0)
|
||||
visited[u] = True
|
||||
|
||||
for neighbour in l[u]:
|
||||
|
||||
if neighbour == u:
|
||||
return False
|
||||
|
||||
if color[neighbour] == -1:
|
||||
color[neighbour] = 1 - color[u]
|
||||
queue.append(neighbour)
|
||||
|
||||
elif color[neighbour] == color[u]:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
for i in range(len(l)):
|
||||
if not visited[i]:
|
||||
queue.append(i)
|
||||
color[i] = 0
|
||||
if bfs() == False:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
# Adjacency List of graph
|
||||
l = {0:[1,3], 1:[0,2], 2:[1,3], 3:[0,2]}
|
||||
print(checkBipartite(l))
|
|
@ -1,31 +0,0 @@
|
|||
# Finding Bridges in Undirected Graph
|
||||
def computeBridges(l):
|
||||
id = 0
|
||||
n = len(l) # No of vertices in graph
|
||||
low = [0] * n
|
||||
visited = [False] * n
|
||||
|
||||
def dfs(at, parent, bridges, id):
|
||||
visited[at] = True
|
||||
low[at] = id
|
||||
id += 1
|
||||
for to in l[at]:
|
||||
if to == parent:
|
||||
pass
|
||||
elif not visited[to]:
|
||||
dfs(to, at, bridges, id)
|
||||
low[at] = min(low[at], low[to])
|
||||
if at < low[to]:
|
||||
bridges.append([at, to])
|
||||
else:
|
||||
# This edge is a back edge and cannot be a bridge
|
||||
low[at] = min(low[at], to)
|
||||
|
||||
bridges = []
|
||||
for i in range(n):
|
||||
if (not visited[i]):
|
||||
dfs(i, -1, bridges, id)
|
||||
print(bridges)
|
||||
|
||||
l = {0:[1,2], 1:[0,2], 2:[0,1,3,5], 3:[2,4], 4:[3], 5:[2,6,8], 6:[5,7], 7:[6,8], 8:[5,7]}
|
||||
computeBridges(l)
|
|
@ -1,30 +0,0 @@
|
|||
# Finding longest distance in Directed Acyclic Graph using KahnsAlgorithm
|
||||
def longestDistance(l):
|
||||
indegree = [0] * len(l)
|
||||
queue = []
|
||||
longDist = [1] * len(l)
|
||||
|
||||
for key, values in l.items():
|
||||
for i in values:
|
||||
indegree[i] += 1
|
||||
|
||||
for i in range(len(indegree)):
|
||||
if indegree[i] == 0:
|
||||
queue.append(i)
|
||||
|
||||
while(queue):
|
||||
vertex = queue.pop(0)
|
||||
for x in l[vertex]:
|
||||
indegree[x] -= 1
|
||||
|
||||
if longDist[vertex] + 1 > longDist[x]:
|
||||
longDist[x] = longDist[vertex] + 1
|
||||
|
||||
if indegree[x] == 0:
|
||||
queue.append(x)
|
||||
|
||||
print(max(longDist))
|
||||
|
||||
# Adjacency list of Graph
|
||||
l = {0:[2,3,4], 1:[2,7], 2:[5], 3:[5,7], 4:[7], 5:[6], 6:[7], 7:[]}
|
||||
longestDistance(l)
|
|
@ -1,32 +0,0 @@
|
|||
# Kahn's Algorithm is used to find Topological ordering of Directed Acyclic Graph using BFS
|
||||
def topologicalSort(l):
|
||||
indegree = [0] * len(l)
|
||||
queue = []
|
||||
topo = []
|
||||
cnt = 0
|
||||
|
||||
for key, values in l.items():
|
||||
for i in values:
|
||||
indegree[i] += 1
|
||||
|
||||
for i in range(len(indegree)):
|
||||
if indegree[i] == 0:
|
||||
queue.append(i)
|
||||
|
||||
while(queue):
|
||||
vertex = queue.pop(0)
|
||||
cnt += 1
|
||||
topo.append(vertex)
|
||||
for x in l[vertex]:
|
||||
indegree[x] -= 1
|
||||
if indegree[x] == 0:
|
||||
queue.append(x)
|
||||
|
||||
if cnt != len(l):
|
||||
print("Cycle exists")
|
||||
else:
|
||||
print(topo)
|
||||
|
||||
# Adjacency List of Graph
|
||||
l = {0:[1,2], 1:[3], 2:[3], 3:[4,5], 4:[], 5:[]}
|
||||
topologicalSort(l)
|
|
@ -1,111 +0,0 @@
|
|||
import sys
|
||||
from collections import defaultdict
|
||||
|
||||
def PrimsAlgorithm(l):
|
||||
|
||||
nodePosition = []
|
||||
def getPosition(vertex):
|
||||
return nodePosition[vertex]
|
||||
|
||||
def setPosition(vertex, pos):
|
||||
nodePosition[vertex] = pos
|
||||
|
||||
def topToBottom(heap, start, size, positions):
|
||||
if start > size // 2 - 1:
|
||||
return
|
||||
else:
|
||||
if 2 * start + 2 >= size:
|
||||
m = 2 * start + 1
|
||||
else:
|
||||
if heap[2 * start + 1] < heap[2 * start + 2]:
|
||||
m = 2 * start + 1
|
||||
else:
|
||||
m = 2 * start + 2
|
||||
if heap[m] < heap[start]:
|
||||
temp, temp1 = heap[m], positions[m]
|
||||
heap[m], positions[m] = heap[start], positions[start]
|
||||
heap[start], positions[start] = temp, temp1
|
||||
|
||||
temp = getPosition(positions[m])
|
||||
setPosition(positions[m], getPosition(positions[start]))
|
||||
setPosition(positions[start], temp)
|
||||
|
||||
topToBottom(heap, m, size, positions)
|
||||
|
||||
# Update function if value of any node in min-heap decreases
|
||||
def bottomToTop(val, index, heap, position):
|
||||
temp = position[index]
|
||||
|
||||
while(index != 0):
|
||||
if index % 2 == 0:
|
||||
parent = int( (index-2) / 2 )
|
||||
else:
|
||||
parent = int( (index-1) / 2 )
|
||||
|
||||
if val < heap[parent]:
|
||||
heap[index] = heap[parent]
|
||||
position[index] = position[parent]
|
||||
setPosition(position[parent], index)
|
||||
else:
|
||||
heap[index] = val
|
||||
position[index] = temp
|
||||
setPosition(temp, index)
|
||||
break
|
||||
index = parent
|
||||
else:
|
||||
heap[0] = val
|
||||
position[0] = temp
|
||||
setPosition(temp, 0)
|
||||
|
||||
def heapify(heap, positions):
|
||||
start = len(heap) // 2 - 1
|
||||
for i in range(start, -1, -1):
|
||||
topToBottom(heap, i, len(heap), positions)
|
||||
|
||||
def deleteMinimum(heap, positions):
|
||||
temp = positions[0]
|
||||
heap[0] = sys.maxsize
|
||||
topToBottom(heap, 0, len(heap), positions)
|
||||
return temp
|
||||
|
||||
visited = [0 for i in range(len(l))]
|
||||
Nbr_TV = [-1 for i in range(len(l))] # Neighboring Tree Vertex of selected vertex
|
||||
# Minimum Distance of explored vertex with neighboring vertex of partial tree formed in graph
|
||||
Distance_TV = [] # Heap of Distance of vertices from their neighboring vertex
|
||||
Positions = []
|
||||
|
||||
for x in range(len(l)):
|
||||
p = sys.maxsize
|
||||
Distance_TV.append(p)
|
||||
Positions.append(x)
|
||||
nodePosition.append(x)
|
||||
|
||||
TreeEdges = []
|
||||
visited[0] = 1
|
||||
Distance_TV[0] = sys.maxsize
|
||||
for x in l[0]:
|
||||
Nbr_TV[ x[0] ] = 0
|
||||
Distance_TV[ x[0] ] = x[1]
|
||||
heapify(Distance_TV, Positions)
|
||||
|
||||
for i in range(1, len(l)):
|
||||
vertex = deleteMinimum(Distance_TV, Positions)
|
||||
if visited[vertex] == 0:
|
||||
TreeEdges.append((Nbr_TV[vertex], vertex))
|
||||
visited[vertex] = 1
|
||||
for v in l[vertex]:
|
||||
if visited[v[0]] == 0 and v[1] < Distance_TV[ getPosition(v[0]) ]:
|
||||
Distance_TV[ getPosition(v[0]) ] = v[1]
|
||||
bottomToTop(v[1], getPosition(v[0]), Distance_TV, Positions)
|
||||
Nbr_TV[ v[0] ] = vertex
|
||||
return TreeEdges
|
||||
|
||||
# < --------- Prims Algorithm --------- >
|
||||
n = int(raw_input("Enter number of vertices: "))
|
||||
e = int(raw_input("Enter number of edges: "))
|
||||
adjlist = defaultdict(list)
|
||||
for x in range(e):
|
||||
l = [int(x) for x in input().split()]
|
||||
adjlist[l[0]].append([ l[1], l[2] ])
|
||||
adjlist[l[1]].append([ l[0], l[2] ])
|
||||
print(PrimsAlgorithm(adjlist))
|
|
@ -1,266 +0,0 @@
|
|||
from __future__ import print_function
|
||||
import heapq
|
||||
import numpy as np
|
||||
|
||||
try:
|
||||
xrange # Python 2
|
||||
except NameError:
|
||||
xrange = range # Python 3
|
||||
|
||||
|
||||
class PriorityQueue:
|
||||
def __init__(self):
|
||||
self.elements = []
|
||||
self.set = set()
|
||||
|
||||
def minkey(self):
|
||||
if not self.empty():
|
||||
return self.elements[0][0]
|
||||
else:
|
||||
return float('inf')
|
||||
|
||||
def empty(self):
|
||||
return len(self.elements) == 0
|
||||
|
||||
def put(self, item, priority):
|
||||
if item not in self.set:
|
||||
heapq.heappush(self.elements, (priority, item))
|
||||
self.set.add(item)
|
||||
else:
|
||||
# update
|
||||
# print("update", item)
|
||||
temp = []
|
||||
(pri, x) = heapq.heappop(self.elements)
|
||||
while x != item:
|
||||
temp.append((pri, x))
|
||||
(pri, x) = heapq.heappop(self.elements)
|
||||
temp.append((priority, item))
|
||||
for (pro, xxx) in temp:
|
||||
heapq.heappush(self.elements, (pro, xxx))
|
||||
|
||||
def remove_element(self, item):
|
||||
if item in self.set:
|
||||
self.set.remove(item)
|
||||
temp = []
|
||||
(pro, x) = heapq.heappop(self.elements)
|
||||
while x != item:
|
||||
temp.append((pro, x))
|
||||
(pro, x) = heapq.heappop(self.elements)
|
||||
for (prito, yyy) in temp:
|
||||
heapq.heappush(self.elements, (prito, yyy))
|
||||
|
||||
def top_show(self):
|
||||
return self.elements[0][1]
|
||||
|
||||
def get(self):
|
||||
(priority, item) = heapq.heappop(self.elements)
|
||||
self.set.remove(item)
|
||||
return (priority, item)
|
||||
|
||||
def consistent_hueristic(P, goal):
|
||||
# euclidean distance
|
||||
a = np.array(P)
|
||||
b = np.array(goal)
|
||||
return np.linalg.norm(a - b)
|
||||
|
||||
def hueristic_2(P, goal):
|
||||
# integer division by time variable
|
||||
return consistent_hueristic(P, goal) // t
|
||||
|
||||
def hueristic_1(P, goal):
|
||||
# manhattan distance
|
||||
return abs(P[0] - goal[0]) + abs(P[1] - goal[1])
|
||||
|
||||
def key(start, i, goal, g_function):
|
||||
ans = g_function[start] + W1 * hueristics[i](start, goal)
|
||||
return ans
|
||||
|
||||
def do_something(back_pointer, goal, start):
|
||||
grid = np.chararray((n, n))
|
||||
for i in range(n):
|
||||
for j in range(n):
|
||||
grid[i][j] = '*'
|
||||
|
||||
for i in range(n):
|
||||
for j in range(n):
|
||||
if (j, (n-1)-i) in blocks:
|
||||
grid[i][j] = "#"
|
||||
|
||||
grid[0][(n-1)] = "-"
|
||||
x = back_pointer[goal]
|
||||
while x != start:
|
||||
(x_c, y_c) = x
|
||||
# print(x)
|
||||
grid[(n-1)-y_c][x_c] = "-"
|
||||
x = back_pointer[x]
|
||||
grid[(n-1)][0] = "-"
|
||||
|
||||
|
||||
for i in xrange(n):
|
||||
for j in range(n):
|
||||
if (i, j) == (0, n-1):
|
||||
print(grid[i][j], end=' ')
|
||||
print("<-- End position", end=' ')
|
||||
else:
|
||||
print(grid[i][j], end=' ')
|
||||
print()
|
||||
print("^")
|
||||
print("Start position")
|
||||
print()
|
||||
print("# is an obstacle")
|
||||
print("- is the path taken by algorithm")
|
||||
print("PATH TAKEN BY THE ALGORITHM IS:-")
|
||||
x = back_pointer[goal]
|
||||
while x != start:
|
||||
print(x, end=' ')
|
||||
x = back_pointer[x]
|
||||
print(x)
|
||||
quit()
|
||||
|
||||
def valid(p):
|
||||
if p[0] < 0 or p[0] > n-1:
|
||||
return False
|
||||
if p[1] < 0 or p[1] > n-1:
|
||||
return False
|
||||
return True
|
||||
|
||||
def expand_state(s, j, visited, g_function, close_list_anchor, close_list_inad, open_list, back_pointer):
|
||||
for itera in range(n_hueristic):
|
||||
open_list[itera].remove_element(s)
|
||||
# print("s", s)
|
||||
# print("j", j)
|
||||
(x, y) = s
|
||||
left = (x-1, y)
|
||||
right = (x+1, y)
|
||||
up = (x, y+1)
|
||||
down = (x, y-1)
|
||||
|
||||
for neighbours in [left, right, up, down]:
|
||||
if neighbours not in blocks:
|
||||
if valid(neighbours) and neighbours not in visited:
|
||||
# print("neighbour", neighbours)
|
||||
visited.add(neighbours)
|
||||
back_pointer[neighbours] = -1
|
||||
g_function[neighbours] = float('inf')
|
||||
|
||||
if valid(neighbours) and g_function[neighbours] > g_function[s] + 1:
|
||||
g_function[neighbours] = g_function[s] + 1
|
||||
back_pointer[neighbours] = s
|
||||
if neighbours not in close_list_anchor:
|
||||
open_list[0].put(neighbours, key(neighbours, 0, goal, g_function))
|
||||
if neighbours not in close_list_inad:
|
||||
for var in range(1,n_hueristic):
|
||||
if key(neighbours, var, goal, g_function) <= W2 * key(neighbours, 0, goal, g_function):
|
||||
# print("why not plssssssssss")
|
||||
open_list[j].put(neighbours, key(neighbours, var, goal, g_function))
|
||||
|
||||
|
||||
# print
|
||||
|
||||
def make_common_ground():
|
||||
some_list = []
|
||||
# block 1
|
||||
for x in range(1, 5):
|
||||
for y in range(1, 6):
|
||||
some_list.append((x, y))
|
||||
|
||||
# line
|
||||
for x in range(15, 20):
|
||||
some_list.append((x, 17))
|
||||
|
||||
# block 2 big
|
||||
for x in range(10, 19):
|
||||
for y in range(1, 15):
|
||||
some_list.append((x, y))
|
||||
|
||||
# L block
|
||||
for x in range(1, 4):
|
||||
for y in range(12, 19):
|
||||
some_list.append((x, y))
|
||||
for x in range(3, 13):
|
||||
for y in range(16, 19):
|
||||
some_list.append((x, y))
|
||||
return some_list
|
||||
|
||||
hueristics = {0: consistent_hueristic, 1: hueristic_1, 2: hueristic_2}
|
||||
|
||||
blocks_blk = [(0, 1),(1, 1),(2, 1),(3, 1),(4, 1),(5, 1),(6, 1),(7, 1),(8, 1),(9, 1),(10, 1),(11, 1),(12, 1),(13, 1),(14, 1),(15, 1),(16, 1),(17, 1),(18, 1), (19, 1)]
|
||||
blocks_no = []
|
||||
blocks_all = make_common_ground()
|
||||
|
||||
|
||||
|
||||
|
||||
blocks = blocks_blk
|
||||
# hyper parameters
|
||||
W1 = 1
|
||||
W2 = 1
|
||||
n = 20
|
||||
n_hueristic = 3 # one consistent and two other inconsistent
|
||||
|
||||
# start and end destination
|
||||
start = (0, 0)
|
||||
goal = (n-1, n-1)
|
||||
|
||||
t = 1
|
||||
def multi_a_star(start, goal, n_hueristic):
|
||||
g_function = {start: 0, goal: float('inf')}
|
||||
back_pointer = {start:-1, goal:-1}
|
||||
open_list = []
|
||||
visited = set()
|
||||
|
||||
for i in range(n_hueristic):
|
||||
open_list.append(PriorityQueue())
|
||||
open_list[i].put(start, key(start, i, goal, g_function))
|
||||
|
||||
close_list_anchor = []
|
||||
close_list_inad = []
|
||||
while open_list[0].minkey() < float('inf'):
|
||||
for i in range(1, n_hueristic):
|
||||
# print("i", i)
|
||||
# print(open_list[0].minkey(), open_list[i].minkey())
|
||||
if open_list[i].minkey() <= W2 * open_list[0].minkey():
|
||||
global t
|
||||
t += 1
|
||||
# print("less prio")
|
||||
if g_function[goal] <= open_list[i].minkey():
|
||||
if g_function[goal] < float('inf'):
|
||||
do_something(back_pointer, goal, start)
|
||||
else:
|
||||
_, get_s = open_list[i].top_show()
|
||||
visited.add(get_s)
|
||||
expand_state(get_s, i, visited, g_function, close_list_anchor, close_list_inad, open_list, back_pointer)
|
||||
close_list_inad.append(get_s)
|
||||
else:
|
||||
# print("more prio")
|
||||
if g_function[goal] <= open_list[0].minkey():
|
||||
if g_function[goal] < float('inf'):
|
||||
do_something(back_pointer, goal, start)
|
||||
else:
|
||||
# print("hoolla")
|
||||
get_s = open_list[0].top_show()
|
||||
visited.add(get_s)
|
||||
expand_state(get_s, 0, visited, g_function, close_list_anchor, close_list_inad, open_list, back_pointer)
|
||||
close_list_anchor.append(get_s)
|
||||
print("No path found to goal")
|
||||
print()
|
||||
for i in range(n-1,-1, -1):
|
||||
for j in range(n):
|
||||
if (j, i) in blocks:
|
||||
print('#', end=' ')
|
||||
elif (j, i) in back_pointer:
|
||||
if (j, i) == (n-1, n-1):
|
||||
print('*', end=' ')
|
||||
else:
|
||||
print('-', end=' ')
|
||||
else:
|
||||
print('*', end=' ')
|
||||
if (j, i) == (n-1, n-1):
|
||||
print('<-- End position', end=' ')
|
||||
print()
|
||||
print("^")
|
||||
print("Start position")
|
||||
print()
|
||||
print("# is an obstacle")
|
||||
print("- is the path taken by algorithm")
|
||||
multi_a_star(start, goal, n_hueristic)
|
102
Graphs/a_star.py
102
Graphs/a_star.py
|
@ -1,102 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
grid = [[0, 1, 0, 0, 0, 0],
|
||||
[0, 1, 0, 0, 0, 0],#0 are free path whereas 1's are obstacles
|
||||
[0, 1, 0, 0, 0, 0],
|
||||
[0, 1, 0, 0, 1, 0],
|
||||
[0, 0, 0, 0, 1, 0]]
|
||||
|
||||
'''
|
||||
heuristic = [[9, 8, 7, 6, 5, 4],
|
||||
[8, 7, 6, 5, 4, 3],
|
||||
[7, 6, 5, 4, 3, 2],
|
||||
[6, 5, 4, 3, 2, 1],
|
||||
[5, 4, 3, 2, 1, 0]]'''
|
||||
|
||||
init = [0, 0]
|
||||
goal = [len(grid)-1, len(grid[0])-1] #all coordinates are given in format [y,x]
|
||||
cost = 1
|
||||
|
||||
#the cost map which pushes the path closer to the goal
|
||||
heuristic = [[0 for row in range(len(grid[0]))] for col in range(len(grid))]
|
||||
for i in range(len(grid)):
|
||||
for j in range(len(grid[0])):
|
||||
heuristic[i][j] = abs(i - goal[0]) + abs(j - goal[1])
|
||||
if grid[i][j] == 1:
|
||||
heuristic[i][j] = 99 #added extra penalty in the heuristic map
|
||||
|
||||
|
||||
#the actions we can take
|
||||
delta = [[-1, 0 ], # go up
|
||||
[ 0, -1], # go left
|
||||
[ 1, 0 ], # go down
|
||||
[ 0, 1 ]] # go right
|
||||
|
||||
|
||||
#function to search the path
|
||||
def search(grid,init,goal,cost,heuristic):
|
||||
|
||||
closed = [[0 for col in range(len(grid[0]))] for row in range(len(grid))]# the referrence grid
|
||||
closed[init[0]][init[1]] = 1
|
||||
action = [[0 for col in range(len(grid[0]))] for row in range(len(grid))]#the action grid
|
||||
|
||||
x = init[0]
|
||||
y = init[1]
|
||||
g = 0
|
||||
f = g + heuristic[init[0]][init[0]]
|
||||
cell = [[f, g, x, y]]
|
||||
|
||||
found = False # flag that is set when search is complete
|
||||
resign = False # flag set if we can't find expand
|
||||
|
||||
while not found and not resign:
|
||||
if len(cell) == 0:
|
||||
resign = True
|
||||
return "FAIL"
|
||||
else:
|
||||
cell.sort()#to choose the least costliest action so as to move closer to the goal
|
||||
cell.reverse()
|
||||
next = cell.pop()
|
||||
x = next[2]
|
||||
y = next[3]
|
||||
g = next[1]
|
||||
f = next[0]
|
||||
|
||||
|
||||
if x == goal[0] and y == goal[1]:
|
||||
found = True
|
||||
else:
|
||||
for i in range(len(delta)):#to try out different valid actions
|
||||
x2 = x + delta[i][0]
|
||||
y2 = y + delta[i][1]
|
||||
if x2 >= 0 and x2 < len(grid) and y2 >=0 and y2 < len(grid[0]):
|
||||
if closed[x2][y2] == 0 and grid[x2][y2] == 0:
|
||||
g2 = g + cost
|
||||
f2 = g2 + heuristic[x2][y2]
|
||||
cell.append([f2, g2, x2, y2])
|
||||
closed[x2][y2] = 1
|
||||
action[x2][y2] = i
|
||||
invpath = []
|
||||
x = goal[0]
|
||||
y = goal[1]
|
||||
invpath.append([x, y])#we get the reverse path from here
|
||||
while x != init[0] or y != init[1]:
|
||||
x2 = x - delta[action[x][y]][0]
|
||||
y2 = y - delta[action[x][y]][1]
|
||||
x = x2
|
||||
y = y2
|
||||
invpath.append([x, y])
|
||||
|
||||
path = []
|
||||
for i in range(len(invpath)):
|
||||
path.append(invpath[len(invpath) - 1 - i])
|
||||
print("ACTION MAP")
|
||||
for i in range(len(action)):
|
||||
print(action[i])
|
||||
|
||||
return path
|
||||
|
||||
a = search(grid,init,goal,cost,heuristic)
|
||||
for i in range(len(a)):
|
||||
print(a[i])
|
||||
|
|
@ -1,281 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
try:
|
||||
xrange # Python 2
|
||||
except NameError:
|
||||
xrange = range # Python 3
|
||||
|
||||
# Accept No. of Nodes and edges
|
||||
n, m = map(int, raw_input().split(" "))
|
||||
|
||||
# Initialising Dictionary of edges
|
||||
g = {}
|
||||
for i in xrange(n):
|
||||
g[i + 1] = []
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Accepting edges of Unweighted Directed Graphs
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
for _ in xrange(m):
|
||||
x, y = map(int, raw_input().split(" "))
|
||||
g[x].append(y)
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Accepting edges of Unweighted Undirected Graphs
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
for _ in xrange(m):
|
||||
x, y = map(int, raw_input().split(" "))
|
||||
g[x].append(y)
|
||||
g[y].append(x)
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Accepting edges of Weighted Undirected Graphs
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
for _ in xrange(m):
|
||||
x, y, r = map(int, raw_input().split(" "))
|
||||
g[x].append([y, r])
|
||||
g[y].append([x, r])
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Depth First Search.
|
||||
Args : G - Dictionary of edges
|
||||
s - Starting Node
|
||||
Vars : vis - Set of visited nodes
|
||||
S - Traversal Stack
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def dfs(G, s):
|
||||
vis, S = set([s]), [s]
|
||||
print(s)
|
||||
while S:
|
||||
flag = 0
|
||||
for i in G[S[-1]]:
|
||||
if i not in vis:
|
||||
S.append(i)
|
||||
vis.add(i)
|
||||
flag = 1
|
||||
print(i)
|
||||
break
|
||||
if not flag:
|
||||
S.pop()
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Breadth First Search.
|
||||
Args : G - Dictionary of edges
|
||||
s - Starting Node
|
||||
Vars : vis - Set of visited nodes
|
||||
Q - Traveral Stack
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
from collections import deque
|
||||
|
||||
|
||||
def bfs(G, s):
|
||||
vis, Q = set([s]), deque([s])
|
||||
print(s)
|
||||
while Q:
|
||||
u = Q.popleft()
|
||||
for v in G[u]:
|
||||
if v not in vis:
|
||||
vis.add(v)
|
||||
Q.append(v)
|
||||
print(v)
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Dijkstra's shortest path Algorithm
|
||||
Args : G - Dictionary of edges
|
||||
s - Starting Node
|
||||
Vars : dist - Dictionary storing shortest distance from s to every other node
|
||||
known - Set of knows nodes
|
||||
path - Preceding node in path
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def dijk(G, s):
|
||||
dist, known, path = {s: 0}, set(), {s: 0}
|
||||
while True:
|
||||
if len(known) == len(G) - 1:
|
||||
break
|
||||
mini = 100000
|
||||
for i in dist:
|
||||
if i not in known and dist[i] < mini:
|
||||
mini = dist[i]
|
||||
u = i
|
||||
known.add(u)
|
||||
for v in G[u]:
|
||||
if v[0] not in known:
|
||||
if dist[u] + v[1] < dist.get(v[0], 100000):
|
||||
dist[v[0]] = dist[u] + v[1]
|
||||
path[v[0]] = u
|
||||
for i in dist:
|
||||
if i != s:
|
||||
print(dist[i])
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Topological Sort
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
from collections import deque
|
||||
|
||||
|
||||
def topo(G, ind=None, Q=[1]):
|
||||
if ind is None:
|
||||
ind = [0] * (len(G) + 1) # SInce oth Index is ignored
|
||||
for u in G:
|
||||
for v in G[u]:
|
||||
ind[v] += 1
|
||||
Q = deque()
|
||||
for i in G:
|
||||
if ind[i] == 0:
|
||||
Q.append(i)
|
||||
if len(Q) == 0:
|
||||
return
|
||||
v = Q.popleft()
|
||||
print(v)
|
||||
for w in G[v]:
|
||||
ind[w] -= 1
|
||||
if ind[w] == 0:
|
||||
Q.append(w)
|
||||
topo(G, ind, Q)
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Reading an Adjacency matrix
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def adjm():
|
||||
n, a = raw_input(), []
|
||||
for i in xrange(n):
|
||||
a.append(map(int, raw_input().split()))
|
||||
return a, n
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Floyd Warshall's algorithm
|
||||
Args : G - Dictionary of edges
|
||||
s - Starting Node
|
||||
Vars : dist - Dictionary storing shortest distance from s to every other node
|
||||
known - Set of knows nodes
|
||||
path - Preceding node in path
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def floy(A_and_n):
|
||||
(A, n) = A_and_n
|
||||
dist = list(A)
|
||||
path = [[0] * n for i in xrange(n)]
|
||||
for k in xrange(n):
|
||||
for i in xrange(n):
|
||||
for j in xrange(n):
|
||||
if dist[i][j] > dist[i][k] + dist[k][j]:
|
||||
dist[i][j] = dist[i][k] + dist[k][j]
|
||||
path[i][k] = k
|
||||
print(dist)
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Prim's MST Algorithm
|
||||
Args : G - Dictionary of edges
|
||||
s - Starting Node
|
||||
Vars : dist - Dictionary storing shortest distance from s to nearest node
|
||||
known - Set of knows nodes
|
||||
path - Preceding node in path
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def prim(G, s):
|
||||
dist, known, path = {s: 0}, set(), {s: 0}
|
||||
while True:
|
||||
if len(known) == len(G) - 1:
|
||||
break
|
||||
mini = 100000
|
||||
for i in dist:
|
||||
if i not in known and dist[i] < mini:
|
||||
mini = dist[i]
|
||||
u = i
|
||||
known.add(u)
|
||||
for v in G[u]:
|
||||
if v[0] not in known:
|
||||
if v[1] < dist.get(v[0], 100000):
|
||||
dist[v[0]] = v[1]
|
||||
path[v[0]] = u
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Accepting Edge list
|
||||
Vars : n - Number of nodes
|
||||
m - Number of edges
|
||||
Returns : l - Edge list
|
||||
n - Number of Nodes
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def edglist():
|
||||
n, m = map(int, raw_input().split(" "))
|
||||
l = []
|
||||
for i in xrange(m):
|
||||
l.append(map(int, raw_input().split(' ')))
|
||||
return l, n
|
||||
|
||||
|
||||
"""
|
||||
--------------------------------------------------------------------------------
|
||||
Kruskal's MST Algorithm
|
||||
Args : E - Edge list
|
||||
n - Number of Nodes
|
||||
Vars : s - Set of all nodes as unique disjoint sets (initially)
|
||||
--------------------------------------------------------------------------------
|
||||
"""
|
||||
|
||||
|
||||
def krusk(E_and_n):
|
||||
# Sort edges on the basis of distance
|
||||
(E, n) = E_and_n
|
||||
E.sort(reverse=True, key=lambda x: x[2])
|
||||
s = [set([i]) for i in range(1, n + 1)]
|
||||
while True:
|
||||
if len(s) == 1:
|
||||
break
|
||||
print(s)
|
||||
x = E.pop()
|
||||
for i in xrange(len(s)):
|
||||
if x[0] in s[i]:
|
||||
break
|
||||
for j in xrange(len(s)):
|
||||
if x[1] in s[j]:
|
||||
if i == j:
|
||||
break
|
||||
s[j].update(s[i])
|
||||
s.pop(i)
|
||||
break
|
|
@ -1,32 +0,0 @@
|
|||
from __future__ import print_function
|
||||
num_nodes, num_edges = list(map(int,raw_input().split()))
|
||||
|
||||
edges = []
|
||||
|
||||
for i in range(num_edges):
|
||||
node1, node2, cost = list(map(int,raw_input().split()))
|
||||
edges.append((i,node1,node2,cost))
|
||||
|
||||
edges = sorted(edges, key=lambda edge: edge[3])
|
||||
|
||||
parent = [i for i in range(num_nodes)]
|
||||
|
||||
def find_parent(i):
|
||||
if(i != parent[i]):
|
||||
parent[i] = find_parent(parent[i])
|
||||
return parent[i]
|
||||
|
||||
minimum_spanning_tree_cost = 0
|
||||
minimum_spanning_tree = []
|
||||
|
||||
for edge in edges:
|
||||
parent_a = find_parent(edge[1])
|
||||
parent_b = find_parent(edge[2])
|
||||
if(parent_a != parent_b):
|
||||
minimum_spanning_tree_cost += edge[3]
|
||||
minimum_spanning_tree.append(edge)
|
||||
parent[parent_a] = parent_b
|
||||
|
||||
print(minimum_spanning_tree_cost)
|
||||
for edge in minimum_spanning_tree:
|
||||
print(edge)
|
|
@ -1,46 +0,0 @@
|
|||
from __future__ import print_function
|
||||
# n - no of nodes, m - no of edges
|
||||
n, m = list(map(int,raw_input().split()))
|
||||
|
||||
g = [[] for i in range(n)] #graph
|
||||
r = [[] for i in range(n)] #reversed graph
|
||||
# input graph data (edges)
|
||||
for i in range(m):
|
||||
u, v = list(map(int,raw_input().split()))
|
||||
g[u].append(v)
|
||||
r[v].append(u)
|
||||
|
||||
stack = []
|
||||
visit = [False]*n
|
||||
scc = []
|
||||
component = []
|
||||
|
||||
def dfs(u):
|
||||
global g, r, scc, component, visit, stack
|
||||
if visit[u]: return
|
||||
visit[u] = True
|
||||
for v in g[u]:
|
||||
dfs(v)
|
||||
stack.append(u)
|
||||
|
||||
def dfs2(u):
|
||||
global g, r, scc, component, visit, stack
|
||||
if visit[u]: return
|
||||
visit[u] = True
|
||||
component.append(u)
|
||||
for v in r[u]:
|
||||
dfs2(v)
|
||||
|
||||
def kosaraju():
|
||||
global g, r, scc, component, visit, stack
|
||||
for i in range(n):
|
||||
dfs(i)
|
||||
visit = [False]*n
|
||||
for i in stack[::-1]:
|
||||
if visit[i]: continue
|
||||
component = []
|
||||
dfs2(i)
|
||||
scc.append(component)
|
||||
return scc
|
||||
|
||||
print(kosaraju())
|
|
@ -1,78 +0,0 @@
|
|||
from collections import deque
|
||||
|
||||
|
||||
def tarjan(g):
|
||||
"""
|
||||
Tarjan's algo for finding strongly connected components in a directed graph
|
||||
|
||||
Uses two main attributes of each node to track reachability, the index of that node within a component(index),
|
||||
and the lowest index reachable from that node(lowlink).
|
||||
|
||||
We then perform a dfs of the each component making sure to update these parameters for each node and saving the
|
||||
nodes we visit on the way.
|
||||
|
||||
If ever we find that the lowest reachable node from a current node is equal to the index of the current node then it
|
||||
must be the root of a strongly connected component and so we save it and it's equireachable vertices as a strongly
|
||||
connected component.
|
||||
|
||||
Complexity: strong_connect() is called at most once for each node and has a complexity of O(|E|) as it is DFS.
|
||||
Therefore this has complexity O(|V| + |E|) for a graph G = (V, E)
|
||||
|
||||
"""
|
||||
|
||||
n = len(g)
|
||||
stack = deque()
|
||||
on_stack = [False for _ in range(n)]
|
||||
index_of = [-1 for _ in range(n)]
|
||||
lowlink_of = index_of[:]
|
||||
|
||||
def strong_connect(v, index, components):
|
||||
index_of[v] = index # the number when this node is seen
|
||||
lowlink_of[v] = index # lowest rank node reachable from here
|
||||
index += 1
|
||||
stack.append(v)
|
||||
on_stack[v] = True
|
||||
|
||||
for w in g[v]:
|
||||
if index_of[w] == -1:
|
||||
index = strong_connect(w, index, components)
|
||||
lowlink_of[v] = lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
|
||||
elif on_stack[w]:
|
||||
lowlink_of[v] = lowlink_of[w] if lowlink_of[w] < lowlink_of[v] else lowlink_of[v]
|
||||
|
||||
if lowlink_of[v] == index_of[v]:
|
||||
component = []
|
||||
w = stack.pop()
|
||||
on_stack[w] = False
|
||||
component.append(w)
|
||||
while w != v:
|
||||
w = stack.pop()
|
||||
on_stack[w] = False
|
||||
component.append(w)
|
||||
components.append(component)
|
||||
return index
|
||||
|
||||
components = []
|
||||
for v in range(n):
|
||||
if index_of[v] == -1:
|
||||
strong_connect(v, 0, components)
|
||||
|
||||
return components
|
||||
|
||||
|
||||
def create_graph(n, edges):
|
||||
g = [[] for _ in range(n)]
|
||||
for u, v in edges:
|
||||
g[u].append(v)
|
||||
return g
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Test
|
||||
n_vertices = 7
|
||||
source = [0, 0, 1, 2, 3, 3, 4, 4, 6]
|
||||
target = [1, 3, 2, 0, 1, 4, 5, 6, 5]
|
||||
edges = [(u, v) for u, v in zip(source, target)]
|
||||
g = create_graph(n_vertices, edges)
|
||||
|
||||
assert [[5], [6], [4], [3, 2, 1, 0]] == tarjan(g)
|
|
@ -1,74 +0,0 @@
|
|||
import math
|
||||
|
||||
def primeFactors(n):
|
||||
pf = []
|
||||
while n % 2 == 0:
|
||||
pf.append(2)
|
||||
n = int(n / 2)
|
||||
|
||||
for i in range(3, int(math.sqrt(n))+1, 2):
|
||||
while n % i == 0:
|
||||
pf.append(i)
|
||||
n = int(n / i)
|
||||
|
||||
if n > 2:
|
||||
pf.append(n)
|
||||
|
||||
return pf
|
||||
|
||||
def numberOfDivisors(n):
|
||||
div = 1
|
||||
|
||||
temp = 1
|
||||
while n % 2 == 0:
|
||||
temp += 1
|
||||
n = int(n / 2)
|
||||
div = div * (temp)
|
||||
|
||||
for i in range(3, int(math.sqrt(n))+1, 2):
|
||||
temp = 1
|
||||
while n % i == 0:
|
||||
temp += 1
|
||||
n = int(n / i)
|
||||
div = div * (temp)
|
||||
|
||||
return div
|
||||
|
||||
def sumOfDivisors(n):
|
||||
s = 1
|
||||
|
||||
temp = 1
|
||||
while n % 2 == 0:
|
||||
temp += 1
|
||||
n = int(n / 2)
|
||||
if temp > 1:
|
||||
s *= (2**temp - 1) / (2 - 1)
|
||||
|
||||
for i in range(3, int(math.sqrt(n))+1, 2):
|
||||
temp = 1
|
||||
while n % i == 0:
|
||||
temp += 1
|
||||
n = int(n / i)
|
||||
if temp > 1:
|
||||
s *= (i**temp - 1) / (i - 1)
|
||||
|
||||
return s
|
||||
|
||||
def eulerPhi(n):
|
||||
l = primeFactors(n)
|
||||
l = set(l)
|
||||
s = n
|
||||
for x in l:
|
||||
s *= (x - 1)/x
|
||||
return s
|
||||
|
||||
def main():
|
||||
print(primeFactors(100))
|
||||
print(numberOfDivisors(100))
|
||||
print(sumOfDivisors(100))
|
||||
print(eulerPhi(100))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# Fibonacci Sequence Using Recursion
|
||||
|
||||
def recur_fibo(n):
|
||||
return n if n <= 1 else (recur_fibo(n-1) + recur_fibo(n-2))
|
||||
|
||||
def isPositiveInteger(limit):
|
||||
return limit >= 0
|
||||
|
||||
def main():
|
||||
limit = int(input("How many terms to include in fibonacci series: "))
|
||||
if isPositiveInteger(limit):
|
||||
print("The first {limit} terms of the fibonacci series are as follows:")
|
||||
print([recur_fibo(n) for n in range(limit)])
|
||||
else:
|
||||
print("Please enter a positive integer: ")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,15 +0,0 @@
|
|||
# Greater Common Divisor - https://en.wikipedia.org/wiki/Greatest_common_divisor
|
||||
def gcd(a, b):
|
||||
return b if a == 0 else gcd(b % a, a)
|
||||
|
||||
def main():
|
||||
try:
|
||||
nums = input("Enter two Integers separated by comma (,): ").split(',')
|
||||
num1 = int(nums[0]); num2 = int(nums[1])
|
||||
except (IndexError, UnboundLocalError, ValueError):
|
||||
print("Wrong Input")
|
||||
print(f"gcd({num1}, {num2}) = {gcd(num1, num2)}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
def modularExponential(base, power, mod):
|
||||
if power < 0:
|
||||
return -1
|
||||
base %= mod
|
||||
result = 1
|
||||
|
||||
while power > 0:
|
||||
if power & 1:
|
||||
result = (result * base) % mod
|
||||
power = power >> 1
|
||||
base = (base * base) % mod
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
print(modularExponential(3, 200, 13))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,46 +0,0 @@
|
|||
import math
|
||||
|
||||
def sieve(n):
|
||||
in_prime = []
|
||||
start = 2
|
||||
end = int(math.sqrt(n)) # Size of every segment
|
||||
temp = [True] * (end + 1)
|
||||
prime = []
|
||||
|
||||
while(start <= end):
|
||||
if temp[start] == True:
|
||||
in_prime.append(start)
|
||||
for i in range(start*start, end+1, start):
|
||||
if temp[i] == True:
|
||||
temp[i] = False
|
||||
start += 1
|
||||
prime += in_prime
|
||||
|
||||
low = end + 1
|
||||
high = low + end - 1
|
||||
if high > n:
|
||||
high = n
|
||||
|
||||
while(low <= n):
|
||||
temp = [True] * (high-low+1)
|
||||
for each in in_prime:
|
||||
|
||||
t = math.floor(low / each) * each
|
||||
if t < low:
|
||||
t += each
|
||||
|
||||
for j in range(t, high+1, each):
|
||||
temp[j - low] = False
|
||||
|
||||
for j in range(len(temp)):
|
||||
if temp[j] == True:
|
||||
prime.append(j+low)
|
||||
|
||||
low = high + 1
|
||||
high = low + end - 1
|
||||
if high > n:
|
||||
high = n
|
||||
|
||||
return prime
|
||||
|
||||
print(sieve(10**6))
|
|
@ -1,24 +0,0 @@
|
|||
import math
|
||||
n = int(raw_input("Enter n: "))
|
||||
|
||||
def sieve(n):
|
||||
l = [True] * (n+1)
|
||||
prime = []
|
||||
start = 2
|
||||
end = int(math.sqrt(n))
|
||||
while(start <= end):
|
||||
if l[start] == True:
|
||||
prime.append(start)
|
||||
for i in range(start*start, n+1, start):
|
||||
if l[i] == True:
|
||||
l[i] = False
|
||||
start += 1
|
||||
|
||||
for j in range(end+1,n+1):
|
||||
if l[j] == True:
|
||||
prime.append(j)
|
||||
|
||||
return prime
|
||||
|
||||
print(sieve(n))
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
|
||||
'''
|
||||
Numerical integration or quadrature for a smooth function f with known values at x_i
|
||||
|
||||
This method is the classical approch of suming 'Equally Spaced Abscissas'
|
||||
|
||||
method 2:
|
||||
"Simpson Rule"
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def method_2(boundary, steps):
|
||||
# "Simpson Rule"
|
||||
# int(f) = delta_x/2 * (b-a)/3*(f1 + 4f2 + 2f_3 + ... + fn)
|
||||
h = (boundary[1] - boundary[0]) / steps
|
||||
a = boundary[0]
|
||||
b = boundary[1]
|
||||
x_i = makePoints(a,b,h)
|
||||
y = 0.0
|
||||
y += (h/3.0)*f(a)
|
||||
cnt = 2
|
||||
for i in x_i:
|
||||
y += (h/3)*(4-2*(cnt%2))*f(i)
|
||||
cnt += 1
|
||||
y += (h/3.0)*f(b)
|
||||
return y
|
||||
|
||||
def makePoints(a,b,h):
|
||||
x = a + h
|
||||
while x < (b-h):
|
||||
yield x
|
||||
x = x + h
|
||||
|
||||
def f(x): #enter your function here
|
||||
y = (x-0)*(x-0)
|
||||
return y
|
||||
|
||||
def main():
|
||||
a = 0.0 #Lower bound of integration
|
||||
b = 1.0 #Upper bound of integration
|
||||
steps = 10.0 #define number of steps or resolution
|
||||
boundary = [a, b] #define boundary of integration
|
||||
y = method_2(boundary, steps)
|
||||
print('y = {0}'.format(y))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,46 +0,0 @@
|
|||
'''
|
||||
Numerical integration or quadrature for a smooth function f with known values at x_i
|
||||
|
||||
This method is the classical approch of suming 'Equally Spaced Abscissas'
|
||||
|
||||
method 1:
|
||||
"extended trapezoidal rule"
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
def method_1(boundary, steps):
|
||||
# "extended trapezoidal rule"
|
||||
# int(f) = dx/2 * (f1 + 2f2 + ... + fn)
|
||||
h = (boundary[1] - boundary[0]) / steps
|
||||
a = boundary[0]
|
||||
b = boundary[1]
|
||||
x_i = makePoints(a,b,h)
|
||||
y = 0.0
|
||||
y += (h/2.0)*f(a)
|
||||
for i in x_i:
|
||||
#print(i)
|
||||
y += h*f(i)
|
||||
y += (h/2.0)*f(b)
|
||||
return y
|
||||
|
||||
def makePoints(a,b,h):
|
||||
x = a + h
|
||||
while x < (b-h):
|
||||
yield x
|
||||
x = x + h
|
||||
|
||||
def f(x): #enter your function here
|
||||
y = (x-0)*(x-0)
|
||||
return y
|
||||
|
||||
def main():
|
||||
a = 0.0 #Lower bound of integration
|
||||
b = 1.0 #Upper bound of integration
|
||||
steps = 10.0 #define number of steps or resolution
|
||||
boundary = [a, b] #define boundary of integration
|
||||
y = method_1(boundary, steps)
|
||||
print('y = {0}'.format(y))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
File diff suppressed because one or more lines are too long
|
@ -1,193 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
'''
|
||||
|
||||
A Framework of Back Propagation Neural Network(BP) model
|
||||
|
||||
Easy to use:
|
||||
* add many layers as you want !!!
|
||||
* clearly see how the loss decreasing
|
||||
Easy to expand:
|
||||
* more activation functions
|
||||
* more loss functions
|
||||
* more optimization method
|
||||
|
||||
Author: Stephen Lee
|
||||
Github : https://github.com/RiptideBo
|
||||
Date: 2017.11.23
|
||||
|
||||
'''
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def sigmoid(x):
|
||||
return 1 / (1 + np.exp(-1 * x))
|
||||
|
||||
class DenseLayer():
|
||||
'''
|
||||
Layers of BP neural network
|
||||
'''
|
||||
def __init__(self,units,activation=None,learning_rate=None,is_input_layer=False):
|
||||
'''
|
||||
common connected layer of bp network
|
||||
:param units: numbers of neural units
|
||||
:param activation: activation function
|
||||
:param learning_rate: learning rate for paras
|
||||
:param is_input_layer: whether it is input layer or not
|
||||
'''
|
||||
self.units = units
|
||||
self.weight = None
|
||||
self.bias = None
|
||||
self.activation = activation
|
||||
if learning_rate is None:
|
||||
learning_rate = 0.3
|
||||
self.learn_rate = learning_rate
|
||||
self.is_input_layer = is_input_layer
|
||||
|
||||
def initializer(self,back_units):
|
||||
self.weight = np.asmatrix(np.random.normal(0,0.5,(self.units,back_units)))
|
||||
self.bias = np.asmatrix(np.random.normal(0,0.5,self.units)).T
|
||||
if self.activation is None:
|
||||
self.activation = sigmoid
|
||||
|
||||
def cal_gradient(self):
|
||||
if self.activation == sigmoid:
|
||||
gradient_mat = np.dot(self.output ,(1- self.output).T)
|
||||
gradient_activation = np.diag(np.diag(gradient_mat))
|
||||
else:
|
||||
gradient_activation = 1
|
||||
return gradient_activation
|
||||
|
||||
def forward_propagation(self,xdata):
|
||||
self.xdata = xdata
|
||||
if self.is_input_layer:
|
||||
# input layer
|
||||
self.wx_plus_b = xdata
|
||||
self.output = xdata
|
||||
return xdata
|
||||
else:
|
||||
self.wx_plus_b = np.dot(self.weight,self.xdata) - self.bias
|
||||
self.output = self.activation(self.wx_plus_b)
|
||||
return self.output
|
||||
|
||||
def back_propagation(self,gradient):
|
||||
|
||||
gradient_activation = self.cal_gradient() # i * i 维
|
||||
gradient = np.asmatrix(np.dot(gradient.T,gradient_activation))
|
||||
|
||||
self._gradient_weight = np.asmatrix(self.xdata)
|
||||
self._gradient_bias = -1
|
||||
self._gradient_x = self.weight
|
||||
|
||||
self.gradient_weight = np.dot(gradient.T,self._gradient_weight.T)
|
||||
self.gradient_bias = gradient * self._gradient_bias
|
||||
self.gradient = np.dot(gradient,self._gradient_x).T
|
||||
# ----------------------upgrade
|
||||
# -----------the Negative gradient direction --------
|
||||
self.weight = self.weight - self.learn_rate * self.gradient_weight
|
||||
self.bias = self.bias - self.learn_rate * self.gradient_bias.T
|
||||
|
||||
return self.gradient
|
||||
|
||||
|
||||
class BPNN():
|
||||
'''
|
||||
Back Propagation Neural Network model
|
||||
'''
|
||||
def __init__(self):
|
||||
self.layers = []
|
||||
self.train_mse = []
|
||||
self.fig_loss = plt.figure()
|
||||
self.ax_loss = self.fig_loss.add_subplot(1,1,1)
|
||||
|
||||
def add_layer(self,layer):
|
||||
self.layers.append(layer)
|
||||
|
||||
def build(self):
|
||||
for i,layer in enumerate(self.layers[:]):
|
||||
if i < 1:
|
||||
layer.is_input_layer = True
|
||||
else:
|
||||
layer.initializer(self.layers[i-1].units)
|
||||
|
||||
def summary(self):
|
||||
for i,layer in enumerate(self.layers[:]):
|
||||
print('------- layer %d -------'%i)
|
||||
print('weight.shape ',np.shape(layer.weight))
|
||||
print('bias.shape ',np.shape(layer.bias))
|
||||
|
||||
def train(self,xdata,ydata,train_round,accuracy):
|
||||
self.train_round = train_round
|
||||
self.accuracy = accuracy
|
||||
|
||||
self.ax_loss.hlines(self.accuracy, 0, self.train_round * 1.1)
|
||||
|
||||
x_shape = np.shape(xdata)
|
||||
for round_i in range(train_round):
|
||||
all_loss = 0
|
||||
for row in range(x_shape[0]):
|
||||
_xdata = np.asmatrix(xdata[row,:]).T
|
||||
_ydata = np.asmatrix(ydata[row,:]).T
|
||||
|
||||
# forward propagation
|
||||
for layer in self.layers:
|
||||
_xdata = layer.forward_propagation(_xdata)
|
||||
|
||||
loss, gradient = self.cal_loss(_ydata, _xdata)
|
||||
all_loss = all_loss + loss
|
||||
|
||||
# back propagation
|
||||
# the input_layer does not upgrade
|
||||
for layer in self.layers[:0:-1]:
|
||||
gradient = layer.back_propagation(gradient)
|
||||
|
||||
mse = all_loss/x_shape[0]
|
||||
self.train_mse.append(mse)
|
||||
|
||||
self.plot_loss()
|
||||
|
||||
if mse < self.accuracy:
|
||||
print('----达到精度----')
|
||||
return mse
|
||||
|
||||
def cal_loss(self,ydata,ydata_):
|
||||
self.loss = np.sum(np.power((ydata - ydata_),2))
|
||||
self.loss_gradient = 2 * (ydata_ - ydata)
|
||||
# vector (shape is the same as _ydata.shape)
|
||||
return self.loss,self.loss_gradient
|
||||
|
||||
def plot_loss(self):
|
||||
if self.ax_loss.lines:
|
||||
self.ax_loss.lines.remove(self.ax_loss.lines[0])
|
||||
self.ax_loss.plot(self.train_mse, 'r-')
|
||||
plt.ion()
|
||||
plt.show()
|
||||
plt.pause(0.1)
|
||||
|
||||
|
||||
|
||||
|
||||
def example():
|
||||
|
||||
x = np.random.randn(10,10)
|
||||
y = np.asarray([[0.8,0.4],[0.4,0.3],[0.34,0.45],[0.67,0.32],
|
||||
[0.88,0.67],[0.78,0.77],[0.55,0.66],[0.55,0.43],[0.54,0.1],
|
||||
[0.1,0.5]])
|
||||
|
||||
model = BPNN()
|
||||
model.add_layer(DenseLayer(10))
|
||||
model.add_layer(DenseLayer(20))
|
||||
model.add_layer(DenseLayer(30))
|
||||
model.add_layer(DenseLayer(2))
|
||||
|
||||
model.build()
|
||||
|
||||
model.summary()
|
||||
|
||||
model.train(xdata=x,ydata=y,train_round=100,accuracy=0.01)
|
||||
|
||||
if __name__ == '__main__':
|
||||
example()
|
|
@ -1,306 +0,0 @@
|
|||
#-*- coding: utf-8 -*-
|
||||
|
||||
'''
|
||||
- - - - - -- - - - - - - - - - - - - - - - - - - - - - -
|
||||
Name - - CNN - Convolution Neural Network For Photo Recognizing
|
||||
Goal - - Recognize Handing Writting Word Photo
|
||||
Detail:Total 5 layers neural network
|
||||
* Convolution layer
|
||||
* Pooling layer
|
||||
* Input layer layer of BP
|
||||
* Hiden layer of BP
|
||||
* Output layer of BP
|
||||
Author: Stephen Lee
|
||||
Github: 245885195@qq.com
|
||||
Date: 2017.9.20
|
||||
- - - - - -- - - - - - - - - - - - - - - - - - - - - - -
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
class CNN():
|
||||
|
||||
def __init__(self,conv1_get,size_p1,bp_num1,bp_num2,bp_num3,rate_w=0.2,rate_t=0.2):
|
||||
'''
|
||||
:param conv1_get: [a,c,d],size, number, step of convolution kernel
|
||||
:param size_p1: pooling size
|
||||
:param bp_num1: units number of flatten layer
|
||||
:param bp_num2: units number of hidden layer
|
||||
:param bp_num3: units number of output layer
|
||||
:param rate_w: rate of weight learning
|
||||
:param rate_t: rate of threshold learning
|
||||
'''
|
||||
self.num_bp1 = bp_num1
|
||||
self.num_bp2 = bp_num2
|
||||
self.num_bp3 = bp_num3
|
||||
self.conv1 = conv1_get[:2]
|
||||
self.step_conv1 = conv1_get[2]
|
||||
self.size_pooling1 = size_p1
|
||||
self.rate_weight = rate_w
|
||||
self.rate_thre = rate_t
|
||||
self.w_conv1 = [np.mat(-1*np.random.rand(self.conv1[0],self.conv1[0])+0.5) for i in range(self.conv1[1])]
|
||||
self.wkj = np.mat(-1 * np.random.rand(self.num_bp3, self.num_bp2) + 0.5)
|
||||
self.vji = np.mat(-1*np.random.rand(self.num_bp2, self.num_bp1)+0.5)
|
||||
self.thre_conv1 = -2*np.random.rand(self.conv1[1])+1
|
||||
self.thre_bp2 = -2*np.random.rand(self.num_bp2)+1
|
||||
self.thre_bp3 = -2*np.random.rand(self.num_bp3)+1
|
||||
|
||||
|
||||
def save_model(self,save_path):
|
||||
#save model dict with pickle
|
||||
import pickle
|
||||
model_dic = {'num_bp1':self.num_bp1,
|
||||
'num_bp2':self.num_bp2,
|
||||
'num_bp3':self.num_bp3,
|
||||
'conv1':self.conv1,
|
||||
'step_conv1':self.step_conv1,
|
||||
'size_pooling1':self.size_pooling1,
|
||||
'rate_weight':self.rate_weight,
|
||||
'rate_thre':self.rate_thre,
|
||||
'w_conv1':self.w_conv1,
|
||||
'wkj':self.wkj,
|
||||
'vji':self.vji,
|
||||
'thre_conv1':self.thre_conv1,
|
||||
'thre_bp2':self.thre_bp2,
|
||||
'thre_bp3':self.thre_bp3}
|
||||
with open(save_path, 'wb') as f:
|
||||
pickle.dump(model_dic, f)
|
||||
|
||||
print('Model saved: %s'% save_path)
|
||||
|
||||
@classmethod
|
||||
def ReadModel(cls,model_path):
|
||||
#read saved model
|
||||
import pickle
|
||||
with open(model_path, 'rb') as f:
|
||||
model_dic = pickle.load(f)
|
||||
|
||||
conv_get= model_dic.get('conv1')
|
||||
conv_get.append(model_dic.get('step_conv1'))
|
||||
size_p1 = model_dic.get('size_pooling1')
|
||||
bp1 = model_dic.get('num_bp1')
|
||||
bp2 = model_dic.get('num_bp2')
|
||||
bp3 = model_dic.get('num_bp3')
|
||||
r_w = model_dic.get('rate_weight')
|
||||
r_t = model_dic.get('rate_thre')
|
||||
#create model instance
|
||||
conv_ins = CNN(conv_get,size_p1,bp1,bp2,bp3,r_w,r_t)
|
||||
#modify model parameter
|
||||
conv_ins.w_conv1 = model_dic.get('w_conv1')
|
||||
conv_ins.wkj = model_dic.get('wkj')
|
||||
conv_ins.vji = model_dic.get('vji')
|
||||
conv_ins.thre_conv1 = model_dic.get('thre_conv1')
|
||||
conv_ins.thre_bp2 = model_dic.get('thre_bp2')
|
||||
conv_ins.thre_bp3 = model_dic.get('thre_bp3')
|
||||
return conv_ins
|
||||
|
||||
|
||||
def sig(self,x):
|
||||
return 1 / (1 + np.exp(-1*x))
|
||||
|
||||
def do_round(self,x):
|
||||
return round(x, 3)
|
||||
|
||||
def convolute(self,data,convs,w_convs,thre_convs,conv_step):
|
||||
#convolution process
|
||||
size_conv = convs[0]
|
||||
num_conv =convs[1]
|
||||
size_data = np.shape(data)[0]
|
||||
#get the data slice of original image data, data_focus
|
||||
data_focus = []
|
||||
for i_focus in range(0, size_data - size_conv + 1, conv_step):
|
||||
for j_focus in range(0, size_data - size_conv + 1, conv_step):
|
||||
focus = data[i_focus:i_focus + size_conv, j_focus:j_focus + size_conv]
|
||||
data_focus.append(focus)
|
||||
#caculate the feature map of every single kernel, and saved as list of matrix
|
||||
data_featuremap = []
|
||||
Size_FeatureMap = int((size_data - size_conv) / conv_step + 1)
|
||||
for i_map in range(num_conv):
|
||||
featuremap = []
|
||||
for i_focus in range(len(data_focus)):
|
||||
net_focus = np.sum(np.multiply(data_focus[i_focus], w_convs[i_map])) - thre_convs[i_map]
|
||||
featuremap.append(self.sig(net_focus))
|
||||
featuremap = np.asmatrix(featuremap).reshape(Size_FeatureMap, Size_FeatureMap)
|
||||
data_featuremap.append(featuremap)
|
||||
|
||||
#expanding the data slice to One dimenssion
|
||||
focus1_list = []
|
||||
for each_focus in data_focus:
|
||||
focus1_list.extend(self.Expand_Mat(each_focus))
|
||||
focus_list = np.asarray(focus1_list)
|
||||
return focus_list,data_featuremap
|
||||
|
||||
def pooling(self,featuremaps,size_pooling,type='average_pool'):
|
||||
#pooling process
|
||||
size_map = len(featuremaps[0])
|
||||
size_pooled = int(size_map/size_pooling)
|
||||
featuremap_pooled = []
|
||||
for i_map in range(len(featuremaps)):
|
||||
map = featuremaps[i_map]
|
||||
map_pooled = []
|
||||
for i_focus in range(0,size_map,size_pooling):
|
||||
for j_focus in range(0, size_map, size_pooling):
|
||||
focus = map[i_focus:i_focus + size_pooling, j_focus:j_focus + size_pooling]
|
||||
if type == 'average_pool':
|
||||
#average pooling
|
||||
map_pooled.append(np.average(focus))
|
||||
elif type == 'max_pooling':
|
||||
#max pooling
|
||||
map_pooled.append(np.max(focus))
|
||||
map_pooled = np.asmatrix(map_pooled).reshape(size_pooled,size_pooled)
|
||||
featuremap_pooled.append(map_pooled)
|
||||
return featuremap_pooled
|
||||
|
||||
def _expand(self,datas):
|
||||
#expanding three dimension data to one dimension list
|
||||
data_expanded = []
|
||||
for i in range(len(datas)):
|
||||
shapes = np.shape(datas[i])
|
||||
data_listed = datas[i].reshape(1,shapes[0]*shapes[1])
|
||||
data_listed = data_listed.getA().tolist()[0]
|
||||
data_expanded.extend(data_listed)
|
||||
data_expanded = np.asarray(data_expanded)
|
||||
return data_expanded
|
||||
|
||||
def _expand_mat(self,data_mat):
|
||||
#expanding matrix to one dimension list
|
||||
data_mat = np.asarray(data_mat)
|
||||
shapes = np.shape(data_mat)
|
||||
data_expanded = data_mat.reshape(1,shapes[0]*shapes[1])
|
||||
return data_expanded
|
||||
|
||||
def _calculate_gradient_from_pool(self,out_map,pd_pool,num_map,size_map,size_pooling):
|
||||
'''
|
||||
calcluate the gradient from the data slice of pool layer
|
||||
pd_pool: list of matrix
|
||||
out_map: the shape of data slice(size_map*size_map)
|
||||
return: pd_all: list of matrix, [num, size_map, size_map]
|
||||
'''
|
||||
pd_all = []
|
||||
i_pool = 0
|
||||
for i_map in range(num_map):
|
||||
pd_conv1 = np.ones((size_map, size_map))
|
||||
for i in range(0, size_map, size_pooling):
|
||||
for j in range(0, size_map, size_pooling):
|
||||
pd_conv1[i:i + size_pooling, j:j + size_pooling] = pd_pool[i_pool]
|
||||
i_pool = i_pool + 1
|
||||
pd_conv2 = np.multiply(pd_conv1,np.multiply(out_map[i_map],(1-out_map[i_map])))
|
||||
pd_all.append(pd_conv2)
|
||||
return pd_all
|
||||
|
||||
def trian(self,patterns,datas_train, datas_teach, n_repeat, error_accuracy,draw_e = bool):
|
||||
#model traning
|
||||
print('----------------------Start Training-------------------------')
|
||||
print((' - - Shape: Train_Data ',np.shape(datas_train)))
|
||||
print((' - - Shape: Teach_Data ',np.shape(datas_teach)))
|
||||
rp = 0
|
||||
all_mse = []
|
||||
mse = 10000
|
||||
while rp < n_repeat and mse >= error_accuracy:
|
||||
alle = 0
|
||||
print('-------------Learning Time %d--------------'%rp)
|
||||
for p in range(len(datas_train)):
|
||||
#print('------------Learning Image: %d--------------'%p)
|
||||
data_train = np.asmatrix(datas_train[p])
|
||||
data_teach = np.asarray(datas_teach[p])
|
||||
data_focus1,data_conved1 = self.convolute(data_train,self.conv1,self.w_conv1,
|
||||
self.thre_conv1,conv_step=self.step_conv1)
|
||||
data_pooled1 = self.pooling(data_conved1,self.size_pooling1)
|
||||
shape_featuremap1 = np.shape(data_conved1)
|
||||
'''
|
||||
print(' -----original shape ', np.shape(data_train))
|
||||
print(' ---- after convolution ',np.shape(data_conv1))
|
||||
print(' -----after pooling ',np.shape(data_pooled1))
|
||||
'''
|
||||
data_bp_input = self._expand(data_pooled1)
|
||||
bp_out1 = data_bp_input
|
||||
|
||||
bp_net_j = np.dot(bp_out1,self.vji.T) - self.thre_bp2
|
||||
bp_out2 = self.sig(bp_net_j)
|
||||
bp_net_k = np.dot(bp_out2 ,self.wkj.T) - self.thre_bp3
|
||||
bp_out3 = self.sig(bp_net_k)
|
||||
|
||||
#--------------Model Leaning ------------------------
|
||||
# calcluate error and gradient---------------
|
||||
pd_k_all = np.multiply((data_teach - bp_out3), np.multiply(bp_out3, (1 - bp_out3)))
|
||||
pd_j_all = np.multiply(np.dot(pd_k_all,self.wkj), np.multiply(bp_out2, (1 - bp_out2)))
|
||||
pd_i_all = np.dot(pd_j_all,self.vji)
|
||||
|
||||
pd_conv1_pooled = pd_i_all / (self.size_pooling1*self.size_pooling1)
|
||||
pd_conv1_pooled = pd_conv1_pooled.T.getA().tolist()
|
||||
pd_conv1_all = self._calculate_gradient_from_pool(data_conved1,pd_conv1_pooled,shape_featuremap1[0],
|
||||
shape_featuremap1[1],self.size_pooling1)
|
||||
#weight and threshold learning process---------
|
||||
#convolution layer
|
||||
for k_conv in range(self.conv1[1]):
|
||||
pd_conv_list = self._expand_mat(pd_conv1_all[k_conv])
|
||||
delta_w = self.rate_weight * np.dot(pd_conv_list,data_focus1)
|
||||
|
||||
self.w_conv1[k_conv] = self.w_conv1[k_conv] + delta_w.reshape((self.conv1[0],self.conv1[0]))
|
||||
|
||||
self.thre_conv1[k_conv] = self.thre_conv1[k_conv] - np.sum(pd_conv1_all[k_conv]) * self.rate_thre
|
||||
#all connected layer
|
||||
self.wkj = self.wkj + pd_k_all.T * bp_out2 * self.rate_weight
|
||||
self.vji = self.vji + pd_j_all.T * bp_out1 * self.rate_weight
|
||||
self.thre_bp3 = self.thre_bp3 - pd_k_all * self.rate_thre
|
||||
self.thre_bp2 = self.thre_bp2 - pd_j_all * self.rate_thre
|
||||
# calculate the sum error of all single image
|
||||
errors = np.sum(abs((data_teach - bp_out3)))
|
||||
alle = alle + errors
|
||||
#print(' ----Teach ',data_teach)
|
||||
#print(' ----BP_output ',bp_out3)
|
||||
rp = rp + 1
|
||||
mse = alle/patterns
|
||||
all_mse.append(mse)
|
||||
def draw_error():
|
||||
yplot = [error_accuracy for i in range(int(n_repeat * 1.2))]
|
||||
plt.plot(all_mse, '+-')
|
||||
plt.plot(yplot, 'r--')
|
||||
plt.xlabel('Learning Times')
|
||||
plt.ylabel('All_mse')
|
||||
plt.grid(True, alpha=0.5)
|
||||
plt.show()
|
||||
print('------------------Training Complished---------------------')
|
||||
print((' - - Training epoch: ', rp, ' - - Mse: %.6f' % mse))
|
||||
if draw_e:
|
||||
draw_error()
|
||||
return mse
|
||||
|
||||
def predict(self,datas_test):
|
||||
#model predict
|
||||
produce_out = []
|
||||
print('-------------------Start Testing-------------------------')
|
||||
print((' - - Shape: Test_Data ',np.shape(datas_test)))
|
||||
for p in range(len(datas_test)):
|
||||
data_test = np.asmatrix(datas_test[p])
|
||||
data_focus1, data_conved1 = self.convolute(data_test, self.conv1, self.w_conv1,
|
||||
self.thre_conv1, conv_step=self.step_conv1)
|
||||
data_pooled1 = self.pooling(data_conved1, self.size_pooling1)
|
||||
data_bp_input = self._expand(data_pooled1)
|
||||
|
||||
bp_out1 = data_bp_input
|
||||
bp_net_j = bp_out1 * self.vji.T - self.thre_bp2
|
||||
bp_out2 = self.sig(bp_net_j)
|
||||
bp_net_k = bp_out2 * self.wkj.T - self.thre_bp3
|
||||
bp_out3 = self.sig(bp_net_k)
|
||||
produce_out.extend(bp_out3.getA().tolist())
|
||||
res = [list(map(self.do_round,each)) for each in produce_out]
|
||||
return np.asarray(res)
|
||||
|
||||
def convolution(self,data):
|
||||
#return the data of image after convoluting process so we can check it out
|
||||
data_test = np.asmatrix(data)
|
||||
data_focus1, data_conved1 = self.convolute(data_test, self.conv1, self.w_conv1,
|
||||
self.thre_conv1, conv_step=self.step_conv1)
|
||||
data_pooled1 = self.pooling(data_conved1, self.size_pooling1)
|
||||
|
||||
return data_conved1,data_pooled1
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
'''
|
||||
I will put the example on other file
|
||||
'''
|
|
@ -1,124 +0,0 @@
|
|||
'''
|
||||
|
||||
Perceptron
|
||||
w = w + N * (d(k) - y) * x(k)
|
||||
|
||||
Using perceptron network for oil analysis,
|
||||
with Measuring of 3 parameters that represent chemical characteristics we can classify the oil, in p1 or p2
|
||||
p1 = -1
|
||||
p2 = 1
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
import random
|
||||
|
||||
|
||||
class Perceptron:
|
||||
def __init__(self, sample, exit, learn_rate=0.01, epoch_number=1000, bias=-1):
|
||||
self.sample = sample
|
||||
self.exit = exit
|
||||
self.learn_rate = learn_rate
|
||||
self.epoch_number = epoch_number
|
||||
self.bias = bias
|
||||
self.number_sample = len(sample)
|
||||
self.col_sample = len(sample[0])
|
||||
self.weight = []
|
||||
|
||||
def training(self):
|
||||
for sample in self.sample:
|
||||
sample.insert(0, self.bias)
|
||||
|
||||
for i in range(self.col_sample):
|
||||
self.weight.append(random.random())
|
||||
|
||||
self.weight.insert(0, self.bias)
|
||||
|
||||
epoch_count = 0
|
||||
|
||||
while True:
|
||||
erro = False
|
||||
for i in range(self.number_sample):
|
||||
u = 0
|
||||
for j in range(self.col_sample + 1):
|
||||
u = u + self.weight[j] * self.sample[i][j]
|
||||
y = self.sign(u)
|
||||
if y != self.exit[i]:
|
||||
|
||||
for j in range(self.col_sample + 1):
|
||||
|
||||
self.weight[j] = self.weight[j] + self.learn_rate * (self.exit[i] - y) * self.sample[i][j]
|
||||
erro = True
|
||||
#print('Epoch: \n',epoch_count)
|
||||
epoch_count = epoch_count + 1
|
||||
# if you want controle the epoch or just by erro
|
||||
if erro == False:
|
||||
print(('\nEpoch:\n',epoch_count))
|
||||
print('------------------------\n')
|
||||
#if epoch_count > self.epoch_number or not erro:
|
||||
break
|
||||
|
||||
def sort(self, sample):
|
||||
sample.insert(0, self.bias)
|
||||
u = 0
|
||||
for i in range(self.col_sample + 1):
|
||||
u = u + self.weight[i] * sample[i]
|
||||
|
||||
y = self.sign(u)
|
||||
|
||||
if y == -1:
|
||||
print(('Sample: ', sample))
|
||||
print('classification: P1')
|
||||
else:
|
||||
print(('Sample: ', sample))
|
||||
print('classification: P2')
|
||||
|
||||
def sign(self, u):
|
||||
return 1 if u >= 0 else -1
|
||||
|
||||
|
||||
samples = [
|
||||
[-0.6508, 0.1097, 4.0009],
|
||||
[-1.4492, 0.8896, 4.4005],
|
||||
[2.0850, 0.6876, 12.0710],
|
||||
[0.2626, 1.1476, 7.7985],
|
||||
[0.6418, 1.0234, 7.0427],
|
||||
[0.2569, 0.6730, 8.3265],
|
||||
[1.1155, 0.6043, 7.4446],
|
||||
[0.0914, 0.3399, 7.0677],
|
||||
[0.0121, 0.5256, 4.6316],
|
||||
[-0.0429, 0.4660, 5.4323],
|
||||
[0.4340, 0.6870, 8.2287],
|
||||
[0.2735, 1.0287, 7.1934],
|
||||
[0.4839, 0.4851, 7.4850],
|
||||
[0.4089, -0.1267, 5.5019],
|
||||
[1.4391, 0.1614, 8.5843],
|
||||
[-0.9115, -0.1973, 2.1962],
|
||||
[0.3654, 1.0475, 7.4858],
|
||||
[0.2144, 0.7515, 7.1699],
|
||||
[0.2013, 1.0014, 6.5489],
|
||||
[0.6483, 0.2183, 5.8991],
|
||||
[-0.1147, 0.2242, 7.2435],
|
||||
[-0.7970, 0.8795, 3.8762],
|
||||
[-1.0625, 0.6366, 2.4707],
|
||||
[0.5307, 0.1285, 5.6883],
|
||||
[-1.2200, 0.7777, 1.7252],
|
||||
[0.3957, 0.1076, 5.6623],
|
||||
[-0.1013, 0.5989, 7.1812],
|
||||
[2.4482, 0.9455, 11.2095],
|
||||
[2.0149, 0.6192, 10.9263],
|
||||
[0.2012, 0.2611, 5.4631]
|
||||
|
||||
]
|
||||
|
||||
exit = [-1, -1, -1, 1, 1, -1, 1, -1, 1, 1, -1, 1, -1, -1, -1, -1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1]
|
||||
|
||||
network = Perceptron(sample=samples, exit = exit, learn_rate=0.01, epoch_number=1000, bias=-1)
|
||||
|
||||
network.trannig()
|
||||
|
||||
while True:
|
||||
sample = []
|
||||
for i in range(3):
|
||||
sample.insert(i, float(raw_input('value: ')))
|
||||
network.sort(sample)
|
|
@ -1,17 +0,0 @@
|
|||
'''
|
||||
Problem Statement:
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5,
|
||||
we get 3,5,6 and 9. The sum of these multiples is 23.
|
||||
Find the sum of all the multiples of 3 or 5 below N.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
n = int(raw_input().strip())
|
||||
sum=0
|
||||
for a in range(3,n):
|
||||
if(a%3==0 or a%5==0):
|
||||
sum+=a
|
||||
print(sum)
|
|
@ -1,20 +0,0 @@
|
|||
'''
|
||||
Problem Statement:
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5,
|
||||
we get 3,5,6 and 9. The sum of these multiples is 23.
|
||||
Find the sum of all the multiples of 3 or 5 below N.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
n = int(raw_input().strip())
|
||||
sum = 0
|
||||
terms = (n-1)//3
|
||||
sum+= ((terms)*(6+(terms-1)*3))//2 #sum of an A.P.
|
||||
terms = (n-1)//5
|
||||
sum+= ((terms)*(10+(terms-1)*5))//2
|
||||
terms = (n-1)//15
|
||||
sum-= ((terms)*(30+(terms-1)*15))//2
|
||||
print(sum)
|
|
@ -1,50 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
'''
|
||||
Problem Statement:
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5,
|
||||
we get 3,5,6 and 9. The sum of these multiples is 23.
|
||||
Find the sum of all the multiples of 3 or 5 below N.
|
||||
'''
|
||||
'''
|
||||
This solution is based on the pattern that the successive numbers in the series follow: 0+3,+2,+1,+3,+1,+2,+3.
|
||||
'''
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
n = int(raw_input().strip())
|
||||
sum=0
|
||||
num=0
|
||||
while(1):
|
||||
num+=3
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=2
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=1
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=3
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=1
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=2
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
num+=3
|
||||
if(num>=n):
|
||||
break
|
||||
sum+=num
|
||||
|
||||
print(sum);
|
|
@ -1,30 +0,0 @@
|
|||
def mulitples(limit):
|
||||
xmulti = []
|
||||
zmulti = []
|
||||
z = 3
|
||||
x = 5
|
||||
temp = 1
|
||||
while True:
|
||||
result = z * temp
|
||||
if (result < limit):
|
||||
zmulti.append(result)
|
||||
temp += 1
|
||||
else:
|
||||
temp = 1
|
||||
break
|
||||
while True:
|
||||
result = x * temp
|
||||
if (result < limit):
|
||||
xmulti.append(result)
|
||||
temp += 1
|
||||
else:
|
||||
break
|
||||
collection = list(set(xmulti+zmulti))
|
||||
return (sum(collection))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
print (mulitples(1000))
|
|
@ -1,26 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2,
|
||||
the first 10 terms will be:
|
||||
1,2,3,5,8,13,21,34,55,89,..
|
||||
By considering the terms in the Fibonacci sequence whose values do not exceed n, find the sum of the even-valued terms.
|
||||
e.g. for n=10, we have {2,8}, sum is 10.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
try:
|
||||
raw_input # Python 2
|
||||
except NameError:
|
||||
raw_input = input # Python 3
|
||||
|
||||
n = int(raw_input().strip())
|
||||
i=1
|
||||
j=2
|
||||
sum=0
|
||||
while(j<=n):
|
||||
if((j&1)==0): #can also use (j%2==0)
|
||||
sum+=j
|
||||
temp=i
|
||||
i=j
|
||||
j=temp+i
|
||||
print(sum)
|
|
@ -1,12 +0,0 @@
|
|||
def fib(n):
|
||||
a, b, s = 0, 1, 0
|
||||
while b < n:
|
||||
if b % 2 == 0 and b < n: s += b
|
||||
a, b = b, a+b
|
||||
ls.append(s)
|
||||
|
||||
T = int(input().strip())
|
||||
ls = []
|
||||
for _ in range(T):
|
||||
fib(int(input().strip()))
|
||||
print(ls, sep = '\n')
|
|
@ -1,20 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
Each new term in the Fibonacci sequence is generated by adding the previous two terms.
|
||||
0,1,1,2,3,5,8,13,21,34,55,89,..
|
||||
Every third term from 0 is even So using this I have written a simple code
|
||||
By considering the terms in the Fibonacci sequence whose values do not exceed n, find the sum of the even-valued terms.
|
||||
e.g. for n=10, we have {2,8}, sum is 10.
|
||||
'''
|
||||
"""Python 3"""
|
||||
n = int(raw_input())
|
||||
a=0
|
||||
b=2
|
||||
count=0
|
||||
while 4*b+a<n:
|
||||
c=4*b+a
|
||||
a=b
|
||||
b=c
|
||||
count=count+a
|
||||
print(count+b)
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||
'''
|
||||
from __future__ import print_function, division
|
||||
|
||||
import math
|
||||
|
||||
def isprime(no):
|
||||
if(no==2):
|
||||
return True
|
||||
elif (no%2==0):
|
||||
return False
|
||||
sq = int(math.sqrt(no))+1
|
||||
for i in range(3,sq,2):
|
||||
if(no%i==0):
|
||||
return False
|
||||
return True
|
||||
|
||||
maxNumber = 0
|
||||
n=int(raw_input())
|
||||
if(isprime(n)):
|
||||
print(n)
|
||||
else:
|
||||
while (n%2==0):
|
||||
n=n/2
|
||||
if(isprime(n)):
|
||||
print(n)
|
||||
else:
|
||||
n1 = int(math.sqrt(n))+1
|
||||
for i in range(3,n1,2):
|
||||
if(n%i==0):
|
||||
if(isprime(n/i)):
|
||||
maxNumber = n/i
|
||||
break
|
||||
elif(isprime(i)):
|
||||
maxNumber = i
|
||||
print(maxNumber)
|
|
@ -1,17 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
n=int(raw_input())
|
||||
prime=1
|
||||
i=2
|
||||
while(i*i<=n):
|
||||
while(n%i==0):
|
||||
prime=i
|
||||
n/=i
|
||||
i+=1
|
||||
if(n>1):
|
||||
prime=n
|
||||
print(prime)
|
|
@ -1,29 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
|
||||
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
limit = int(raw_input("limit? "))
|
||||
|
||||
# fetchs the next number
|
||||
for number in range(limit-1,10000,-1):
|
||||
|
||||
# converts number into string.
|
||||
strNumber = str(number)
|
||||
|
||||
# checks whether 'strNumber' is a palindrome.
|
||||
if(strNumber == strNumber[::-1]):
|
||||
|
||||
divisor = 999
|
||||
|
||||
# if 'number' is a product of two 3-digit numbers
|
||||
# then number is the answer otherwise fetch next number.
|
||||
while(divisor != 99):
|
||||
|
||||
if((number % divisor == 0) and (len(str(number / divisor)) == 3)):
|
||||
|
||||
print(number)
|
||||
exit(0)
|
||||
|
||||
divisor -=1
|
|
@ -1,19 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
|
||||
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
arr = []
|
||||
for i in range(999,100,-1):
|
||||
for j in range(999,100,-1):
|
||||
t = str(i*j)
|
||||
if t == t[::-1]:
|
||||
arr.append(i*j)
|
||||
arr.sort()
|
||||
|
||||
n=int(raw_input())
|
||||
for i in arr[::-1]:
|
||||
if(i<n):
|
||||
print(i)
|
||||
exit(0)
|
|
@ -1,21 +0,0 @@
|
|||
'''
|
||||
Problem:
|
||||
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
|
||||
What is the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to N?
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
n = int(raw_input())
|
||||
i = 0
|
||||
while 1:
|
||||
i+=n*(n-1)
|
||||
nfound=0
|
||||
for j in range(2,n):
|
||||
if (i%j != 0):
|
||||
nfound=1
|
||||
break
|
||||
if(nfound==0):
|
||||
if(i==0):
|
||||
i=1
|
||||
print(i)
|
||||
break
|
|
@ -1,20 +0,0 @@
|
|||
#!/bin/python3
|
||||
'''
|
||||
Problem:
|
||||
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
|
||||
What is the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to N?
|
||||
'''
|
||||
|
||||
""" Euclidean GCD Algorithm """
|
||||
def gcd(x,y):
|
||||
return x if y==0 else gcd(y,x%y)
|
||||
|
||||
""" Using the property lcm*gcd of two numbers = product of them """
|
||||
def lcm(x,y):
|
||||
return (x*y)//gcd(x,y)
|
||||
|
||||
n = int(raw_input())
|
||||
g=1
|
||||
for i in range(1,n+1):
|
||||
g=lcm(g,i)
|
||||
print(g)
|
|
@ -1,20 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Problem:
|
||||
The sum of the squares of the first ten natural numbers is,
|
||||
1^2 + 2^2 + ... + 10^2 = 385
|
||||
The square of the sum of the first ten natural numbers is,
|
||||
(1 + 2 + ... + 10)^2 = 552 = 3025
|
||||
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
|
||||
Find the difference between the sum of the squares of the first N natural numbers and the square of the sum.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
suma = 0
|
||||
sumb = 0
|
||||
n = int(raw_input())
|
||||
for i in range(1,n+1):
|
||||
suma += i**2
|
||||
sumb += i
|
||||
sum = sumb**2 - suma
|
||||
print(sum)
|
|
@ -1,16 +0,0 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Problem:
|
||||
The sum of the squares of the first ten natural numbers is,
|
||||
1^2 + 2^2 + ... + 10^2 = 385
|
||||
The square of the sum of the first ten natural numbers is,
|
||||
(1 + 2 + ... + 10)^2 = 552 = 3025
|
||||
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
|
||||
Find the difference between the sum of the squares of the first N natural numbers and the square of the sum.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
n = int(raw_input())
|
||||
suma = n*(n+1)/2
|
||||
suma **= 2
|
||||
sumb = n*(n+1)*(2*n+1)/6
|
||||
print(suma-sumb)
|
|
@ -1,30 +0,0 @@
|
|||
'''
|
||||
By listing the first six prime numbers:
|
||||
2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
|
||||
What is the Nth prime number?
|
||||
'''
|
||||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
def isprime(n):
|
||||
if (n==2):
|
||||
return True
|
||||
elif (n%2==0):
|
||||
return False
|
||||
else:
|
||||
sq = int(sqrt(n))+1
|
||||
for i in range(3,sq,2):
|
||||
if(n%i==0):
|
||||
return False
|
||||
return True
|
||||
n = int(raw_input())
|
||||
i=0
|
||||
j=1
|
||||
while(i!=n and j<3):
|
||||
j+=1
|
||||
if (isprime(j)):
|
||||
i+=1
|
||||
while(i!=n):
|
||||
j+=2
|
||||
if(isprime(j)):
|
||||
i+=1
|
||||
print(j)
|
|
@ -1,16 +0,0 @@
|
|||
# By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the Nth prime number?
|
||||
def isprime(number):
|
||||
for i in range(2,int(number**0.5)+1):
|
||||
if number%i==0:
|
||||
return False
|
||||
return True
|
||||
n = int(raw_input('Enter The N\'th Prime Number You Want To Get: ')) # Ask For The N'th Prime Number Wanted
|
||||
primes = []
|
||||
num = 2
|
||||
while len(primes) < n:
|
||||
if isprime(num):
|
||||
primes.append(num)
|
||||
num += 1
|
||||
else:
|
||||
num += 1
|
||||
print(primes[len(primes) - 1])
|
|
@ -1,15 +0,0 @@
|
|||
import sys
|
||||
def main():
|
||||
LargestProduct = -sys.maxsize-1
|
||||
number=raw_input().strip()
|
||||
for i in range(len(number)-13):
|
||||
product=1
|
||||
for j in range(13):
|
||||
product *= int(number[i+j])
|
||||
if product > LargestProduct:
|
||||
LargestProduct = product
|
||||
print(LargestProduct)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,15 +0,0 @@
|
|||
from __future__ import print_function
|
||||
# Program to find the product of a,b,c which are Pythagorean Triplet that satisfice the following:
|
||||
# 1. a < b < c
|
||||
# 2. a**2 + b**2 = c**2
|
||||
# 3. a + b + c = 1000
|
||||
|
||||
print("Please Wait...")
|
||||
for a in range(300):
|
||||
for b in range(400):
|
||||
for c in range(500):
|
||||
if(a < b < c):
|
||||
if((a**2) + (b**2) == (c**2)):
|
||||
if((a+b+c) == 1000):
|
||||
print(("Product of",a,"*",b,"*",c,"=",(a*b*c)))
|
||||
break
|
|
@ -1,18 +0,0 @@
|
|||
"""A Pythagorean triplet is a set of three natural numbers, for which,
|
||||
a^2+b^2=c^2
|
||||
Given N, Check if there exists any Pythagorean triplet for which a+b+c=N
|
||||
Find maximum possible value of product of a,b,c among all such Pythagorean triplets, If there is no such Pythagorean triplet print -1."""
|
||||
#!/bin/python3
|
||||
|
||||
product=-1
|
||||
d=0
|
||||
N = int(raw_input())
|
||||
for a in range(1,N//3):
|
||||
"""Solving the two equations a**2+b**2=c**2 and a+b+c=N eliminating c """
|
||||
b=(N*N-2*a*N)//(2*N-2*a)
|
||||
c=N-a-b
|
||||
if c*c==(a*a+b*b):
|
||||
d=(a*b*c)
|
||||
if d>=product:
|
||||
product=d
|
||||
print(product)
|
|
@ -1,38 +0,0 @@
|
|||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def is_prime(n):
|
||||
for i in xrange(2, int(sqrt(n))+1):
|
||||
if n%i == 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def sum_of_primes(n):
|
||||
if n > 2:
|
||||
sumOfPrimes = 2
|
||||
else:
|
||||
return 0
|
||||
|
||||
for i in xrange(3, n, 2):
|
||||
if is_prime(i):
|
||||
sumOfPrimes += i
|
||||
|
||||
return sumOfPrimes
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print(sum_of_primes(2000000))
|
||||
else:
|
||||
try:
|
||||
n = int(sys.argv[1])
|
||||
print(sum_of_primes(n))
|
||||
except ValueError:
|
||||
print('Invalid entry - please enter a number.')
|
|
@ -1,20 +0,0 @@
|
|||
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
|
||||
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
|
||||
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
|
||||
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
|
||||
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
|
||||
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
|
||||
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
|
||||
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
|
||||
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
|
||||
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
|
||||
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
|
||||
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
|
||||
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
|
||||
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
|
||||
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
|
||||
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
|
||||
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
|
||||
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
|
||||
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
|
||||
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48
|
|
@ -1,68 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
What is the greatest product of four adjacent numbers (horizontally, vertically, or diagonally) in this 20x20 array?
|
||||
|
||||
08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77 91 08
|
||||
49 49 99 40 17 81 18 57 60 87 17 40 98 43 69 48 04 56 62 00
|
||||
81 49 31 73 55 79 14 29 93 71 40 67 53 88 30 03 49 13 36 65
|
||||
52 70 95 23 04 60 11 42 69 24 68 56 01 32 56 71 37 02 36 91
|
||||
22 31 16 71 51 67 63 89 41 92 36 54 22 40 40 28 66 33 13 80
|
||||
24 47 32 60 99 03 45 02 44 75 33 53 78 36 84 20 35 17 12 50
|
||||
32 98 81 28 64 23 67 10 26 38 40 67 59 54 70 66 18 38 64 70
|
||||
67 26 20 68 02 62 12 20 95 63 94 39 63 08 40 91 66 49 94 21
|
||||
24 55 58 05 66 73 99 26 97 17 78 78 96 83 14 88 34 89 63 72
|
||||
21 36 23 09 75 00 76 44 20 45 35 14 00 61 33 97 34 31 33 95
|
||||
78 17 53 28 22 75 31 67 15 94 03 80 04 62 16 14 09 53 56 92
|
||||
16 39 05 42 96 35 31 47 55 58 88 24 00 17 54 24 36 29 85 57
|
||||
86 56 00 48 35 71 89 07 05 44 44 37 44 60 21 58 51 54 17 58
|
||||
19 80 81 68 05 94 47 69 28 73 92 13 86 52 17 77 04 89 55 40
|
||||
04 52 08 83 97 35 99 16 07 97 57 32 16 26 26 79 33 27 98 66
|
||||
88 36 68 87 57 62 20 72 03 46 33 67 46 55 12 32 63 93 53 69
|
||||
04 42 16 73 38 25 39 11 24 94 72 18 08 46 29 32 40 62 76 36
|
||||
20 69 36 41 72 30 23 88 34 62 99 69 82 67 59 85 74 04 36 16
|
||||
20 73 35 29 78 31 90 01 74 31 49 71 48 86 81 16 23 57 05 54
|
||||
01 70 54 71 83 51 54 69 16 92 33 48 61 43 52 01 89 19 67 48
|
||||
'''
|
||||
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 2
|
||||
|
||||
def largest_product(grid):
|
||||
nColumns = len(grid[0])
|
||||
nRows = len(grid)
|
||||
|
||||
largest = 0
|
||||
lrDiagProduct = 0
|
||||
rlDiagProduct = 0
|
||||
|
||||
#Check vertically, horizontally, diagonally at the same time (only works for nxn grid)
|
||||
for i in xrange(nColumns):
|
||||
for j in xrange(nRows-3):
|
||||
vertProduct = grid[j][i]*grid[j+1][i]*grid[j+2][i]*grid[j+3][i]
|
||||
horzProduct = grid[i][j]*grid[i][j+1]*grid[i][j+2]*grid[i][j+3]
|
||||
|
||||
#Left-to-right diagonal (\) product
|
||||
if (i < nColumns-3):
|
||||
lrDiagProduct = grid[i][j]*grid[i+1][j+1]*grid[i+2][j+2]*grid[i+3][j+3]
|
||||
|
||||
#Right-to-left diagonal(/) product
|
||||
if (i > 2):
|
||||
rlDiagProduct = grid[i][j]*grid[i-1][j+1]*grid[i-2][j+2]*grid[i-3][j+3]
|
||||
|
||||
maxProduct = max(vertProduct, horzProduct, lrDiagProduct, rlDiagProduct)
|
||||
if maxProduct > largest:
|
||||
largest = maxProduct
|
||||
|
||||
return largest
|
||||
|
||||
if __name__ == '__main__':
|
||||
grid = []
|
||||
with open('grid.txt') as file:
|
||||
for line in file:
|
||||
grid.append(line.strip('\n').split(' '))
|
||||
|
||||
grid = [[int(i) for i in grid[j]] for j in xrange(len(grid))]
|
||||
|
||||
print(largest_product(grid))
|
|
@ -1,39 +0,0 @@
|
|||
def main():
|
||||
with open ("grid.txt", "r") as f:
|
||||
l = []
|
||||
for i in range(20):
|
||||
l.append([int(x) for x in f.readline().split()])
|
||||
|
||||
maximum = 0
|
||||
|
||||
# right
|
||||
for i in range(20):
|
||||
for j in range(17):
|
||||
temp = l[i][j] * l[i][j+1] * l[i][j+2] * l[i][j+3]
|
||||
if temp > maximum:
|
||||
maximum = temp
|
||||
|
||||
# down
|
||||
for i in range(17):
|
||||
for j in range(20):
|
||||
temp = l[i][j] * l[i+1][j] * l[i+2][j] * l[i+3][j]
|
||||
if temp > maximum:
|
||||
maximum = temp
|
||||
|
||||
#diagonal 1
|
||||
for i in range(17):
|
||||
for j in range(17):
|
||||
temp = l[i][j] * l[i+1][j+1] * l[i+2][j+2] * l[i+3][j+3]
|
||||
if temp > maximum:
|
||||
maximum = temp
|
||||
|
||||
#diagonal 2
|
||||
for i in range(17):
|
||||
for j in range(3, 20):
|
||||
temp = l[i][j] * l[i+1][j-1] * l[i+2][j-2] * l[i+3][j-3]
|
||||
if temp > maximum:
|
||||
maximum = temp
|
||||
print(maximum)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,46 +0,0 @@
|
|||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
'''
|
||||
Highly divisible triangular numbers
|
||||
Problem 12
|
||||
The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be:
|
||||
|
||||
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
|
||||
|
||||
Let us list the factors of the first seven triangle numbers:
|
||||
|
||||
1: 1
|
||||
3: 1,3
|
||||
6: 1,2,3,6
|
||||
10: 1,2,5,10
|
||||
15: 1,3,5,15
|
||||
21: 1,3,7,21
|
||||
28: 1,2,4,7,14,28
|
||||
We can see that 28 is the first triangle number to have over five divisors.
|
||||
|
||||
What is the value of the first triangle number to have over five hundred divisors?
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def count_divisors(n):
|
||||
nDivisors = 0
|
||||
for i in xrange(1, int(sqrt(n))+1):
|
||||
if n%i == 0:
|
||||
nDivisors += 2
|
||||
|
||||
return nDivisors
|
||||
|
||||
tNum = 1
|
||||
i = 1
|
||||
|
||||
while True:
|
||||
i += 1
|
||||
tNum += i
|
||||
|
||||
if count_divisors(tNum) > 500:
|
||||
break
|
||||
|
||||
print(tNum)
|
|
@ -1,14 +0,0 @@
|
|||
'''
|
||||
Problem Statement:
|
||||
Work out the first ten digits of the sum of the N 50-digit numbers.
|
||||
'''
|
||||
from __future__ import print_function
|
||||
|
||||
n = int(raw_input().strip())
|
||||
|
||||
array = []
|
||||
for i in range(n):
|
||||
array.append(int(raw_input().strip()))
|
||||
|
||||
print(str(sum(array))[:10])
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
from __future__ import print_function
|
||||
largest_number = 0
|
||||
pre_counter = 0
|
||||
|
||||
for input1 in range(750000,1000000):
|
||||
counter = 1
|
||||
number = input1
|
||||
|
||||
while number > 1:
|
||||
if number % 2 == 0:
|
||||
number /=2
|
||||
counter += 1
|
||||
else:
|
||||
number = (3*number)+1
|
||||
counter += 1
|
||||
|
||||
if counter > pre_counter:
|
||||
largest_number = input1
|
||||
pre_counter = counter
|
||||
|
||||
print(('Largest Number:',largest_number,'->',pre_counter,'digits'))
|
|
@ -1,20 +0,0 @@
|
|||
from __future__ import print_function
|
||||
from math import factorial
|
||||
|
||||
def lattice_paths(n):
|
||||
n = 2*n #middle entry of odd rows starting at row 3 is the solution for n = 1, 2, 3,...
|
||||
k = n/2
|
||||
|
||||
return factorial(n)/(factorial(k)*factorial(n-k))
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print(lattice_paths(20))
|
||||
else:
|
||||
try:
|
||||
n = int(sys.argv[1])
|
||||
print(lattice_paths(n))
|
||||
except ValueError:
|
||||
print('Invalid entry - please enter a number.')
|
|
@ -1,15 +0,0 @@
|
|||
power = int(raw_input("Enter the power of 2: "))
|
||||
num = 2**power
|
||||
|
||||
string_num = str(num)
|
||||
|
||||
list_num = list(string_num)
|
||||
|
||||
sum_of_num = 0
|
||||
|
||||
print("2 ^",power,"=",num)
|
||||
|
||||
for i in list_num:
|
||||
sum_of_num += int(i)
|
||||
|
||||
print("Sum of the digits are:",sum_of_num)
|
|
@ -1,35 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Number letter counts
|
||||
Problem 17
|
||||
|
||||
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total.
|
||||
|
||||
If all the numbers from 1 to 1000 (one thousand) inclusive were written out in words, how many letters would be used?
|
||||
|
||||
|
||||
NOTE: Do not count spaces or hyphens. For example, 342 (three hundred and forty-two) contains 23 letters and 115 (one hundred and fifteen)
|
||||
contains 20 letters. The use of "and" when writing out numbers is in compliance with British usage.
|
||||
'''
|
||||
|
||||
ones_counts = [0, 3, 3, 5, 4, 4, 3, 5, 5, 4, 3, 6, 6, 8, 8, 7, 7, 9, 8, 8] #number of letters in zero, one, two, ..., nineteen (0 for zero since it's never said aloud)
|
||||
tens_counts = [0, 0, 6, 6, 5, 5, 5, 7, 6, 6] #number of letters in twenty, thirty, ..., ninety (0 for numbers less than 20 due to inconsistency in teens)
|
||||
|
||||
count = 0
|
||||
|
||||
for i in range(1, 1001):
|
||||
if i < 1000:
|
||||
if i >= 100:
|
||||
count += ones_counts[i/100] + 7 #add number of letters for "n hundred"
|
||||
|
||||
if i%100 is not 0:
|
||||
count += 3 #add number of letters for "and" if number is not multiple of 100
|
||||
|
||||
if 0 < i%100 < 20:
|
||||
count += ones_counts[i%100] #add number of letters for one, two, three, ..., nineteen (could be combined with below if not for inconsistency in teens)
|
||||
else:
|
||||
count += ones_counts[i%10] + tens_counts[(i%100-i%10)/10] #add number of letters for twenty, twenty one, ..., ninety nine
|
||||
else:
|
||||
count += ones_counts[i/1000] + 8
|
||||
|
||||
print(count)
|
|
@ -1,51 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Counting Sundays
|
||||
Problem 19
|
||||
|
||||
You are given the following information, but you may prefer to do some research for yourself.
|
||||
|
||||
1 Jan 1900 was a Monday.
|
||||
Thirty days has September,
|
||||
April, June and November.
|
||||
All the rest have thirty-one,
|
||||
Saving February alone,
|
||||
Which has twenty-eight, rain or shine.
|
||||
And on leap years, twenty-nine.
|
||||
|
||||
A leap year occurs on any year evenly divisible by 4, but not on a century unless it is divisible by 400.
|
||||
|
||||
How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?
|
||||
'''
|
||||
|
||||
days_per_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
|
||||
|
||||
day = 6
|
||||
month = 1
|
||||
year = 1901
|
||||
|
||||
sundays = 0
|
||||
|
||||
while year < 2001:
|
||||
day += 7
|
||||
|
||||
if (year%4 == 0 and not year%100 == 0) or (year%400 == 0):
|
||||
if day > days_per_month[month-1] and month is not 2:
|
||||
month += 1
|
||||
day = day-days_per_month[month-2]
|
||||
elif day > 29 and month is 2:
|
||||
month += 1
|
||||
day = day-29
|
||||
else:
|
||||
if day > days_per_month[month-1]:
|
||||
month += 1
|
||||
day = day-days_per_month[month-2]
|
||||
|
||||
if month > 12:
|
||||
year += 1
|
||||
month = 1
|
||||
|
||||
if year < 2001 and day is 1:
|
||||
sundays += 1
|
||||
|
||||
print(sundays)
|
|
@ -1,27 +0,0 @@
|
|||
# Finding the factorial.
|
||||
def factorial(n):
|
||||
fact = 1
|
||||
for i in range(1,n+1):
|
||||
fact *= i
|
||||
return fact
|
||||
|
||||
# Spliting the digits and adding it.
|
||||
def split_and_add(number):
|
||||
sum_of_digits = 0
|
||||
while(number>0):
|
||||
last_digit = number % 10
|
||||
sum_of_digits += last_digit
|
||||
number = int(number/10) # Removing the last_digit from the given number.
|
||||
return sum_of_digits
|
||||
|
||||
# Taking the user input.
|
||||
number = int(raw_input("Enter the Number: "))
|
||||
|
||||
# Assigning the factorial from the factorial function.
|
||||
factorial = factorial(number)
|
||||
|
||||
# Spliting and adding the factorial into answer.
|
||||
answer = split_and_add(factorial)
|
||||
|
||||
# Printing the answer.
|
||||
print(answer)
|
|
@ -1,5 +0,0 @@
|
|||
from math import factorial
|
||||
def main():
|
||||
print(sum([int(x) for x in str(factorial(100))]))
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,42 +0,0 @@
|
|||
#-.- coding: latin-1 -.-
|
||||
from __future__ import print_function
|
||||
from math import sqrt
|
||||
'''
|
||||
Amicable Numbers
|
||||
Problem 21
|
||||
|
||||
Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n).
|
||||
If d(a) = b and d(b) = a, where a ≠ b, then a and b are an amicable pair and each of a and b are called amicable numbers.
|
||||
|
||||
For example, the proper divisors of 220 are 1, 2, 4, 5, 10, 11, 20, 22, 44, 55 and 110; therefore d(220) = 284. The proper divisors of 284 are 1, 2, 4, 71 and 142; so d(284) = 220.
|
||||
|
||||
Evaluate the sum of all the amicable numbers under 10000.
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def sum_of_divisors(n):
|
||||
total = 0
|
||||
for i in xrange(1, int(sqrt(n)+1)):
|
||||
if n%i == 0 and i != sqrt(n):
|
||||
total += i + n//i
|
||||
elif i == sqrt(n):
|
||||
total += i
|
||||
|
||||
return total-n
|
||||
|
||||
sums = []
|
||||
total = 0
|
||||
|
||||
for i in xrange(1, 10000):
|
||||
n = sum_of_divisors(i)
|
||||
|
||||
if n < len(sums):
|
||||
if sums[n-1] == i:
|
||||
total += n + i
|
||||
|
||||
sums.append(n)
|
||||
|
||||
print(total)
|
File diff suppressed because one or more lines are too long
|
@ -1,37 +0,0 @@
|
|||
# -*- coding: latin-1 -*-
|
||||
from __future__ import print_function
|
||||
'''
|
||||
Name scores
|
||||
Problem 22
|
||||
|
||||
Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it
|
||||
into alphabetical order. Then working out the alphabetical value for each name, multiply this value by its alphabetical position in the list
|
||||
to obtain a name score.
|
||||
|
||||
For example, when the list is sorted into alphabetical order, COLIN, which is worth 3 + 15 + 12 + 9 + 14 = 53, is the 938th name in the list.
|
||||
So, COLIN would obtain a score of 938 × 53 = 49714.
|
||||
|
||||
What is the total of all the name scores in the file?
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
with open('p022_names.txt') as file:
|
||||
names = str(file.readlines()[0])
|
||||
names = names.replace('"', '').split(',')
|
||||
|
||||
names.sort()
|
||||
|
||||
name_score = 0
|
||||
total_score = 0
|
||||
|
||||
for i, name in enumerate(names):
|
||||
for letter in name:
|
||||
name_score += ord(letter) - 64
|
||||
|
||||
total_score += (i+1)*name_score
|
||||
name_score = 0
|
||||
|
||||
print(total_score)
|
|
@ -1,533 +0,0 @@
|
|||
def main():
|
||||
name = [
|
||||
"MARY", "PATRICIA", "LINDA", "BARBARA", "ELIZABETH", "JENNIFER", "MARIA", "SUSAN", "MARGARET", "DOROTHY",
|
||||
"LISA", "NANCY", "KAREN", "BETTY", "HELEN", "SANDRA", "DONNA", "CAROL", "RUTH", "SHARON",
|
||||
"MICHELLE", "LAURA", "SARAH", "KIMBERLY", "DEBORAH", "JESSICA", "SHIRLEY", "CYNTHIA", "ANGELA", "MELISSA",
|
||||
"BRENDA", "AMY", "ANNA", "REBECCA", "VIRGINIA", "KATHLEEN", "PAMELA", "MARTHA", "DEBRA", "AMANDA",
|
||||
"STEPHANIE", "CAROLYN", "CHRISTINE", "MARIE", "JANET", "CATHERINE", "FRANCES", "ANN", "JOYCE", "DIANE",
|
||||
"ALICE", "JULIE", "HEATHER", "TERESA", "DORIS", "GLORIA", "EVELYN", "JEAN", "CHERYL", "MILDRED",
|
||||
"KATHERINE", "JOAN", "ASHLEY", "JUDITH", "ROSE", "JANICE", "KELLY", "NICOLE", "JUDY", "CHRISTINA",
|
||||
"KATHY", "THERESA", "BEVERLY", "DENISE", "TAMMY", "IRENE", "JANE", "LORI", "RACHEL", "MARILYN",
|
||||
"ANDREA", "KATHRYN", "LOUISE", "SARA", "ANNE", "JACQUELINE", "WANDA", "BONNIE", "JULIA", "RUBY",
|
||||
"LOIS", "TINA", "PHYLLIS", "NORMA", "PAULA", "DIANA", "ANNIE", "LILLIAN", "EMILY", "ROBIN",
|
||||
"PEGGY", "CRYSTAL", "GLADYS", "RITA", "DAWN", "CONNIE", "FLORENCE", "TRACY", "EDNA", "TIFFANY",
|
||||
"CARMEN", "ROSA", "CINDY", "GRACE", "WENDY", "VICTORIA", "EDITH", "KIM", "SHERRY", "SYLVIA",
|
||||
"JOSEPHINE", "THELMA", "SHANNON", "SHEILA", "ETHEL", "ELLEN", "ELAINE", "MARJORIE", "CARRIE", "CHARLOTTE",
|
||||
"MONICA", "ESTHER", "PAULINE", "EMMA", "JUANITA", "ANITA", "RHONDA", "HAZEL", "AMBER", "EVA",
|
||||
"DEBBIE", "APRIL", "LESLIE", "CLARA", "LUCILLE", "JAMIE", "JOANNE", "ELEANOR", "VALERIE", "DANIELLE",
|
||||
"MEGAN", "ALICIA", "SUZANNE", "MICHELE", "GAIL", "BERTHA", "DARLENE", "VERONICA", "JILL", "ERIN",
|
||||
"GERALDINE", "LAUREN", "CATHY", "JOANN", "LORRAINE", "LYNN", "SALLY", "REGINA", "ERICA", "BEATRICE",
|
||||
"DOLORES", "BERNICE", "AUDREY", "YVONNE", "ANNETTE", "JUNE", "SAMANTHA", "MARION", "DANA", "STACY",
|
||||
"ANA", "RENEE", "IDA", "VIVIAN", "ROBERTA", "HOLLY", "BRITTANY", "MELANIE", "LORETTA", "YOLANDA",
|
||||
"JEANETTE", "LAURIE", "KATIE", "KRISTEN", "VANESSA", "ALMA", "SUE", "ELSIE", "BETH", "JEANNE",
|
||||
"VICKI", "CARLA", "TARA", "ROSEMARY", "EILEEN", "TERRI", "GERTRUDE", "LUCY", "TONYA", "ELLA",
|
||||
"STACEY", "WILMA", "GINA", "KRISTIN", "JESSIE", "NATALIE", "AGNES", "VERA", "WILLIE", "CHARLENE",
|
||||
"BESSIE", "DELORES", "MELINDA", "PEARL", "ARLENE", "MAUREEN", "COLLEEN", "ALLISON", "TAMARA", "JOY",
|
||||
"GEORGIA", "CONSTANCE", "LILLIE", "CLAUDIA", "JACKIE", "MARCIA", "TANYA", "NELLIE", "MINNIE", "MARLENE",
|
||||
"HEIDI", "GLENDA", "LYDIA", "VIOLA", "COURTNEY", "MARIAN", "STELLA", "CAROLINE", "DORA", "JO",
|
||||
"VICKIE", "MATTIE", "TERRY", "MAXINE", "IRMA", "MABEL", "MARSHA", "MYRTLE", "LENA", "CHRISTY",
|
||||
"DEANNA", "PATSY", "HILDA", "GWENDOLYN", "JENNIE", "NORA", "MARGIE", "NINA", "CASSANDRA", "LEAH",
|
||||
"PENNY", "KAY", "PRISCILLA", "NAOMI", "CAROLE", "BRANDY", "OLGA", "BILLIE", "DIANNE", "TRACEY",
|
||||
"LEONA", "JENNY", "FELICIA", "SONIA", "MIRIAM", "VELMA", "BECKY", "BOBBIE", "VIOLET", "KRISTINA",
|
||||
"TONI", "MISTY", "MAE", "SHELLY", "DAISY", "RAMONA", "SHERRI", "ERIKA", "KATRINA", "CLAIRE",
|
||||
"LINDSEY", "LINDSAY", "GENEVA", "GUADALUPE", "BELINDA", "MARGARITA", "SHERYL", "CORA", "FAYE", "ADA",
|
||||
"NATASHA", "SABRINA", "ISABEL", "MARGUERITE", "HATTIE", "HARRIET", "MOLLY", "CECILIA", "KRISTI", "BRANDI",
|
||||
"BLANCHE", "SANDY", "ROSIE", "JOANNA", "IRIS", "EUNICE", "ANGIE", "INEZ", "LYNDA", "MADELINE",
|
||||
"AMELIA", "ALBERTA", "GENEVIEVE", "MONIQUE", "JODI", "JANIE", "MAGGIE", "KAYLA", "SONYA", "JAN",
|
||||
"LEE", "KRISTINE", "CANDACE", "FANNIE", "MARYANN", "OPAL", "ALISON", "YVETTE", "MELODY", "LUZ",
|
||||
"SUSIE", "OLIVIA", "FLORA", "SHELLEY", "KRISTY", "MAMIE", "LULA", "LOLA", "VERNA", "BEULAH",
|
||||
"ANTOINETTE", "CANDICE", "JUANA", "JEANNETTE", "PAM", "KELLI", "HANNAH", "WHITNEY", "BRIDGET", "KARLA",
|
||||
"CELIA", "LATOYA", "PATTY", "SHELIA", "GAYLE", "DELLA", "VICKY", "LYNNE", "SHERI", "MARIANNE",
|
||||
"KARA", "JACQUELYN", "ERMA", "BLANCA", "MYRA", "LETICIA", "PAT", "KRISTA", "ROXANNE", "ANGELICA",
|
||||
"JOHNNIE", "ROBYN", "FRANCIS", "ADRIENNE", "ROSALIE", "ALEXANDRA", "BROOKE", "BETHANY", "SADIE", "BERNADETTE",
|
||||
"TRACI", "JODY", "KENDRA", "JASMINE", "NICHOLE", "RACHAEL", "CHELSEA", "MABLE", "ERNESTINE", "MURIEL",
|
||||
"MARCELLA", "ELENA", "KRYSTAL", "ANGELINA", "NADINE", "KARI", "ESTELLE", "DIANNA", "PAULETTE", "LORA",
|
||||
"MONA", "DOREEN", "ROSEMARIE", "ANGEL", "DESIREE", "ANTONIA", "HOPE", "GINGER", "JANIS", "BETSY",
|
||||
"CHRISTIE", "FREDA", "MERCEDES", "MEREDITH", "LYNETTE", "TERI", "CRISTINA", "EULA", "LEIGH", "MEGHAN",
|
||||
"SOPHIA", "ELOISE", "ROCHELLE", "GRETCHEN", "CECELIA", "RAQUEL", "HENRIETTA", "ALYSSA", "JANA", "KELLEY",
|
||||
"GWEN", "KERRY", "JENNA", "TRICIA", "LAVERNE", "OLIVE", "ALEXIS", "TASHA", "SILVIA", "ELVIRA",
|
||||
"CASEY", "DELIA", "SOPHIE", "KATE", "PATTI", "LORENA", "KELLIE", "SONJA", "LILA", "LANA",
|
||||
"DARLA", "MAY", "MINDY", "ESSIE", "MANDY", "LORENE", "ELSA", "JOSEFINA", "JEANNIE", "MIRANDA",
|
||||
"DIXIE", "LUCIA", "MARTA", "FAITH", "LELA", "JOHANNA", "SHARI", "CAMILLE", "TAMI", "SHAWNA",
|
||||
"ELISA", "EBONY", "MELBA", "ORA", "NETTIE", "TABITHA", "OLLIE", "JAIME", "WINIFRED", "KRISTIE",
|
||||
"MARINA", "ALISHA", "AIMEE", "RENA", "MYRNA", "MARLA", "TAMMIE", "LATASHA", "BONITA", "PATRICE",
|
||||
"RONDA", "SHERRIE", "ADDIE", "FRANCINE", "DELORIS", "STACIE", "ADRIANA", "CHERI", "SHELBY", "ABIGAIL",
|
||||
"CELESTE", "JEWEL", "CARA", "ADELE", "REBEKAH", "LUCINDA", "DORTHY", "CHRIS", "EFFIE", "TRINA",
|
||||
"REBA", "SHAWN", "SALLIE", "AURORA", "LENORA", "ETTA", "LOTTIE", "KERRI", "TRISHA", "NIKKI",
|
||||
"ESTELLA", "FRANCISCA", "JOSIE", "TRACIE", "MARISSA", "KARIN", "BRITTNEY", "JANELLE", "LOURDES", "LAUREL",
|
||||
"HELENE", "FERN", "ELVA", "CORINNE", "KELSEY", "INA", "BETTIE", "ELISABETH", "AIDA", "CAITLIN",
|
||||
"INGRID", "IVA", "EUGENIA", "CHRISTA", "GOLDIE", "CASSIE", "MAUDE", "JENIFER", "THERESE", "FRANKIE",
|
||||
"DENA", "LORNA", "JANETTE", "LATONYA", "CANDY", "MORGAN", "CONSUELO", "TAMIKA", "ROSETTA", "DEBORA",
|
||||
"CHERIE", "POLLY", "DINA", "JEWELL", "FAY", "JILLIAN", "DOROTHEA", "NELL", "TRUDY", "ESPERANZA",
|
||||
"PATRICA", "KIMBERLEY", "SHANNA", "HELENA", "CAROLINA", "CLEO", "STEFANIE", "ROSARIO", "OLA", "JANINE",
|
||||
"MOLLIE", "LUPE", "ALISA", "LOU", "MARIBEL", "SUSANNE", "BETTE", "SUSANA", "ELISE", "CECILE",
|
||||
"ISABELLE", "LESLEY", "JOCELYN", "PAIGE", "JONI", "RACHELLE", "LEOLA", "DAPHNE", "ALTA", "ESTER",
|
||||
"PETRA", "GRACIELA", "IMOGENE", "JOLENE", "KEISHA", "LACEY", "GLENNA", "GABRIELA", "KERI", "URSULA",
|
||||
"LIZZIE", "KIRSTEN", "SHANA", "ADELINE", "MAYRA", "JAYNE", "JACLYN", "GRACIE", "SONDRA", "CARMELA",
|
||||
"MARISA", "ROSALIND", "CHARITY", "TONIA", "BEATRIZ", "MARISOL", "CLARICE", "JEANINE", "SHEENA", "ANGELINE",
|
||||
"FRIEDA", "LILY", "ROBBIE", "SHAUNA", "MILLIE", "CLAUDETTE", "CATHLEEN", "ANGELIA", "GABRIELLE", "AUTUMN",
|
||||
"KATHARINE", "SUMMER", "JODIE", "STACI", "LEA", "CHRISTI", "JIMMIE", "JUSTINE", "ELMA", "LUELLA",
|
||||
"MARGRET", "DOMINIQUE", "SOCORRO", "RENE", "MARTINA", "MARGO", "MAVIS", "CALLIE", "BOBBI", "MARITZA",
|
||||
"LUCILE", "LEANNE", "JEANNINE", "DEANA", "AILEEN", "LORIE", "LADONNA", "WILLA", "MANUELA", "GALE",
|
||||
"SELMA", "DOLLY", "SYBIL", "ABBY", "LARA", "DALE", "IVY", "DEE", "WINNIE", "MARCY",
|
||||
"LUISA", "JERI", "MAGDALENA", "OFELIA", "MEAGAN", "AUDRA", "MATILDA", "LEILA", "CORNELIA", "BIANCA",
|
||||
"SIMONE", "BETTYE", "RANDI", "VIRGIE", "LATISHA", "BARBRA", "GEORGINA", "ELIZA", "LEANN", "BRIDGETTE",
|
||||
"RHODA", "HALEY", "ADELA", "NOLA", "BERNADINE", "FLOSSIE", "ILA", "GRETA", "RUTHIE", "NELDA",
|
||||
"MINERVA", "LILLY", "TERRIE", "LETHA", "HILARY", "ESTELA", "VALARIE", "BRIANNA", "ROSALYN", "EARLINE",
|
||||
"CATALINA", "AVA", "MIA", "CLARISSA", "LIDIA", "CORRINE", "ALEXANDRIA", "CONCEPCION", "TIA", "SHARRON",
|
||||
"RAE", "DONA", "ERICKA", "JAMI", "ELNORA", "CHANDRA", "LENORE", "NEVA", "MARYLOU", "MELISA",
|
||||
"TABATHA", "SERENA", "AVIS", "ALLIE", "SOFIA", "JEANIE", "ODESSA", "NANNIE", "HARRIETT", "LORAINE",
|
||||
"PENELOPE", "MILAGROS", "EMILIA", "BENITA", "ALLYSON", "ASHLEE", "TANIA", "TOMMIE", "ESMERALDA", "KARINA",
|
||||
"EVE", "PEARLIE", "ZELMA", "MALINDA", "NOREEN", "TAMEKA", "SAUNDRA", "HILLARY", "AMIE", "ALTHEA",
|
||||
"ROSALINDA", "JORDAN", "LILIA", "ALANA", "GAY", "CLARE", "ALEJANDRA", "ELINOR", "MICHAEL", "LORRIE",
|
||||
"JERRI", "DARCY", "EARNESTINE", "CARMELLA", "TAYLOR", "NOEMI", "MARCIE", "LIZA", "ANNABELLE", "LOUISA",
|
||||
"EARLENE", "MALLORY", "CARLENE", "NITA", "SELENA", "TANISHA", "KATY", "JULIANNE", "JOHN", "LAKISHA",
|
||||
"EDWINA", "MARICELA", "MARGERY", "KENYA", "DOLLIE", "ROXIE", "ROSLYN", "KATHRINE", "NANETTE", "CHARMAINE",
|
||||
"LAVONNE", "ILENE", "KRIS", "TAMMI", "SUZETTE", "CORINE", "KAYE", "JERRY", "MERLE", "CHRYSTAL",
|
||||
"LINA", "DEANNE", "LILIAN", "JULIANA", "ALINE", "LUANN", "KASEY", "MARYANNE", "EVANGELINE", "COLETTE",
|
||||
"MELVA", "LAWANDA", "YESENIA", "NADIA", "MADGE", "KATHIE", "EDDIE", "OPHELIA", "VALERIA", "NONA",
|
||||
"MITZI", "MARI", "GEORGETTE", "CLAUDINE", "FRAN", "ALISSA", "ROSEANN", "LAKEISHA", "SUSANNA", "REVA",
|
||||
"DEIDRE", "CHASITY", "SHEREE", "CARLY", "JAMES", "ELVIA", "ALYCE", "DEIRDRE", "GENA", "BRIANA",
|
||||
"ARACELI", "KATELYN", "ROSANNE", "WENDI", "TESSA", "BERTA", "MARVA", "IMELDA", "MARIETTA", "MARCI",
|
||||
"LEONOR", "ARLINE", "SASHA", "MADELYN", "JANNA", "JULIETTE", "DEENA", "AURELIA", "JOSEFA", "AUGUSTA",
|
||||
"LILIANA", "YOUNG", "CHRISTIAN", "LESSIE", "AMALIA", "SAVANNAH", "ANASTASIA", "VILMA", "NATALIA", "ROSELLA",
|
||||
"LYNNETTE", "CORINA", "ALFREDA", "LEANNA", "CAREY", "AMPARO", "COLEEN", "TAMRA", "AISHA", "WILDA",
|
||||
"KARYN", "CHERRY", "QUEEN", "MAURA", "MAI", "EVANGELINA", "ROSANNA", "HALLIE", "ERNA", "ENID",
|
||||
"MARIANA", "LACY", "JULIET", "JACKLYN", "FREIDA", "MADELEINE", "MARA", "HESTER", "CATHRYN", "LELIA",
|
||||
"CASANDRA", "BRIDGETT", "ANGELITA", "JANNIE", "DIONNE", "ANNMARIE", "KATINA", "BERYL", "PHOEBE", "MILLICENT",
|
||||
"KATHERYN", "DIANN", "CARISSA", "MARYELLEN", "LIZ", "LAURI", "HELGA", "GILDA", "ADRIAN", "RHEA",
|
||||
"MARQUITA", "HOLLIE", "TISHA", "TAMERA", "ANGELIQUE", "FRANCESCA", "BRITNEY", "KAITLIN", "LOLITA", "FLORINE",
|
||||
"ROWENA", "REYNA", "TWILA", "FANNY", "JANELL", "INES", "CONCETTA", "BERTIE", "ALBA", "BRIGITTE",
|
||||
"ALYSON", "VONDA", "PANSY", "ELBA", "NOELLE", "LETITIA", "KITTY", "DEANN", "BRANDIE", "LOUELLA",
|
||||
"LETA", "FELECIA", "SHARLENE", "LESA", "BEVERLEY", "ROBERT", "ISABELLA", "HERMINIA", "TERRA", "CELINA",
|
||||
"TORI", "OCTAVIA", "JADE", "DENICE", "GERMAINE", "SIERRA", "MICHELL", "CORTNEY", "NELLY", "DORETHA",
|
||||
"SYDNEY", "DEIDRA", "MONIKA", "LASHONDA", "JUDI", "CHELSEY", "ANTIONETTE", "MARGOT", "BOBBY", "ADELAIDE",
|
||||
"NAN", "LEEANN", "ELISHA", "DESSIE", "LIBBY", "KATHI", "GAYLA", "LATANYA", "MINA", "MELLISA",
|
||||
"KIMBERLEE", "JASMIN", "RENAE", "ZELDA", "ELDA", "MA", "JUSTINA", "GUSSIE", "EMILIE", "CAMILLA",
|
||||
"ABBIE", "ROCIO", "KAITLYN", "JESSE", "EDYTHE", "ASHLEIGH", "SELINA", "LAKESHA", "GERI", "ALLENE",
|
||||
"PAMALA", "MICHAELA", "DAYNA", "CARYN", "ROSALIA", "SUN", "JACQULINE", "REBECA", "MARYBETH", "KRYSTLE",
|
||||
"IOLA", "DOTTIE", "BENNIE", "BELLE", "AUBREY", "GRISELDA", "ERNESTINA", "ELIDA", "ADRIANNE", "DEMETRIA",
|
||||
"DELMA", "CHONG", "JAQUELINE", "DESTINY", "ARLEEN", "VIRGINA", "RETHA", "FATIMA", "TILLIE", "ELEANORE",
|
||||
"CARI", "TREVA", "BIRDIE", "WILHELMINA", "ROSALEE", "MAURINE", "LATRICE", "YONG", "JENA", "TARYN",
|
||||
"ELIA", "DEBBY", "MAUDIE", "JEANNA", "DELILAH", "CATRINA", "SHONDA", "HORTENCIA", "THEODORA", "TERESITA",
|
||||
"ROBBIN", "DANETTE", "MARYJANE", "FREDDIE", "DELPHINE", "BRIANNE", "NILDA", "DANNA", "CINDI", "BESS",
|
||||
"IONA", "HANNA", "ARIEL", "WINONA", "VIDA", "ROSITA", "MARIANNA", "WILLIAM", "RACHEAL", "GUILLERMINA",
|
||||
"ELOISA", "CELESTINE", "CAREN", "MALISSA", "LONA", "CHANTEL", "SHELLIE", "MARISELA", "LEORA", "AGATHA",
|
||||
"SOLEDAD", "MIGDALIA", "IVETTE", "CHRISTEN", "ATHENA", "JANEL", "CHLOE", "VEDA", "PATTIE", "TESSIE",
|
||||
"TERA", "MARILYNN", "LUCRETIA", "KARRIE", "DINAH", "DANIELA", "ALECIA", "ADELINA", "VERNICE", "SHIELA",
|
||||
"PORTIA", "MERRY", "LASHAWN", "DEVON", "DARA", "TAWANA", "OMA", "VERDA", "CHRISTIN", "ALENE",
|
||||
"ZELLA", "SANDI", "RAFAELA", "MAYA", "KIRA", "CANDIDA", "ALVINA", "SUZAN", "SHAYLA", "LYN",
|
||||
"LETTIE", "ALVA", "SAMATHA", "ORALIA", "MATILDE", "MADONNA", "LARISSA", "VESTA", "RENITA", "INDIA",
|
||||
"DELOIS", "SHANDA", "PHILLIS", "LORRI", "ERLINDA", "CRUZ", "CATHRINE", "BARB", "ZOE", "ISABELL",
|
||||
"IONE", "GISELA", "CHARLIE", "VALENCIA", "ROXANNA", "MAYME", "KISHA", "ELLIE", "MELLISSA", "DORRIS",
|
||||
"DALIA", "BELLA", "ANNETTA", "ZOILA", "RETA", "REINA", "LAURETTA", "KYLIE", "CHRISTAL", "PILAR",
|
||||
"CHARLA", "ELISSA", "TIFFANI", "TANA", "PAULINA", "LEOTA", "BREANNA", "JAYME", "CARMEL", "VERNELL",
|
||||
"TOMASA", "MANDI", "DOMINGA", "SANTA", "MELODIE", "LURA", "ALEXA", "TAMELA", "RYAN", "MIRNA",
|
||||
"KERRIE", "VENUS", "NOEL", "FELICITA", "CRISTY", "CARMELITA", "BERNIECE", "ANNEMARIE", "TIARA", "ROSEANNE",
|
||||
"MISSY", "CORI", "ROXANA", "PRICILLA", "KRISTAL", "JUNG", "ELYSE", "HAYDEE", "ALETHA", "BETTINA",
|
||||
"MARGE", "GILLIAN", "FILOMENA", "CHARLES", "ZENAIDA", "HARRIETTE", "CARIDAD", "VADA", "UNA", "ARETHA",
|
||||
"PEARLINE", "MARJORY", "MARCELA", "FLOR", "EVETTE", "ELOUISE", "ALINA", "TRINIDAD", "DAVID", "DAMARIS",
|
||||
"CATHARINE", "CARROLL", "BELVA", "NAKIA", "MARLENA", "LUANNE", "LORINE", "KARON", "DORENE", "DANITA",
|
||||
"BRENNA", "TATIANA", "SAMMIE", "LOUANN", "LOREN", "JULIANNA", "ANDRIA", "PHILOMENA", "LUCILA", "LEONORA",
|
||||
"DOVIE", "ROMONA", "MIMI", "JACQUELIN", "GAYE", "TONJA", "MISTI", "JOE", "GENE", "CHASTITY",
|
||||
"STACIA", "ROXANN", "MICAELA", "NIKITA", "MEI", "VELDA", "MARLYS", "JOHNNA", "AURA", "LAVERN",
|
||||
"IVONNE", "HAYLEY", "NICKI", "MAJORIE", "HERLINDA", "GEORGE", "ALPHA", "YADIRA", "PERLA", "GREGORIA",
|
||||
"DANIEL", "ANTONETTE", "SHELLI", "MOZELLE", "MARIAH", "JOELLE", "CORDELIA", "JOSETTE", "CHIQUITA", "TRISTA",
|
||||
"LOUIS", "LAQUITA", "GEORGIANA", "CANDI", "SHANON", "LONNIE", "HILDEGARD", "CECIL", "VALENTINA", "STEPHANY",
|
||||
"MAGDA", "KAROL", "GERRY", "GABRIELLA", "TIANA", "ROMA", "RICHELLE", "RAY", "PRINCESS", "OLETA",
|
||||
"JACQUE", "IDELLA", "ALAINA", "SUZANNA", "JOVITA", "BLAIR", "TOSHA", "RAVEN", "NEREIDA", "MARLYN",
|
||||
"KYLA", "JOSEPH", "DELFINA", "TENA", "STEPHENIE", "SABINA", "NATHALIE", "MARCELLE", "GERTIE", "DARLEEN",
|
||||
"THEA", "SHARONDA", "SHANTEL", "BELEN", "VENESSA", "ROSALINA", "ONA", "GENOVEVA", "COREY", "CLEMENTINE",
|
||||
"ROSALBA", "RENATE", "RENATA", "MI", "IVORY", "GEORGIANNA", "FLOY", "DORCAS", "ARIANA", "TYRA",
|
||||
"THEDA", "MARIAM", "JULI", "JESICA", "DONNIE", "VIKKI", "VERLA", "ROSELYN", "MELVINA", "JANNETTE",
|
||||
"GINNY", "DEBRAH", "CORRIE", "ASIA", "VIOLETA", "MYRTIS", "LATRICIA", "COLLETTE", "CHARLEEN", "ANISSA",
|
||||
"VIVIANA", "TWYLA", "PRECIOUS", "NEDRA", "LATONIA", "LAN", "HELLEN", "FABIOLA", "ANNAMARIE", "ADELL",
|
||||
"SHARYN", "CHANTAL", "NIKI", "MAUD", "LIZETTE", "LINDY", "KIA", "KESHA", "JEANA", "DANELLE",
|
||||
"CHARLINE", "CHANEL", "CARROL", "VALORIE", "LIA", "DORTHA", "CRISTAL", "SUNNY", "LEONE", "LEILANI",
|
||||
"GERRI", "DEBI", "ANDRA", "KESHIA", "IMA", "EULALIA", "EASTER", "DULCE", "NATIVIDAD", "LINNIE",
|
||||
"KAMI", "GEORGIE", "CATINA", "BROOK", "ALDA", "WINNIFRED", "SHARLA", "RUTHANN", "MEAGHAN", "MAGDALENE",
|
||||
"LISSETTE", "ADELAIDA", "VENITA", "TRENA", "SHIRLENE", "SHAMEKA", "ELIZEBETH", "DIAN", "SHANTA", "MICKEY",
|
||||
"LATOSHA", "CARLOTTA", "WINDY", "SOON", "ROSINA", "MARIANN", "LEISA", "JONNIE", "DAWNA", "CATHIE",
|
||||
"BILLY", "ASTRID", "SIDNEY", "LAUREEN", "JANEEN", "HOLLI", "FAWN", "VICKEY", "TERESSA", "SHANTE",
|
||||
"RUBYE", "MARCELINA", "CHANDA", "CARY", "TERESE", "SCARLETT", "MARTY", "MARNIE", "LULU", "LISETTE",
|
||||
"JENIFFER", "ELENOR", "DORINDA", "DONITA", "CARMAN", "BERNITA", "ALTAGRACIA", "ALETA", "ADRIANNA", "ZORAIDA",
|
||||
"RONNIE", "NICOLA", "LYNDSEY", "KENDALL", "JANINA", "CHRISSY", "AMI", "STARLA", "PHYLIS", "PHUONG",
|
||||
"KYRA", "CHARISSE", "BLANCH", "SANJUANITA", "RONA", "NANCI", "MARILEE", "MARANDA", "CORY", "BRIGETTE",
|
||||
"SANJUANA", "MARITA", "KASSANDRA", "JOYCELYN", "IRA", "FELIPA", "CHELSIE", "BONNY", "MIREYA", "LORENZA",
|
||||
"KYONG", "ILEANA", "CANDELARIA", "TONY", "TOBY", "SHERIE", "OK", "MARK", "LUCIE", "LEATRICE",
|
||||
"LAKESHIA", "GERDA", "EDIE", "BAMBI", "MARYLIN", "LAVON", "HORTENSE", "GARNET", "EVIE", "TRESSA",
|
||||
"SHAYNA", "LAVINA", "KYUNG", "JEANETTA", "SHERRILL", "SHARA", "PHYLISS", "MITTIE", "ANABEL", "ALESIA",
|
||||
"THUY", "TAWANDA", "RICHARD", "JOANIE", "TIFFANIE", "LASHANDA", "KARISSA", "ENRIQUETA", "DARIA", "DANIELLA",
|
||||
"CORINNA", "ALANNA", "ABBEY", "ROXANE", "ROSEANNA", "MAGNOLIA", "LIDA", "KYLE", "JOELLEN", "ERA",
|
||||
"CORAL", "CARLEEN", "TRESA", "PEGGIE", "NOVELLA", "NILA", "MAYBELLE", "JENELLE", "CARINA", "NOVA",
|
||||
"MELINA", "MARQUERITE", "MARGARETTE", "JOSEPHINA", "EVONNE", "DEVIN", "CINTHIA", "ALBINA", "TOYA", "TAWNYA",
|
||||
"SHERITA", "SANTOS", "MYRIAM", "LIZABETH", "LISE", "KEELY", "JENNI", "GISELLE", "CHERYLE", "ARDITH",
|
||||
"ARDIS", "ALESHA", "ADRIANE", "SHAINA", "LINNEA", "KAROLYN", "HONG", "FLORIDA", "FELISHA", "DORI",
|
||||
"DARCI", "ARTIE", "ARMIDA", "ZOLA", "XIOMARA", "VERGIE", "SHAMIKA", "NENA", "NANNETTE", "MAXIE",
|
||||
"LOVIE", "JEANE", "JAIMIE", "INGE", "FARRAH", "ELAINA", "CAITLYN", "STARR", "FELICITAS", "CHERLY",
|
||||
"CARYL", "YOLONDA", "YASMIN", "TEENA", "PRUDENCE", "PENNIE", "NYDIA", "MACKENZIE", "ORPHA", "MARVEL",
|
||||
"LIZBETH", "LAURETTE", "JERRIE", "HERMELINDA", "CAROLEE", "TIERRA", "MIRIAN", "META", "MELONY", "KORI",
|
||||
"JENNETTE", "JAMILA", "ENA", "ANH", "YOSHIKO", "SUSANNAH", "SALINA", "RHIANNON", "JOLEEN", "CRISTINE",
|
||||
"ASHTON", "ARACELY", "TOMEKA", "SHALONDA", "MARTI", "LACIE", "KALA", "JADA", "ILSE", "HAILEY",
|
||||
"BRITTANI", "ZONA", "SYBLE", "SHERRYL", "RANDY", "NIDIA", "MARLO", "KANDICE", "KANDI", "DEB",
|
||||
"DEAN", "AMERICA", "ALYCIA", "TOMMY", "RONNA", "NORENE", "MERCY", "JOSE", "INGEBORG", "GIOVANNA",
|
||||
"GEMMA", "CHRISTEL", "AUDRY", "ZORA", "VITA", "VAN", "TRISH", "STEPHAINE", "SHIRLEE", "SHANIKA",
|
||||
"MELONIE", "MAZIE", "JAZMIN", "INGA", "HOA", "HETTIE", "GERALYN", "FONDA", "ESTRELLA", "ADELLA",
|
||||
"SU", "SARITA", "RINA", "MILISSA", "MARIBETH", "GOLDA", "EVON", "ETHELYN", "ENEDINA", "CHERISE",
|
||||
"CHANA", "VELVA", "TAWANNA", "SADE", "MIRTA", "LI", "KARIE", "JACINTA", "ELNA", "DAVINA",
|
||||
"CIERRA", "ASHLIE", "ALBERTHA", "TANESHA", "STEPHANI", "NELLE", "MINDI", "LU", "LORINDA", "LARUE",
|
||||
"FLORENE", "DEMETRA", "DEDRA", "CIARA", "CHANTELLE", "ASHLY", "SUZY", "ROSALVA", "NOELIA", "LYDA",
|
||||
"LEATHA", "KRYSTYNA", "KRISTAN", "KARRI", "DARLINE", "DARCIE", "CINDA", "CHEYENNE", "CHERRIE", "AWILDA",
|
||||
"ALMEDA", "ROLANDA", "LANETTE", "JERILYN", "GISELE", "EVALYN", "CYNDI", "CLETA", "CARIN", "ZINA",
|
||||
"ZENA", "VELIA", "TANIKA", "PAUL", "CHARISSA", "THOMAS", "TALIA", "MARGARETE", "LAVONDA", "KAYLEE",
|
||||
"KATHLENE", "JONNA", "IRENA", "ILONA", "IDALIA", "CANDIS", "CANDANCE", "BRANDEE", "ANITRA", "ALIDA",
|
||||
"SIGRID", "NICOLETTE", "MARYJO", "LINETTE", "HEDWIG", "CHRISTIANA", "CASSIDY", "ALEXIA", "TRESSIE", "MODESTA",
|
||||
"LUPITA", "LITA", "GLADIS", "EVELIA", "DAVIDA", "CHERRI", "CECILY", "ASHELY", "ANNABEL", "AGUSTINA",
|
||||
"WANITA", "SHIRLY", "ROSAURA", "HULDA", "EUN", "BAILEY", "YETTA", "VERONA", "THOMASINA", "SIBYL",
|
||||
"SHANNAN", "MECHELLE", "LUE", "LEANDRA", "LANI", "KYLEE", "KANDY", "JOLYNN", "FERNE", "EBONI",
|
||||
"CORENE", "ALYSIA", "ZULA", "NADA", "MOIRA", "LYNDSAY", "LORRETTA", "JUAN", "JAMMIE", "HORTENSIA",
|
||||
"GAYNELL", "CAMERON", "ADRIA", "VINA", "VICENTA", "TANGELA", "STEPHINE", "NORINE", "NELLA", "LIANA",
|
||||
"LESLEE", "KIMBERELY", "ILIANA", "GLORY", "FELICA", "EMOGENE", "ELFRIEDE", "EDEN", "EARTHA", "CARMA",
|
||||
"BEA", "OCIE", "MARRY", "LENNIE", "KIARA", "JACALYN", "CARLOTA", "ARIELLE", "YU", "STAR",
|
||||
"OTILIA", "KIRSTIN", "KACEY", "JOHNETTA", "JOEY", "JOETTA", "JERALDINE", "JAUNITA", "ELANA", "DORTHEA",
|
||||
"CAMI", "AMADA", "ADELIA", "VERNITA", "TAMAR", "SIOBHAN", "RENEA", "RASHIDA", "OUIDA", "ODELL",
|
||||
"NILSA", "MERYL", "KRISTYN", "JULIETA", "DANICA", "BREANNE", "AUREA", "ANGLEA", "SHERRON", "ODETTE",
|
||||
"MALIA", "LORELEI", "LIN", "LEESA", "KENNA", "KATHLYN", "FIONA", "CHARLETTE", "SUZIE", "SHANTELL",
|
||||
"SABRA", "RACQUEL", "MYONG", "MIRA", "MARTINE", "LUCIENNE", "LAVADA", "JULIANN", "JOHNIE", "ELVERA",
|
||||
"DELPHIA", "CLAIR", "CHRISTIANE", "CHAROLETTE", "CARRI", "AUGUSTINE", "ASHA", "ANGELLA", "PAOLA", "NINFA",
|
||||
"LEDA", "LAI", "EDA", "SUNSHINE", "STEFANI", "SHANELL", "PALMA", "MACHELLE", "LISSA", "KECIA",
|
||||
"KATHRYNE", "KARLENE", "JULISSA", "JETTIE", "JENNIFFER", "HUI", "CORRINA", "CHRISTOPHER", "CAROLANN", "ALENA",
|
||||
"TESS", "ROSARIA", "MYRTICE", "MARYLEE", "LIANE", "KENYATTA", "JUDIE", "JANEY", "IN", "ELMIRA",
|
||||
"ELDORA", "DENNA", "CRISTI", "CATHI", "ZAIDA", "VONNIE", "VIVA", "VERNIE", "ROSALINE", "MARIELA",
|
||||
"LUCIANA", "LESLI", "KARAN", "FELICE", "DENEEN", "ADINA", "WYNONA", "TARSHA", "SHERON", "SHASTA",
|
||||
"SHANITA", "SHANI", "SHANDRA", "RANDA", "PINKIE", "PARIS", "NELIDA", "MARILOU", "LYLA", "LAURENE",
|
||||
"LACI", "JOI", "JANENE", "DOROTHA", "DANIELE", "DANI", "CAROLYNN", "CARLYN", "BERENICE", "AYESHA",
|
||||
"ANNELIESE", "ALETHEA", "THERSA", "TAMIKO", "RUFINA", "OLIVA", "MOZELL", "MARYLYN", "MADISON", "KRISTIAN",
|
||||
"KATHYRN", "KASANDRA", "KANDACE", "JANAE", "GABRIEL", "DOMENICA", "DEBBRA", "DANNIELLE", "CHUN", "BUFFY",
|
||||
"BARBIE", "ARCELIA", "AJA", "ZENOBIA", "SHAREN", "SHAREE", "PATRICK", "PAGE", "MY", "LAVINIA",
|
||||
"KUM", "KACIE", "JACKELINE", "HUONG", "FELISA", "EMELIA", "ELEANORA", "CYTHIA", "CRISTIN", "CLYDE",
|
||||
"CLARIBEL", "CARON", "ANASTACIA", "ZULMA", "ZANDRA", "YOKO", "TENISHA", "SUSANN", "SHERILYN", "SHAY",
|
||||
"SHAWANDA", "SABINE", "ROMANA", "MATHILDA", "LINSEY", "KEIKO", "JOANA", "ISELA", "GRETTA", "GEORGETTA",
|
||||
"EUGENIE", "DUSTY", "DESIRAE", "DELORA", "CORAZON", "ANTONINA", "ANIKA", "WILLENE", "TRACEE", "TAMATHA",
|
||||
"REGAN", "NICHELLE", "MICKIE", "MAEGAN", "LUANA", "LANITA", "KELSIE", "EDELMIRA", "BREE", "AFTON",
|
||||
"TEODORA", "TAMIE", "SHENA", "MEG", "LINH", "KELI", "KACI", "DANYELLE", "BRITT", "ARLETTE",
|
||||
"ALBERTINE", "ADELLE", "TIFFINY", "STORMY", "SIMONA", "NUMBERS", "NICOLASA", "NICHOL", "NIA", "NAKISHA",
|
||||
"MEE", "MAIRA", "LOREEN", "KIZZY", "JOHNNY", "JAY", "FALLON", "CHRISTENE", "BOBBYE", "ANTHONY",
|
||||
"YING", "VINCENZA", "TANJA", "RUBIE", "RONI", "QUEENIE", "MARGARETT", "KIMBERLI", "IRMGARD", "IDELL",
|
||||
"HILMA", "EVELINA", "ESTA", "EMILEE", "DENNISE", "DANIA", "CARL", "CARIE", "ANTONIO", "WAI",
|
||||
"SANG", "RISA", "RIKKI", "PARTICIA", "MUI", "MASAKO", "MARIO", "LUVENIA", "LOREE", "LONI",
|
||||
"LIEN", "KEVIN", "GIGI", "FLORENCIA", "DORIAN", "DENITA", "DALLAS", "CHI", "BILLYE", "ALEXANDER",
|
||||
"TOMIKA", "SHARITA", "RANA", "NIKOLE", "NEOMA", "MARGARITE", "MADALYN", "LUCINA", "LAILA", "KALI",
|
||||
"JENETTE", "GABRIELE", "EVELYNE", "ELENORA", "CLEMENTINA", "ALEJANDRINA", "ZULEMA", "VIOLETTE", "VANNESSA", "THRESA",
|
||||
"RETTA", "PIA", "PATIENCE", "NOELLA", "NICKIE", "JONELL", "DELTA", "CHUNG", "CHAYA", "CAMELIA",
|
||||
"BETHEL", "ANYA", "ANDREW", "THANH", "SUZANN", "SPRING", "SHU", "MILA", "LILLA", "LAVERNA",
|
||||
"KEESHA", "KATTIE", "GIA", "GEORGENE", "EVELINE", "ESTELL", "ELIZBETH", "VIVIENNE", "VALLIE", "TRUDIE",
|
||||
"STEPHANE", "MICHEL", "MAGALY", "MADIE", "KENYETTA", "KARREN", "JANETTA", "HERMINE", "HARMONY", "DRUCILLA",
|
||||
"DEBBI", "CELESTINA", "CANDIE", "BRITNI", "BECKIE", "AMINA", "ZITA", "YUN", "YOLANDE", "VIVIEN",
|
||||
"VERNETTA", "TRUDI", "SOMMER", "PEARLE", "PATRINA", "OSSIE", "NICOLLE", "LOYCE", "LETTY", "LARISA",
|
||||
"KATHARINA", "JOSELYN", "JONELLE", "JENELL", "IESHA", "HEIDE", "FLORINDA", "FLORENTINA", "FLO", "ELODIA",
|
||||
"DORINE", "BRUNILDA", "BRIGID", "ASHLI", "ARDELLA", "TWANA", "THU", "TARAH", "SUNG", "SHEA",
|
||||
"SHAVON", "SHANE", "SERINA", "RAYNA", "RAMONITA", "NGA", "MARGURITE", "LUCRECIA", "KOURTNEY", "KATI",
|
||||
"JESUS", "JESENIA", "DIAMOND", "CRISTA", "AYANA", "ALICA", "ALIA", "VINNIE", "SUELLEN", "ROMELIA",
|
||||
"RACHELL", "PIPER", "OLYMPIA", "MICHIKO", "KATHALEEN", "JOLIE", "JESSI", "JANESSA", "HANA", "HA",
|
||||
"ELEASE", "CARLETTA", "BRITANY", "SHONA", "SALOME", "ROSAMOND", "REGENA", "RAINA", "NGOC", "NELIA",
|
||||
"LOUVENIA", "LESIA", "LATRINA", "LATICIA", "LARHONDA", "JINA", "JACKI", "HOLLIS", "HOLLEY", "EMMY",
|
||||
"DEEANN", "CORETTA", "ARNETTA", "VELVET", "THALIA", "SHANICE", "NETA", "MIKKI", "MICKI", "LONNA",
|
||||
"LEANA", "LASHUNDA", "KILEY", "JOYE", "JACQULYN", "IGNACIA", "HYUN", "HIROKO", "HENRY", "HENRIETTE",
|
||||
"ELAYNE", "DELINDA", "DARNELL", "DAHLIA", "COREEN", "CONSUELA", "CONCHITA", "CELINE", "BABETTE", "AYANNA",
|
||||
"ANETTE", "ALBERTINA", "SKYE", "SHAWNEE", "SHANEKA", "QUIANA", "PAMELIA", "MIN", "MERRI", "MERLENE",
|
||||
"MARGIT", "KIESHA", "KIERA", "KAYLENE", "JODEE", "JENISE", "ERLENE", "EMMIE", "ELSE", "DARYL",
|
||||
"DALILA", "DAISEY", "CODY", "CASIE", "BELIA", "BABARA", "VERSIE", "VANESA", "SHELBA", "SHAWNDA",
|
||||
"SAM", "NORMAN", "NIKIA", "NAOMA", "MARNA", "MARGERET", "MADALINE", "LAWANA", "KINDRA", "JUTTA",
|
||||
"JAZMINE", "JANETT", "HANNELORE", "GLENDORA", "GERTRUD", "GARNETT", "FREEDA", "FREDERICA", "FLORANCE", "FLAVIA",
|
||||
"DENNIS", "CARLINE", "BEVERLEE", "ANJANETTE", "VALDA", "TRINITY", "TAMALA", "STEVIE", "SHONNA", "SHA",
|
||||
"SARINA", "ONEIDA", "MICAH", "MERILYN", "MARLEEN", "LURLINE", "LENNA", "KATHERIN", "JIN", "JENI",
|
||||
"HAE", "GRACIA", "GLADY", "FARAH", "ERIC", "ENOLA", "EMA", "DOMINQUE", "DEVONA", "DELANA",
|
||||
"CECILA", "CAPRICE", "ALYSHA", "ALI", "ALETHIA", "VENA", "THERESIA", "TAWNY", "SONG", "SHAKIRA",
|
||||
"SAMARA", "SACHIKO", "RACHELE", "PAMELLA", "NICKY", "MARNI", "MARIEL", "MAREN", "MALISA", "LIGIA",
|
||||
"LERA", "LATORIA", "LARAE", "KIMBER", "KATHERN", "KAREY", "JENNEFER", "JANETH", "HALINA", "FREDIA",
|
||||
"DELISA", "DEBROAH", "CIERA", "CHIN", "ANGELIKA", "ANDREE", "ALTHA", "YEN", "VIVAN", "TERRESA",
|
||||
"TANNA", "SUK", "SUDIE", "SOO", "SIGNE", "SALENA", "RONNI", "REBBECCA", "MYRTIE", "MCKENZIE",
|
||||
"MALIKA", "MAIDA", "LOAN", "LEONARDA", "KAYLEIGH", "FRANCE", "ETHYL", "ELLYN", "DAYLE", "CAMMIE",
|
||||
"BRITTNI", "BIRGIT", "AVELINA", "ASUNCION", "ARIANNA", "AKIKO", "VENICE", "TYESHA", "TONIE", "TIESHA",
|
||||
"TAKISHA", "STEFFANIE", "SINDY", "SANTANA", "MEGHANN", "MANDA", "MACIE", "LADY", "KELLYE", "KELLEE",
|
||||
"JOSLYN", "JASON", "INGER", "INDIRA", "GLINDA", "GLENNIS", "FERNANDA", "FAUSTINA", "ENEIDA", "ELICIA",
|
||||
"DOT", "DIGNA", "DELL", "ARLETTA", "ANDRE", "WILLIA", "TAMMARA", "TABETHA", "SHERRELL", "SARI",
|
||||
"REFUGIO", "REBBECA", "PAULETTA", "NIEVES", "NATOSHA", "NAKITA", "MAMMIE", "KENISHA", "KAZUKO", "KASSIE",
|
||||
"GARY", "EARLEAN", "DAPHINE", "CORLISS", "CLOTILDE", "CAROLYNE", "BERNETTA", "AUGUSTINA", "AUDREA", "ANNIS",
|
||||
"ANNABELL", "YAN", "TENNILLE", "TAMICA", "SELENE", "SEAN", "ROSANA", "REGENIA", "QIANA", "MARKITA",
|
||||
"MACY", "LEEANNE", "LAURINE", "KYM", "JESSENIA", "JANITA", "GEORGINE", "GENIE", "EMIKO", "ELVIE",
|
||||
"DEANDRA", "DAGMAR", "CORIE", "COLLEN", "CHERISH", "ROMAINE", "PORSHA", "PEARLENE", "MICHELINE", "MERNA",
|
||||
"MARGORIE", "MARGARETTA", "LORE", "KENNETH", "JENINE", "HERMINA", "FREDERICKA", "ELKE", "DRUSILLA", "DORATHY",
|
||||
"DIONE", "DESIRE", "CELENA", "BRIGIDA", "ANGELES", "ALLEGRA", "THEO", "TAMEKIA", "SYNTHIA", "STEPHEN",
|
||||
"SOOK", "SLYVIA", "ROSANN", "REATHA", "RAYE", "MARQUETTA", "MARGART", "LING", "LAYLA", "KYMBERLY",
|
||||
"KIANA", "KAYLEEN", "KATLYN", "KARMEN", "JOELLA", "IRINA", "EMELDA", "ELENI", "DETRA", "CLEMMIE",
|
||||
"CHERYLL", "CHANTELL", "CATHEY", "ARNITA", "ARLA", "ANGLE", "ANGELIC", "ALYSE", "ZOFIA", "THOMASINE",
|
||||
"TENNIE", "SON", "SHERLY", "SHERLEY", "SHARYL", "REMEDIOS", "PETRINA", "NICKOLE", "MYUNG", "MYRLE",
|
||||
"MOZELLA", "LOUANNE", "LISHA", "LATIA", "LANE", "KRYSTA", "JULIENNE", "JOEL", "JEANENE", "JACQUALINE",
|
||||
"ISAURA", "GWENDA", "EARLEEN", "DONALD", "CLEOPATRA", "CARLIE", "AUDIE", "ANTONIETTA", "ALISE", "ALEX",
|
||||
"VERDELL", "VAL", "TYLER", "TOMOKO", "THAO", "TALISHA", "STEVEN", "SO", "SHEMIKA", "SHAUN",
|
||||
"SCARLET", "SAVANNA", "SANTINA", "ROSIA", "RAEANN", "ODILIA", "NANA", "MINNA", "MAGAN", "LYNELLE",
|
||||
"LE", "KARMA", "JOEANN", "IVANA", "INELL", "ILANA", "HYE", "HONEY", "HEE", "GUDRUN",
|
||||
"FRANK", "DREAMA", "CRISSY", "CHANTE", "CARMELINA", "ARVILLA", "ARTHUR", "ANNAMAE", "ALVERA", "ALEIDA",
|
||||
"AARON", "YEE", "YANIRA", "VANDA", "TIANNA", "TAM", "STEFANIA", "SHIRA", "PERRY", "NICOL",
|
||||
"NANCIE", "MONSERRATE", "MINH", "MELYNDA", "MELANY", "MATTHEW", "LOVELLA", "LAURE", "KIRBY", "KACY",
|
||||
"JACQUELYNN", "HYON", "GERTHA", "FRANCISCO", "ELIANA", "CHRISTENA", "CHRISTEEN", "CHARISE", "CATERINA", "CARLEY",
|
||||
"CANDYCE", "ARLENA", "AMMIE", "YANG", "WILLETTE", "VANITA", "TUYET", "TINY", "SYREETA", "SILVA",
|
||||
"SCOTT", "RONALD", "PENNEY", "NYLA", "MICHAL", "MAURICE", "MARYAM", "MARYA", "MAGEN", "LUDIE",
|
||||
"LOMA", "LIVIA", "LANELL", "KIMBERLIE", "JULEE", "DONETTA", "DIEDRA", "DENISHA", "DEANE", "DAWNE",
|
||||
"CLARINE", "CHERRYL", "BRONWYN", "BRANDON", "ALLA", "VALERY", "TONDA", "SUEANN", "SORAYA", "SHOSHANA",
|
||||
"SHELA", "SHARLEEN", "SHANELLE", "NERISSA", "MICHEAL", "MERIDITH", "MELLIE", "MAYE", "MAPLE", "MAGARET",
|
||||
"LUIS", "LILI", "LEONILA", "LEONIE", "LEEANNA", "LAVONIA", "LAVERA", "KRISTEL", "KATHEY", "KATHE",
|
||||
"JUSTIN", "JULIAN", "JIMMY", "JANN", "ILDA", "HILDRED", "HILDEGARDE", "GENIA", "FUMIKO", "EVELIN",
|
||||
"ERMELINDA", "ELLY", "DUNG", "DOLORIS", "DIONNA", "DANAE", "BERNEICE", "ANNICE", "ALIX", "VERENA",
|
||||
"VERDIE", "TRISTAN", "SHAWNNA", "SHAWANA", "SHAUNNA", "ROZELLA", "RANDEE", "RANAE", "MILAGRO", "LYNELL",
|
||||
"LUISE", "LOUIE", "LOIDA", "LISBETH", "KARLEEN", "JUNITA", "JONA", "ISIS", "HYACINTH", "HEDY",
|
||||
"GWENN", "ETHELENE", "ERLINE", "EDWARD", "DONYA", "DOMONIQUE", "DELICIA", "DANNETTE", "CICELY", "BRANDA",
|
||||
"BLYTHE", "BETHANN", "ASHLYN", "ANNALEE", "ALLINE", "YUKO", "VELLA", "TRANG", "TOWANDA", "TESHA",
|
||||
"SHERLYN", "NARCISA", "MIGUELINA", "MERI", "MAYBELL", "MARLANA", "MARGUERITA", "MADLYN", "LUNA", "LORY",
|
||||
"LORIANN", "LIBERTY", "LEONORE", "LEIGHANN", "LAURICE", "LATESHA", "LARONDA", "KATRICE", "KASIE", "KARL",
|
||||
"KALEY", "JADWIGA", "GLENNIE", "GEARLDINE", "FRANCINA", "EPIFANIA", "DYAN", "DORIE", "DIEDRE", "DENESE",
|
||||
"DEMETRICE", "DELENA", "DARBY", "CRISTIE", "CLEORA", "CATARINA", "CARISA", "BERNIE", "BARBERA", "ALMETA",
|
||||
"TRULA", "TEREASA", "SOLANGE", "SHEILAH", "SHAVONNE", "SANORA", "ROCHELL", "MATHILDE", "MARGARETA", "MAIA",
|
||||
"LYNSEY", "LAWANNA", "LAUNA", "KENA", "KEENA", "KATIA", "JAMEY", "GLYNDA", "GAYLENE", "ELVINA",
|
||||
"ELANOR", "DANUTA", "DANIKA", "CRISTEN", "CORDIE", "COLETTA", "CLARITA", "CARMON", "BRYNN", "AZUCENA",
|
||||
"AUNDREA", "ANGELE", "YI", "WALTER", "VERLIE", "VERLENE", "TAMESHA", "SILVANA", "SEBRINA", "SAMIRA",
|
||||
"REDA", "RAYLENE", "PENNI", "PANDORA", "NORAH", "NOMA", "MIREILLE", "MELISSIA", "MARYALICE", "LARAINE",
|
||||
"KIMBERY", "KARYL", "KARINE", "KAM", "JOLANDA", "JOHANA", "JESUSA", "JALEESA", "JAE", "JACQUELYNE",
|
||||
"IRISH", "ILUMINADA", "HILARIA", "HANH", "GENNIE", "FRANCIE", "FLORETTA", "EXIE", "EDDA", "DREMA",
|
||||
"DELPHA", "BEV", "BARBAR", "ASSUNTA", "ARDELL", "ANNALISA", "ALISIA", "YUKIKO", "YOLANDO", "WONDA",
|
||||
"WEI", "WALTRAUD", "VETA", "TEQUILA", "TEMEKA", "TAMEIKA", "SHIRLEEN", "SHENITA", "PIEDAD", "OZELLA",
|
||||
"MIRTHA", "MARILU", "KIMIKO", "JULIANE", "JENICE", "JEN", "JANAY", "JACQUILINE", "HILDE", "FE",
|
||||
"FAE", "EVAN", "EUGENE", "ELOIS", "ECHO", "DEVORAH", "CHAU", "BRINDA", "BETSEY", "ARMINDA",
|
||||
"ARACELIS", "APRYL", "ANNETT", "ALISHIA", "VEOLA", "USHA", "TOSHIKO", "THEOLA", "TASHIA", "TALITHA",
|
||||
"SHERY", "RUDY", "RENETTA", "REIKO", "RASHEEDA", "OMEGA", "OBDULIA", "MIKA", "MELAINE", "MEGGAN",
|
||||
"MARTIN", "MARLEN", "MARGET", "MARCELINE", "MANA", "MAGDALEN", "LIBRADA", "LEZLIE", "LEXIE", "LATASHIA",
|
||||
"LASANDRA", "KELLE", "ISIDRA", "ISA", "INOCENCIA", "GWYN", "FRANCOISE", "ERMINIA", "ERINN", "DIMPLE",
|
||||
"DEVORA", "CRISELDA", "ARMANDA", "ARIE", "ARIANE", "ANGELO", "ANGELENA", "ALLEN", "ALIZA", "ADRIENE",
|
||||
"ADALINE", "XOCHITL", "TWANNA", "TRAN", "TOMIKO", "TAMISHA", "TAISHA", "SUSY", "SIU", "RUTHA",
|
||||
"ROXY", "RHONA", "RAYMOND", "OTHA", "NORIKO", "NATASHIA", "MERRIE", "MELVIN", "MARINDA", "MARIKO",
|
||||
"MARGERT", "LORIS", "LIZZETTE", "LEISHA", "KAILA", "KA", "JOANNIE", "JERRICA", "JENE", "JANNET",
|
||||
"JANEE", "JACINDA", "HERTA", "ELENORE", "DORETTA", "DELAINE", "DANIELL", "CLAUDIE", "CHINA", "BRITTA",
|
||||
"APOLONIA", "AMBERLY", "ALEASE", "YURI", "YUK", "WEN", "WANETA", "UTE", "TOMI", "SHARRI",
|
||||
"SANDIE", "ROSELLE", "REYNALDA", "RAGUEL", "PHYLICIA", "PATRIA", "OLIMPIA", "ODELIA", "MITZIE", "MITCHELL",
|
||||
"MISS", "MINDA", "MIGNON", "MICA", "MENDY", "MARIVEL", "MAILE", "LYNETTA", "LAVETTE", "LAURYN",
|
||||
"LATRISHA", "LAKIESHA", "KIERSTEN", "KARY", "JOSPHINE", "JOLYN", "JETTA", "JANISE", "JACQUIE", "IVELISSE",
|
||||
"GLYNIS", "GIANNA", "GAYNELLE", "EMERALD", "DEMETRIUS", "DANYELL", "DANILLE", "DACIA", "CORALEE", "CHER",
|
||||
"CEOLA", "BRETT", "BELL", "ARIANNE", "ALESHIA", "YUNG", "WILLIEMAE", "TROY", "TRINH", "THORA",
|
||||
"TAI", "SVETLANA", "SHERIKA", "SHEMEKA", "SHAUNDA", "ROSELINE", "RICKI", "MELDA", "MALLIE", "LAVONNA",
|
||||
"LATINA", "LARRY", "LAQUANDA", "LALA", "LACHELLE", "KLARA", "KANDIS", "JOHNA", "JEANMARIE", "JAYE",
|
||||
"HANG", "GRAYCE", "GERTUDE", "EMERITA", "EBONIE", "CLORINDA", "CHING", "CHERY", "CAROLA", "BREANN",
|
||||
"BLOSSOM", "BERNARDINE", "BECKI", "ARLETHA", "ARGELIA", "ARA", "ALITA", "YULANDA", "YON", "YESSENIA",
|
||||
"TOBI", "TASIA", "SYLVIE", "SHIRL", "SHIRELY", "SHERIDAN", "SHELLA", "SHANTELLE", "SACHA", "ROYCE",
|
||||
"REBECKA", "REAGAN", "PROVIDENCIA", "PAULENE", "MISHA", "MIKI", "MARLINE", "MARICA", "LORITA", "LATOYIA",
|
||||
"LASONYA", "KERSTIN", "KENDA", "KEITHA", "KATHRIN", "JAYMIE", "JACK", "GRICELDA", "GINETTE", "ERYN",
|
||||
"ELINA", "ELFRIEDA", "DANYEL", "CHEREE", "CHANELLE", "BARRIE", "AVERY", "AURORE", "ANNAMARIA", "ALLEEN",
|
||||
"AILENE", "AIDE", "YASMINE", "VASHTI", "VALENTINE", "TREASA", "TORY", "TIFFANEY", "SHERYLL", "SHARIE",
|
||||
"SHANAE", "SAU", "RAISA", "PA", "NEDA", "MITSUKO", "MIRELLA", "MILDA", "MARYANNA", "MARAGRET",
|
||||
"MABELLE", "LUETTA", "LORINA", "LETISHA", "LATARSHA", "LANELLE", "LAJUANA", "KRISSY", "KARLY", "KARENA",
|
||||
"JON", "JESSIKA", "JERICA", "JEANELLE", "JANUARY", "JALISA", "JACELYN", "IZOLA", "IVEY", "GREGORY",
|
||||
"EUNA", "ETHA", "DREW", "DOMITILA", "DOMINICA", "DAINA", "CREOLA", "CARLI", "CAMIE", "BUNNY",
|
||||
"BRITTNY", "ASHANTI", "ANISHA", "ALEEN", "ADAH", "YASUKO", "WINTER", "VIKI", "VALRIE", "TONA",
|
||||
"TINISHA", "THI", "TERISA", "TATUM", "TANEKA", "SIMONNE", "SHALANDA", "SERITA", "RESSIE", "REFUGIA",
|
||||
"PAZ", "OLENE", "NA", "MERRILL", "MARGHERITA", "MANDIE", "MAN", "MAIRE", "LYNDIA", "LUCI",
|
||||
"LORRIANE", "LORETA", "LEONIA", "LAVONA", "LASHAWNDA", "LAKIA", "KYOKO", "KRYSTINA", "KRYSTEN", "KENIA",
|
||||
"KELSI", "JUDE", "JEANICE", "ISOBEL", "GEORGIANN", "GENNY", "FELICIDAD", "EILENE", "DEON", "DELOISE",
|
||||
"DEEDEE", "DANNIE", "CONCEPTION", "CLORA", "CHERILYN", "CHANG", "CALANDRA", "BERRY", "ARMANDINA", "ANISA",
|
||||
"ULA", "TIMOTHY", "TIERA", "THERESSA", "STEPHANIA", "SIMA", "SHYLA", "SHONTA", "SHERA", "SHAQUITA",
|
||||
"SHALA", "SAMMY", "ROSSANA", "NOHEMI", "NERY", "MORIAH", "MELITA", "MELIDA", "MELANI", "MARYLYNN",
|
||||
"MARISHA", "MARIETTE", "MALORIE", "MADELENE", "LUDIVINA", "LORIA", "LORETTE", "LORALEE", "LIANNE", "LEON",
|
||||
"LAVENIA", "LAURINDA", "LASHON", "KIT", "KIMI", "KEILA", "KATELYNN", "KAI", "JONE", "JOANE",
|
||||
"JI", "JAYNA", "JANELLA", "JA", "HUE", "HERTHA", "FRANCENE", "ELINORE", "DESPINA", "DELSIE",
|
||||
"DEEDRA", "CLEMENCIA", "CARRY", "CAROLIN", "CARLOS", "BULAH", "BRITTANIE", "BOK", "BLONDELL", "BIBI",
|
||||
"BEAULAH", "BEATA", "ANNITA", "AGRIPINA", "VIRGEN", "VALENE", "UN", "TWANDA", "TOMMYE", "TOI",
|
||||
"TARRA", "TARI", "TAMMERA", "SHAKIA", "SADYE", "RUTHANNE", "ROCHEL", "RIVKA", "PURA", "NENITA",
|
||||
"NATISHA", "MING", "MERRILEE", "MELODEE", "MARVIS", "LUCILLA", "LEENA", "LAVETA", "LARITA", "LANIE",
|
||||
"KEREN", "ILEEN", "GEORGEANN", "GENNA", "GENESIS", "FRIDA", "EWA", "EUFEMIA", "EMELY", "ELA",
|
||||
"EDYTH", "DEONNA", "DEADRA", "DARLENA", "CHANELL", "CHAN", "CATHERN", "CASSONDRA", "CASSAUNDRA", "BERNARDA",
|
||||
"BERNA", "ARLINDA", "ANAMARIA", "ALBERT", "WESLEY", "VERTIE", "VALERI", "TORRI", "TATYANA", "STASIA",
|
||||
"SHERISE", "SHERILL", "SEASON", "SCOTTIE", "SANDA", "RUTHE", "ROSY", "ROBERTO", "ROBBI", "RANEE",
|
||||
"QUYEN", "PEARLY", "PALMIRA", "ONITA", "NISHA", "NIESHA", "NIDA", "NEVADA", "NAM", "MERLYN",
|
||||
"MAYOLA", "MARYLOUISE", "MARYLAND", "MARX", "MARTH", "MARGENE", "MADELAINE", "LONDA", "LEONTINE", "LEOMA",
|
||||
"LEIA", "LAWRENCE", "LAURALEE", "LANORA", "LAKITA", "KIYOKO", "KETURAH", "KATELIN", "KAREEN", "JONIE",
|
||||
"JOHNETTE", "JENEE", "JEANETT", "IZETTA", "HIEDI", "HEIKE", "HASSIE", "HAROLD", "GIUSEPPINA", "GEORGANN",
|
||||
"FIDELA", "FERNANDE", "ELWANDA", "ELLAMAE", "ELIZ", "DUSTI", "DOTTY", "CYNDY", "CORALIE", "CELESTA",
|
||||
"ARGENTINA", "ALVERTA", "XENIA", "WAVA", "VANETTA", "TORRIE", "TASHINA", "TANDY", "TAMBRA", "TAMA",
|
||||
"STEPANIE", "SHILA", "SHAUNTA", "SHARAN", "SHANIQUA", "SHAE", "SETSUKO", "SERAFINA", "SANDEE", "ROSAMARIA",
|
||||
"PRISCILA", "OLINDA", "NADENE", "MUOI", "MICHELINA", "MERCEDEZ", "MARYROSE", "MARIN", "MARCENE", "MAO",
|
||||
"MAGALI", "MAFALDA", "LOGAN", "LINN", "LANNIE", "KAYCE", "KAROLINE", "KAMILAH", "KAMALA", "JUSTA",
|
||||
"JOLINE", "JENNINE", "JACQUETTA", "IRAIDA", "GERALD", "GEORGEANNA", "FRANCHESCA", "FAIRY", "EMELINE", "ELANE",
|
||||
"EHTEL", "EARLIE", "DULCIE", "DALENE", "CRIS", "CLASSIE", "CHERE", "CHARIS", "CAROYLN", "CARMINA",
|
||||
"CARITA", "BRIAN", "BETHANIE", "AYAKO", "ARICA", "AN", "ALYSA", "ALESSANDRA", "AKILAH", "ADRIEN",
|
||||
"ZETTA", "YOULANDA", "YELENA", "YAHAIRA", "XUAN", "WENDOLYN", "VICTOR", "TIJUANA", "TERRELL", "TERINA",
|
||||
"TERESIA", "SUZI", "SUNDAY", "SHERELL", "SHAVONDA", "SHAUNTE", "SHARDA", "SHAKITA", "SENA", "RYANN",
|
||||
"RUBI", "RIVA", "REGINIA", "REA", "RACHAL", "PARTHENIA", "PAMULA", "MONNIE", "MONET", "MICHAELE",
|
||||
"MELIA", "MARINE", "MALKA", "MAISHA", "LISANDRA", "LEO", "LEKISHA", "LEAN", "LAURENCE", "LAKENDRA",
|
||||
"KRYSTIN", "KORTNEY", "KIZZIE", "KITTIE", "KERA", "KENDAL", "KEMBERLY", "KANISHA", "JULENE", "JULE",
|
||||
"JOSHUA", "JOHANNE", "JEFFREY", "JAMEE", "HAN", "HALLEY", "GIDGET", "GALINA", "FREDRICKA", "FLETA",
|
||||
"FATIMAH", "EUSEBIA", "ELZA", "ELEONORE", "DORTHEY", "DORIA", "DONELLA", "DINORAH", "DELORSE", "CLARETHA",
|
||||
"CHRISTINIA", "CHARLYN", "BONG", "BELKIS", "AZZIE", "ANDERA", "AIKO", "ADENA", "YER", "YAJAIRA",
|
||||
"WAN", "VANIA", "ULRIKE", "TOSHIA", "TIFANY", "STEFANY", "SHIZUE", "SHENIKA", "SHAWANNA", "SHAROLYN",
|
||||
"SHARILYN", "SHAQUANA", "SHANTAY", "SEE", "ROZANNE", "ROSELEE", "RICKIE", "REMONA", "REANNA", "RAELENE",
|
||||
"QUINN", "PHUNG", "PETRONILA", "NATACHA", "NANCEY", "MYRL", "MIYOKO", "MIESHA", "MERIDETH", "MARVELLA",
|
||||
"MARQUITTA", "MARHTA", "MARCHELLE", "LIZETH", "LIBBIE", "LAHOMA", "LADAWN", "KINA", "KATHELEEN", "KATHARYN",
|
||||
"KARISA", "KALEIGH", "JUNIE", "JULIEANN", "JOHNSIE", "JANEAN", "JAIMEE", "JACKQUELINE", "HISAKO", "HERMA",
|
||||
"HELAINE", "GWYNETH", "GLENN", "GITA", "EUSTOLIA", "EMELINA", "ELIN", "EDRIS", "DONNETTE", "DONNETTA",
|
||||
"DIERDRE", "DENAE", "DARCEL", "CLAUDE", "CLARISA", "CINDERELLA", "CHIA", "CHARLESETTA", "CHARITA", "CELSA",
|
||||
"CASSY", "CASSI", "CARLEE", "BRUNA", "BRITTANEY", "BRANDE", "BILLI", "BAO", "ANTONETTA", "ANGLA",
|
||||
"ANGELYN", "ANALISA", "ALANE", "WENONA", "WENDIE", "VERONIQUE", "VANNESA", "TOBIE", "TEMPIE", "SUMIKO",
|
||||
"SULEMA", "SPARKLE", "SOMER", "SHEBA", "SHAYNE", "SHARICE", "SHANEL", "SHALON", "SAGE", "ROY",
|
||||
"ROSIO", "ROSELIA", "RENAY", "REMA", "REENA", "PORSCHE", "PING", "PEG", "OZIE", "ORETHA",
|
||||
"ORALEE", "ODA", "NU", "NGAN", "NAKESHA", "MILLY", "MARYBELLE", "MARLIN", "MARIS", "MARGRETT",
|
||||
"MARAGARET", "MANIE", "LURLENE", "LILLIA", "LIESELOTTE", "LAVELLE", "LASHAUNDA", "LAKEESHA", "KEITH", "KAYCEE",
|
||||
"KALYN", "JOYA", "JOETTE", "JENAE", "JANIECE", "ILLA", "GRISEL", "GLAYDS", "GENEVIE", "GALA",
|
||||
"FREDDA", "FRED", "ELMER", "ELEONOR", "DEBERA", "DEANDREA", "DAN", "CORRINNE", "CORDIA", "CONTESSA",
|
||||
"COLENE", "CLEOTILDE", "CHARLOTT", "CHANTAY", "CECILLE", "BEATRIS", "AZALEE", "ARLEAN", "ARDATH", "ANJELICA",
|
||||
"ANJA", "ALFREDIA", "ALEISHA", "ADAM", "ZADA", "YUONNE", "XIAO", "WILLODEAN", "WHITLEY", "VENNIE",
|
||||
"VANNA", "TYISHA", "TOVA", "TORIE", "TONISHA", "TILDA", "TIEN", "TEMPLE", "SIRENA", "SHERRIL",
|
||||
"SHANTI", "SHAN", "SENAIDA", "SAMELLA", "ROBBYN", "RENDA", "REITA", "PHEBE", "PAULITA", "NOBUKO",
|
||||
"NGUYET", "NEOMI", "MOON", "MIKAELA", "MELANIA", "MAXIMINA", "MARG", "MAISIE", "LYNNA", "LILLI",
|
||||
"LAYNE", "LASHAUN", "LAKENYA", "LAEL", "KIRSTIE", "KATHLINE", "KASHA", "KARLYN", "KARIMA", "JOVAN",
|
||||
"JOSEFINE", "JENNELL", "JACQUI", "JACKELYN", "HYO", "HIEN", "GRAZYNA", "FLORRIE", "FLORIA", "ELEONORA",
|
||||
"DWANA", "DORLA", "DONG", "DELMY", "DEJA", "DEDE", "DANN", "CRYSTA", "CLELIA", "CLARIS",
|
||||
"CLARENCE", "CHIEKO", "CHERLYN", "CHERELLE", "CHARMAIN", "CHARA", "CAMMY", "BEE", "ARNETTE", "ARDELLE",
|
||||
"ANNIKA", "AMIEE", "AMEE", "ALLENA", "YVONE", "YUKI", "YOSHIE", "YEVETTE", "YAEL", "WILLETTA",
|
||||
"VONCILE", "VENETTA", "TULA", "TONETTE", "TIMIKA", "TEMIKA", "TELMA", "TEISHA", "TAREN", "TA",
|
||||
"STACEE", "SHIN", "SHAWNTA", "SATURNINA", "RICARDA", "POK", "PASTY", "ONIE", "NUBIA", "MORA",
|
||||
"MIKE", "MARIELLE", "MARIELLA", "MARIANELA", "MARDELL", "MANY", "LUANNA", "LOISE", "LISABETH", "LINDSY",
|
||||
"LILLIANA", "LILLIAM", "LELAH", "LEIGHA", "LEANORA", "LANG", "KRISTEEN", "KHALILAH", "KEELEY", "KANDRA",
|
||||
"JUNKO", "JOAQUINA", "JERLENE", "JANI", "JAMIKA", "JAME", "HSIU", "HERMILA", "GOLDEN", "GENEVIVE",
|
||||
"EVIA", "EUGENA", "EMMALINE", "ELFREDA", "ELENE", "DONETTE", "DELCIE", "DEEANNA", "DARCEY", "CUC",
|
||||
"CLARINDA", "CIRA", "CHAE", "CELINDA", "CATHERYN", "CATHERIN", "CASIMIRA", "CARMELIA", "CAMELLIA", "BREANA",
|
||||
"BOBETTE", "BERNARDINA", "BEBE", "BASILIA", "ARLYNE", "AMAL", "ALAYNA", "ZONIA", "ZENIA", "YURIKO",
|
||||
"YAEKO", "WYNELL", "WILLOW", "WILLENA", "VERNIA", "TU", "TRAVIS", "TORA", "TERRILYN", "TERICA",
|
||||
"TENESHA", "TAWNA", "TAJUANA", "TAINA", "STEPHNIE", "SONA", "SOL", "SINA", "SHONDRA", "SHIZUKO",
|
||||
"SHERLENE", "SHERICE", "SHARIKA", "ROSSIE", "ROSENA", "RORY", "RIMA", "RIA", "RHEBA", "RENNA",
|
||||
"PETER", "NATALYA", "NANCEE", "MELODI", "MEDA", "MAXIMA", "MATHA", "MARKETTA", "MARICRUZ", "MARCELENE",
|
||||
"MALVINA", "LUBA", "LOUETTA", "LEIDA", "LECIA", "LAURAN", "LASHAWNA", "LAINE", "KHADIJAH", "KATERINE",
|
||||
"KASI", "KALLIE", "JULIETTA", "JESUSITA", "JESTINE", "JESSIA", "JEREMY", "JEFFIE", "JANYCE", "ISADORA",
|
||||
"GEORGIANNE", "FIDELIA", "EVITA", "EURA", "EULAH", "ESTEFANA", "ELSY", "ELIZABET", "ELADIA", "DODIE",
|
||||
"DION", "DIA", "DENISSE", "DELORAS", "DELILA", "DAYSI", "DAKOTA", "CURTIS", "CRYSTLE", "CONCHA",
|
||||
"COLBY", "CLARETTA", "CHU", "CHRISTIA", "CHARLSIE", "CHARLENA", "CARYLON", "BETTYANN", "ASLEY", "ASHLEA",
|
||||
"AMIRA", "AI", "AGUEDA", "AGNUS", "YUETTE", "VINITA", "VICTORINA", "TYNISHA", "TREENA", "TOCCARA",
|
||||
"TISH", "THOMASENA", "TEGAN", "SOILA", "SHILOH", "SHENNA", "SHARMAINE", "SHANTAE", "SHANDI", "SEPTEMBER",
|
||||
"SARAN", "SARAI", "SANA", "SAMUEL", "SALLEY", "ROSETTE", "ROLANDE", "REGINE", "OTELIA", "OSCAR",
|
||||
"OLEVIA", "NICHOLLE", "NECOLE", "NAIDA", "MYRTA", "MYESHA", "MITSUE", "MINTA", "MERTIE", "MARGY",
|
||||
"MAHALIA", "MADALENE", "LOVE", "LOURA", "LOREAN", "LEWIS", "LESHA", "LEONIDA", "LENITA", "LAVONE",
|
||||
"LASHELL", "LASHANDRA", "LAMONICA", "KIMBRA", "KATHERINA", "KARRY", "KANESHA", "JULIO", "JONG", "JENEVA",
|
||||
"JAQUELYN", "HWA", "GILMA", "GHISLAINE", "GERTRUDIS", "FRANSISCA", "FERMINA", "ETTIE", "ETSUKO", "ELLIS",
|
||||
"ELLAN", "ELIDIA", "EDRA", "DORETHEA", "DOREATHA", "DENYSE", "DENNY", "DEETTA", "DAINE", "CYRSTAL",
|
||||
"CORRIN", "CAYLA", "CARLITA", "CAMILA", "BURMA", "BULA", "BUENA", "BLAKE", "BARABARA", "AVRIL",
|
||||
"AUSTIN", "ALAINE", "ZANA", "WILHEMINA", "WANETTA", "VIRGIL", "VI", "VERONIKA", "VERNON", "VERLINE",
|
||||
"VASILIKI", "TONITA", "TISA", "TEOFILA", "TAYNA", "TAUNYA", "TANDRA", "TAKAKO", "SUNNI", "SUANNE",
|
||||
"SIXTA", "SHARELL", "SEEMA", "RUSSELL", "ROSENDA", "ROBENA", "RAYMONDE", "PEI", "PAMILA", "OZELL",
|
||||
"NEIDA", "NEELY", "MISTIE", "MICHA", "MERISSA", "MAURITA", "MARYLN", "MARYETTA", "MARSHALL", "MARCELL",
|
||||
"MALENA", "MAKEDA", "MADDIE", "LOVETTA", "LOURIE", "LORRINE", "LORILEE", "LESTER", "LAURENA", "LASHAY",
|
||||
"LARRAINE", "LAREE", "LACRESHA", "KRISTLE", "KRISHNA", "KEVA", "KEIRA", "KAROLE", "JOIE", "JINNY",
|
||||
"JEANNETTA", "JAMA", "HEIDY", "GILBERTE", "GEMA", "FAVIOLA", "EVELYNN", "ENDA", "ELLI", "ELLENA",
|
||||
"DIVINA", "DAGNY", "COLLENE", "CODI", "CINDIE", "CHASSIDY", "CHASIDY", "CATRICE", "CATHERINA", "CASSEY",
|
||||
"CAROLL", "CARLENA", "CANDRA", "CALISTA", "BRYANNA", "BRITTENY", "BEULA", "BARI", "AUDRIE", "AUDRIA",
|
||||
"ARDELIA", "ANNELLE", "ANGILA", "ALONA", "ALLYN", "DOUGLAS", "ROGER", "JONATHAN", "RALPH", "NICHOLAS",
|
||||
"BENJAMIN", "BRUCE", "HARRY", "WAYNE", "STEVE", "HOWARD", "ERNEST", "PHILLIP", "TODD", "CRAIG",
|
||||
"ALAN", "PHILIP", "EARL", "DANNY", "BRYAN", "STANLEY", "LEONARD", "NATHAN", "MANUEL", "RODNEY",
|
||||
"MARVIN", "VINCENT", "JEFFERY", "JEFF", "CHAD", "JACOB", "ALFRED", "BRADLEY", "HERBERT", "FREDERICK",
|
||||
"EDWIN", "DON", "RICKY", "RANDALL", "BARRY", "BERNARD", "LEROY", "MARCUS", "THEODORE", "CLIFFORD",
|
||||
"MIGUEL", "JIM", "TOM", "CALVIN", "BILL", "LLOYD", "DEREK", "WARREN", "DARRELL", "JEROME",
|
||||
"FLOYD", "ALVIN", "TIM", "GORDON", "GREG", "JORGE", "DUSTIN", "PEDRO", "DERRICK", "ZACHARY",
|
||||
"HERMAN", "GLEN", "HECTOR", "RICARDO", "RICK", "BRENT", "RAMON", "GILBERT", "MARC", "REGINALD",
|
||||
"RUBEN", "NATHANIEL", "RAFAEL", "EDGAR", "MILTON", "RAUL", "BEN", "CHESTER", "DUANE", "FRANKLIN",
|
||||
"BRAD", "RON", "ROLAND", "ARNOLD", "HARVEY", "JARED", "ERIK", "DARRYL", "NEIL", "JAVIER",
|
||||
"FERNANDO", "CLINTON", "TED", "MATHEW", "TYRONE", "DARREN", "LANCE", "KURT", "ALLAN", "NELSON",
|
||||
"GUY", "CLAYTON", "HUGH", "MAX", "DWAYNE", "DWIGHT", "ARMANDO", "FELIX", "EVERETT", "IAN",
|
||||
"WALLACE", "KEN", "BOB", "ALFREDO", "ALBERTO", "DAVE", "IVAN", "BYRON", "ISAAC", "MORRIS",
|
||||
"CLIFTON", "WILLARD", "ROSS", "ANDY", "SALVADOR", "KIRK", "SERGIO", "SETH", "KENT", "TERRANCE",
|
||||
"EDUARDO", "TERRENCE", "ENRIQUE", "WADE", "STUART", "FREDRICK", "ARTURO", "ALEJANDRO", "NICK", "LUTHER",
|
||||
"WENDELL", "JEREMIAH", "JULIUS", "OTIS", "TREVOR", "OLIVER", "LUKE", "HOMER", "GERARD", "DOUG",
|
||||
"KENNY", "HUBERT", "LYLE", "MATT", "ALFONSO", "ORLANDO", "REX", "CARLTON", "ERNESTO", "NEAL",
|
||||
"PABLO", "LORENZO", "OMAR", "WILBUR", "GRANT", "HORACE", "RODERICK", "ABRAHAM", "WILLIS", "RICKEY",
|
||||
"ANDRES", "CESAR", "JOHNATHAN", "MALCOLM", "RUDOLPH", "DAMON", "KELVIN", "PRESTON", "ALTON", "ARCHIE",
|
||||
"MARCO", "WM", "PETE", "RANDOLPH", "GARRY", "GEOFFREY", "JONATHON", "FELIPE", "GERARDO", "ED",
|
||||
"DOMINIC", "DELBERT", "COLIN", "GUILLERMO", "EARNEST", "LUCAS", "BENNY", "SPENCER", "RODOLFO", "MYRON",
|
||||
"EDMUND", "GARRETT", "SALVATORE", "CEDRIC", "LOWELL", "GREGG", "SHERMAN", "WILSON", "SYLVESTER", "ROOSEVELT",
|
||||
"ISRAEL", "JERMAINE", "FORREST", "WILBERT", "LELAND", "SIMON", "CLARK", "IRVING", "BRYANT", "OWEN",
|
||||
"RUFUS", "WOODROW", "KRISTOPHER", "MACK", "LEVI", "MARCOS", "GUSTAVO", "JAKE", "LIONEL", "GILBERTO",
|
||||
"CLINT", "NICOLAS", "ISMAEL", "ORVILLE", "ERVIN", "DEWEY", "AL", "WILFRED", "JOSH", "HUGO",
|
||||
"IGNACIO", "CALEB", "TOMAS", "SHELDON", "ERICK", "STEWART", "DOYLE", "DARREL", "ROGELIO", "TERENCE",
|
||||
"SANTIAGO", "ALONZO", "ELIAS", "BERT", "ELBERT", "RAMIRO", "CONRAD", "NOAH", "GRADY", "PHIL",
|
||||
"CORNELIUS", "LAMAR", "ROLANDO", "CLAY", "PERCY", "DEXTER", "BRADFORD", "DARIN", "AMOS", "MOSES",
|
||||
"IRVIN", "SAUL", "ROMAN", "RANDAL", "TIMMY", "DARRIN", "WINSTON", "BRENDAN", "ABEL", "DOMINICK",
|
||||
"BOYD", "EMILIO", "ELIJAH", "DOMINGO", "EMMETT", "MARLON", "EMANUEL", "JERALD", "EDMOND", "EMIL",
|
||||
"DEWAYNE", "WILL", "OTTO", "TEDDY", "REYNALDO", "BRET", "JESS", "TRENT", "HUMBERTO", "EMMANUEL",
|
||||
"STEPHAN", "VICENTE", "LAMONT", "GARLAND", "MILES", "EFRAIN", "HEATH", "RODGER", "HARLEY", "ETHAN",
|
||||
"ELDON", "ROCKY", "PIERRE", "JUNIOR", "FREDDY", "ELI", "BRYCE", "ANTOINE", "STERLING", "CHASE",
|
||||
"GROVER", "ELTON", "CLEVELAND", "DYLAN", "CHUCK", "DAMIAN", "REUBEN", "STAN", "AUGUST", "LEONARDO",
|
||||
"JASPER", "RUSSEL", "ERWIN", "BENITO", "HANS", "MONTE", "BLAINE", "ERNIE", "CURT", "QUENTIN",
|
||||
"AGUSTIN", "MURRAY", "JAMAL", "ADOLFO", "HARRISON", "TYSON", "BURTON", "BRADY", "ELLIOTT", "WILFREDO",
|
||||
"BART", "JARROD", "VANCE", "DENIS", "DAMIEN", "JOAQUIN", "HARLAN", "DESMOND", "ELLIOT", "DARWIN",
|
||||
"GREGORIO", "BUDDY", "XAVIER", "KERMIT", "ROSCOE", "ESTEBAN", "ANTON", "SOLOMON", "SCOTTY", "NORBERT",
|
||||
"ELVIN", "WILLIAMS", "NOLAN", "ROD", "QUINTON", "HAL", "BRAIN", "ROB", "ELWOOD", "KENDRICK",
|
||||
"DARIUS", "MOISES", "FIDEL", "THADDEUS", "CLIFF", "MARCEL", "JACKSON", "RAPHAEL", "BRYON", "ARMAND",
|
||||
"ALVARO", "JEFFRY", "DANE", "JOESPH", "THURMAN", "NED", "RUSTY", "MONTY", "FABIAN", "REGGIE",
|
||||
"MASON", "GRAHAM", "ISAIAH", "VAUGHN", "GUS", "LOYD", "DIEGO", "ADOLPH", "NORRIS", "MILLARD",
|
||||
"ROCCO", "GONZALO", "DERICK", "RODRIGO", "WILEY", "RIGOBERTO", "ALPHONSO", "TY", "NOE", "VERN",
|
||||
"REED", "JEFFERSON", "ELVIS", "BERNARDO", "MAURICIO", "HIRAM", "DONOVAN", "BASIL", "RILEY", "NICKOLAS",
|
||||
"MAYNARD", "SCOT", "VINCE", "QUINCY", "EDDY", "SEBASTIAN", "FEDERICO", "ULYSSES", "HERIBERTO", "DONNELL",
|
||||
"COLE", "DAVIS", "GAVIN", "EMERY", "WARD", "ROMEO", "JAYSON", "DANTE", "CLEMENT", "COY",
|
||||
"MAXWELL", "JARVIS", "BRUNO", "ISSAC", "DUDLEY", "BROCK", "SANFORD", "CARMELO", "BARNEY", "NESTOR",
|
||||
"STEFAN", "DONNY", "ART", "LINWOOD", "BEAU", "WELDON", "GALEN", "ISIDRO", "TRUMAN", "DELMAR",
|
||||
"JOHNATHON", "SILAS", "FREDERIC", "DICK", "IRWIN", "MERLIN", "CHARLEY", "MARCELINO", "HARRIS", "CARLO",
|
||||
"TRENTON", "KURTIS", "HUNTER", "AURELIO", "WINFRED", "VITO", "COLLIN", "DENVER", "CARTER", "LEONEL",
|
||||
"EMORY", "PASQUALE", "MOHAMMAD", "MARIANO", "DANIAL", "LANDON", "DIRK", "BRANDEN", "ADAN", "BUFORD",
|
||||
"GERMAN", "WILMER", "EMERSON", "ZACHERY", "FLETCHER", "JACQUES", "ERROL", "DALTON", "MONROE", "JOSUE",
|
||||
"EDWARDO", "BOOKER", "WILFORD", "SONNY", "SHELTON", "CARSON", "THERON", "RAYMUNDO", "DAREN", "HOUSTON",
|
||||
"ROBBY", "LINCOLN", "GENARO", "BENNETT", "OCTAVIO", "CORNELL", "HUNG", "ARRON", "ANTONY", "HERSCHEL",
|
||||
"GIOVANNI", "GARTH", "CYRUS", "CYRIL", "RONNY", "LON", "FREEMAN", "DUNCAN", "KENNITH", "CARMINE",
|
||||
"ERICH", "CHADWICK", "WILBURN", "RUSS", "REID", "MYLES", "ANDERSON", "MORTON", "JONAS", "FOREST",
|
||||
"MITCHEL", "MERVIN", "ZANE", "RICH", "JAMEL", "LAZARO", "ALPHONSE", "RANDELL", "MAJOR", "JARRETT",
|
||||
"BROOKS", "ABDUL", "LUCIANO", "SEYMOUR", "EUGENIO", "MOHAMMED", "VALENTIN", "CHANCE", "ARNULFO", "LUCIEN",
|
||||
"FERDINAND", "THAD", "EZRA", "ALDO", "RUBIN", "ROYAL", "MITCH", "EARLE", "ABE", "WYATT",
|
||||
"MARQUIS", "LANNY", "KAREEM", "JAMAR", "BORIS", "ISIAH", "EMILE", "ELMO", "ARON", "LEOPOLDO",
|
||||
"EVERETTE", "JOSEF", "ELOY", "RODRICK", "REINALDO", "LUCIO", "JERROD", "WESTON", "HERSHEL", "BARTON",
|
||||
"PARKER", "LEMUEL", "BURT", "JULES", "GIL", "ELISEO", "AHMAD", "NIGEL", "EFREN", "ANTWAN",
|
||||
"ALDEN", "MARGARITO", "COLEMAN", "DINO", "OSVALDO", "LES", "DEANDRE", "NORMAND", "KIETH", "TREY",
|
||||
"NORBERTO", "NAPOLEON", "JEROLD", "FRITZ", "ROSENDO", "MILFORD", "CHRISTOPER", "ALFONZO", "LYMAN", "JOSIAH",
|
||||
"BRANT", "WILTON", "RICO", "JAMAAL", "DEWITT", "BRENTON", "OLIN", "FOSTER", "FAUSTINO", "CLAUDIO",
|
||||
"JUDSON", "GINO", "EDGARDO", "ALEC", "TANNER", "JARRED", "DONN", "TAD", "PRINCE", "PORFIRIO",
|
||||
"ODIS", "LENARD", "CHAUNCEY", "TOD", "MEL", "MARCELO", "KORY", "AUGUSTUS", "KEVEN", "HILARIO",
|
||||
"BUD", "SAL", "ORVAL", "MAURO", "ZACHARIAH", "OLEN", "ANIBAL", "MILO", "JED", "DILLON",
|
||||
"AMADO", "NEWTON", "LENNY", "RICHIE", "HORACIO", "BRICE", "MOHAMED", "DELMER", "DARIO", "REYES",
|
||||
"MAC", "JONAH", "JERROLD", "ROBT", "HANK", "RUPERT", "ROLLAND", "KENTON", "DAMION", "ANTONE",
|
||||
"WALDO", "FREDRIC", "BRADLY", "KIP", "BURL", "WALKER", "TYREE", "JEFFEREY", "AHMED", "WILLY",
|
||||
"STANFORD", "OREN", "NOBLE", "MOSHE", "MIKEL", "ENOCH", "BRENDON", "QUINTIN", "JAMISON", "FLORENCIO",
|
||||
"DARRICK", "TOBIAS", "HASSAN", "GIUSEPPE", "DEMARCUS", "CLETUS", "TYRELL", "LYNDON", "KEENAN", "WERNER",
|
||||
"GERALDO", "COLUMBUS", "CHET", "BERTRAM", "MARKUS", "HUEY", "HILTON", "DWAIN", "DONTE", "TYRON",
|
||||
"OMER", "ISAIAS", "HIPOLITO", "FERMIN", "ADALBERTO", "BO", "BARRETT", "TEODORO", "MCKINLEY", "MAXIMO",
|
||||
"GARFIELD", "RALEIGH", "LAWERENCE", "ABRAM", "RASHAD", "KING", "EMMITT", "DARON", "SAMUAL", "MIQUEL",
|
||||
"EUSEBIO", "DOMENIC", "DARRON", "BUSTER", "WILBER", "RENATO", "JC", "HOYT", "HAYWOOD", "EZEKIEL",
|
||||
"CHAS", "FLORENTINO", "ELROY", "CLEMENTE", "ARDEN", "NEVILLE", "EDISON", "DESHAWN", "NATHANIAL", "JORDON",
|
||||
"DANILO", "CLAUD", "SHERWOOD", "RAYMON", "RAYFORD", "CRISTOBAL", "AMBROSE", "TITUS", "HYMAN", "FELTON",
|
||||
"EZEQUIEL", "ERASMO", "STANTON", "LONNY", "LEN", "IKE", "MILAN", "LINO", "JAROD", "HERB",
|
||||
"ANDREAS", "WALTON", "RHETT", "PALMER", "DOUGLASS", "CORDELL", "OSWALDO", "ELLSWORTH", "VIRGILIO", "TONEY",
|
||||
"NATHANAEL", "DEL", "BENEDICT", "MOSE", "JOHNSON", "ISREAL", "GARRET", "FAUSTO", "ASA", "ARLEN",
|
||||
"ZACK", "WARNER", "MODESTO", "FRANCESCO", "MANUAL", "GAYLORD", "GASTON", "FILIBERTO", "DEANGELO", "MICHALE",
|
||||
"GRANVILLE", "WES", "MALIK", "ZACKARY", "TUAN", "ELDRIDGE", "CRISTOPHER", "CORTEZ", "ANTIONE", "MALCOM",
|
||||
"LONG", "KOREY", "JOSPEH", "COLTON", "WAYLON", "VON", "HOSEA", "SHAD", "SANTO", "RUDOLF",
|
||||
"ROLF", "REY", "RENALDO", "MARCELLUS", "LUCIUS", "KRISTOFER", "BOYCE", "BENTON", "HAYDEN", "HARLAND",
|
||||
"ARNOLDO", "RUEBEN", "LEANDRO", "KRAIG", "JERRELL", "JEROMY", "HOBERT", "CEDRICK", "ARLIE", "WINFORD",
|
||||
"WALLY", "LUIGI", "KENETH", "JACINTO", "GRAIG", "FRANKLYN", "EDMUNDO", "SID", "PORTER", "LEIF",
|
||||
"JERAMY", "BUCK", "WILLIAN", "VINCENZO", "SHON", "LYNWOOD", "JERE", "HAI", "ELDEN", "DORSEY",
|
||||
"DARELL", "BRODERICK", "ALONSO"
|
||||
]
|
||||
total_sum = 0
|
||||
temp_sum = 0
|
||||
name.sort()
|
||||
for i in range(len(name)):
|
||||
for j in name[i]:
|
||||
temp_sum += ord(j) - ord('A') + 1
|
||||
total_sum += (i + 1) * temp_sum
|
||||
temp_sum = 0
|
||||
print(total_sum)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,7 +0,0 @@
|
|||
from itertools import permutations
|
||||
def main():
|
||||
result=list(map("".join, permutations('0123456789')))
|
||||
print(result[999999])
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,31 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def fibonacci(n):
|
||||
if n == 1 or type(n) is not int:
|
||||
return 0
|
||||
elif n == 2:
|
||||
return 1
|
||||
else:
|
||||
sequence = [0, 1]
|
||||
for i in xrange(2, n+1):
|
||||
sequence.append(sequence[i-1] + sequence[i-2])
|
||||
|
||||
return sequence[n]
|
||||
|
||||
def fibonacci_digits_index(n):
|
||||
digits = 0
|
||||
index = 2
|
||||
|
||||
while digits < n:
|
||||
index += 1
|
||||
digits = len(str(fibonacci(index)))
|
||||
|
||||
return index
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(fibonacci_digits_index(1000))
|
|
@ -1,29 +0,0 @@
|
|||
from __future__ import print_function
|
||||
from math import ceil
|
||||
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def diagonal_sum(n):
|
||||
total = 1
|
||||
|
||||
for i in xrange(1, int(ceil(n/2.0))):
|
||||
odd = 2*i+1
|
||||
even = 2*i
|
||||
total = total + 4*odd**2 - 6*even
|
||||
|
||||
return total
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
if len(sys.argv) == 1:
|
||||
print(diagonal_sum(1001))
|
||||
else:
|
||||
try:
|
||||
n = int(sys.argv[1])
|
||||
diagonal_sum(n)
|
||||
except ValueError:
|
||||
print('Invalid entry - please enter a number')
|
|
@ -1,33 +0,0 @@
|
|||
def main():
|
||||
"""
|
||||
Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5:
|
||||
|
||||
22=4, 23=8, 24=16, 25=32
|
||||
32=9, 33=27, 34=81, 35=243
|
||||
42=16, 43=64, 44=256, 45=1024
|
||||
52=25, 53=125, 54=625, 55=3125
|
||||
If they are then placed in numerical order, with any repeats removed,
|
||||
we get the following sequence of 15 distinct terms:
|
||||
|
||||
4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125
|
||||
|
||||
How many distinct terms are in the sequence generated by ab
|
||||
for 2 <= a <= 100 and 2 <= b <= 100?
|
||||
"""
|
||||
|
||||
collectPowers = set()
|
||||
|
||||
currentPow = 0
|
||||
|
||||
N = 101 # maximum limit
|
||||
|
||||
for a in range(2, N):
|
||||
for b in range(2, N):
|
||||
currentPow = a**b # calculates the current power
|
||||
collectPowers.add(currentPow) # adds the result to the set
|
||||
|
||||
print("Number of terms ", len(collectPowers))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,30 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Double-base palindromes
|
||||
Problem 36
|
||||
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
|
||||
|
||||
Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.
|
||||
|
||||
(Please note that the palindromic number, in either base, may not include leading zeros.)
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def is_palindrome(n):
|
||||
n = str(n)
|
||||
|
||||
if n == n[::-1]:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
total = 0
|
||||
|
||||
for i in xrange(1, 1000000):
|
||||
if is_palindrome(i) and is_palindrome(bin(i).split('b')[1]):
|
||||
total += i
|
||||
|
||||
print(total)
|
|
@ -1,26 +0,0 @@
|
|||
#-.- coding: latin-1 -.-
|
||||
from __future__ import print_function
|
||||
'''
|
||||
Champernowne's constant
|
||||
Problem 40
|
||||
An irrational decimal fraction is created by concatenating the positive integers:
|
||||
|
||||
0.123456789101112131415161718192021...
|
||||
|
||||
It can be seen that the 12th digit of the fractional part is 1.
|
||||
|
||||
If dn represents the nth digit of the fractional part, find the value of the following expression.
|
||||
|
||||
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
|
||||
'''
|
||||
|
||||
constant = []
|
||||
i = 1
|
||||
|
||||
while len(constant) < 1e6:
|
||||
constant.append(str(i))
|
||||
i += 1
|
||||
|
||||
constant = ''.join(constant)
|
||||
|
||||
print(int(constant[0])*int(constant[9])*int(constant[99])*int(constant[999])*int(constant[9999])*int(constant[99999])*int(constant[999999]))
|
|
@ -1,21 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Self Powers
|
||||
Problem 48
|
||||
|
||||
The series, 11 + 22 + 33 + ... + 1010 = 10405071317.
|
||||
|
||||
Find the last ten digits of the series, 11 + 22 + 33 + ... + 10001000.
|
||||
'''
|
||||
|
||||
try:
|
||||
xrange
|
||||
except NameError:
|
||||
xrange = range
|
||||
|
||||
total = 0
|
||||
for i in xrange(1, 1001):
|
||||
total += i**i
|
||||
|
||||
|
||||
print(str(total)[-10:])
|
|
@ -1,23 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Permuted multiples
|
||||
Problem 52
|
||||
|
||||
It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order.
|
||||
|
||||
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.
|
||||
'''
|
||||
i = 1
|
||||
|
||||
while True:
|
||||
if sorted(list(str(i))) == \
|
||||
sorted(list(str(2*i))) == \
|
||||
sorted(list(str(3*i))) == \
|
||||
sorted(list(str(4*i))) == \
|
||||
sorted(list(str(5*i))) == \
|
||||
sorted(list(str(6*i))):
|
||||
break
|
||||
|
||||
i += 1
|
||||
|
||||
print(i)
|
|
@ -1,36 +0,0 @@
|
|||
#-.- coding: latin-1 -.-
|
||||
from __future__ import print_function
|
||||
from math import factorial
|
||||
'''
|
||||
Combinatoric selections
|
||||
Problem 53
|
||||
|
||||
There are exactly ten ways of selecting three from five, 12345:
|
||||
|
||||
123, 124, 125, 134, 135, 145, 234, 235, 245, and 345
|
||||
|
||||
In combinatorics, we use the notation, 5C3 = 10.
|
||||
|
||||
In general,
|
||||
|
||||
nCr = n!/(r!(n−r)!),where r ≤ n, n! = n×(n−1)×...×3×2×1, and 0! = 1.
|
||||
It is not until n = 23, that a value exceeds one-million: 23C10 = 1144066.
|
||||
|
||||
How many, not necessarily distinct, values of nCr, for 1 ≤ n ≤ 100, are greater than one-million?
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def combinations(n, r):
|
||||
return factorial(n)/(factorial(r)*factorial(n-r))
|
||||
|
||||
total = 0
|
||||
|
||||
for i in xrange(1, 101):
|
||||
for j in xrange(1, i+1):
|
||||
if combinations(i, j) > 1e6:
|
||||
total += 1
|
||||
|
||||
print(total)
|
|
@ -1,35 +0,0 @@
|
|||
from __future__ import print_function
|
||||
'''
|
||||
Counting Summations
|
||||
Problem 76
|
||||
|
||||
It is possible to write five as a sum in exactly six different ways:
|
||||
|
||||
4 + 1
|
||||
3 + 2
|
||||
3 + 1 + 1
|
||||
2 + 2 + 1
|
||||
2 + 1 + 1 + 1
|
||||
1 + 1 + 1 + 1 + 1
|
||||
|
||||
How many different ways can one hundred be written as a sum of at least two positive integers?
|
||||
'''
|
||||
try:
|
||||
xrange #Python 2
|
||||
except NameError:
|
||||
xrange = range #Python 3
|
||||
|
||||
def partition(m):
|
||||
memo = [[0 for _ in xrange(m)] for _ in xrange(m+1)]
|
||||
for i in xrange(m+1):
|
||||
memo[i][0] = 1
|
||||
|
||||
for n in xrange(m+1):
|
||||
for k in xrange(1, m):
|
||||
memo[n][k] += memo[n][k-1]
|
||||
if n > k:
|
||||
memo[n][k] += memo[n-k-1][k]
|
||||
|
||||
return (memo[m][m-1] - 1)
|
||||
|
||||
print(partition(100))
|
|
@ -1,58 +0,0 @@
|
|||
# ProjectEuler
|
||||
|
||||
Problems are taken from https://projecteuler.net/.
|
||||
|
||||
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical
|
||||
insights to solve. Project Euler is ideal for mathematicians who are learning to code.
|
||||
|
||||
Here the efficiency of your code is also checked.
|
||||
I've tried to provide all the best possible solutions.
|
||||
|
||||
PROBLEMS:
|
||||
|
||||
1. If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3,5,6 and 9. The sum of these multiples is 23.
|
||||
Find the sum of all the multiples of 3 or 5 below N.
|
||||
|
||||
2. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2,
|
||||
the first 10 terms will be:
|
||||
1,2,3,5,8,13,21,34,55,89,..
|
||||
By considering the terms in the Fibonacci sequence whose values do not exceed n, find the sum of the even-valued terms.
|
||||
e.g. for n=10, we have {2,8}, sum is 10.
|
||||
|
||||
3. The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor of a given number N?
|
||||
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
|
||||
|
||||
4. A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
|
||||
Find the largest palindrome made from the product of two 3-digit numbers which is less than N.
|
||||
|
||||
5. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
|
||||
What is the smallest positive number that is evenly divisible(divisible with no remainder) by all of the numbers from 1 to N?
|
||||
|
||||
6. The sum of the squares of the first ten natural numbers is,
|
||||
1^2 + 2^2 + ... + 10^2 = 385
|
||||
The square of the sum of the first ten natural numbers is,
|
||||
(1 + 2 + ... + 10)^2 = 552 = 3025
|
||||
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.
|
||||
Find the difference between the sum of the squares of the first N natural numbers and the square of the sum.
|
||||
|
||||
7. By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.
|
||||
What is the Nth prime number?
|
||||
|
||||
9. A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
|
||||
a^2 + b^2 = c^2
|
||||
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
|
||||
Find the product abc.
|
||||
|
||||
14. The following iterative sequence is defined for the set of positive integers:
|
||||
n → n/2 (n is even)
|
||||
n → 3n + 1 (n is odd)
|
||||
Using the rule above and starting with 13, we generate the following sequence:
|
||||
13 → 40 → 20 → 10 → 5 → 16 → 8 → 4 → 2 → 1
|
||||
Which starting number, under one million, produces the longest chain?
|
||||
|
||||
16. 2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
|
||||
What is the sum of the digits of the number 2^1000?
|
||||
20. n! means n × (n − 1) × ... × 3 × 2 × 1
|
||||
For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800,
|
||||
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
|
||||
Find the sum of the digits in the number 100!
|
|
@ -1,116 +0,0 @@
|
|||
def compare_string(string1, string2):
|
||||
l1 = list(string1); l2 = list(string2)
|
||||
count = 0
|
||||
for i in range(len(l1)):
|
||||
if l1[i] != l2[i]:
|
||||
count += 1
|
||||
l1[i] = '_'
|
||||
if count > 1:
|
||||
return -1
|
||||
else:
|
||||
return("".join(l1))
|
||||
|
||||
def check(binary):
|
||||
pi = []
|
||||
while 1:
|
||||
check1 = ['$']*len(binary)
|
||||
temp = []
|
||||
for i in range(len(binary)):
|
||||
for j in range(i+1, len(binary)):
|
||||
k=compare_string(binary[i], binary[j])
|
||||
if k != -1:
|
||||
check1[i] = '*'
|
||||
check1[j] = '*'
|
||||
temp.append(k)
|
||||
for i in range(len(binary)):
|
||||
if check1[i] == '$':
|
||||
pi.append(binary[i])
|
||||
if len(temp) == 0:
|
||||
return pi
|
||||
binary = list(set(temp))
|
||||
|
||||
def decimal_to_binary(no_of_variable, minterms):
|
||||
temp = []
|
||||
s = ''
|
||||
for m in minterms:
|
||||
for i in range(no_of_variable):
|
||||
s = str(m%2) + s
|
||||
m //= 2
|
||||
temp.append(s)
|
||||
s = ''
|
||||
return temp
|
||||
|
||||
def is_for_table(string1, string2, count):
|
||||
l1 = list(string1);l2=list(string2)
|
||||
count_n = 0
|
||||
for i in range(len(l1)):
|
||||
if l1[i] != l2[i]:
|
||||
count_n += 1
|
||||
if count_n == count:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def selection(chart, prime_implicants):
|
||||
temp = []
|
||||
select = [0]*len(chart)
|
||||
for i in range(len(chart[0])):
|
||||
count = 0
|
||||
rem = -1
|
||||
for j in range(len(chart)):
|
||||
if chart[j][i] == 1:
|
||||
count += 1
|
||||
rem = j
|
||||
if count == 1:
|
||||
select[rem] = 1
|
||||
for i in range(len(select)):
|
||||
if select[i] == 1:
|
||||
for j in range(len(chart[0])):
|
||||
if chart[i][j] == 1:
|
||||
for k in range(len(chart)):
|
||||
chart[k][j] = 0
|
||||
temp.append(prime_implicants[i])
|
||||
while 1:
|
||||
max_n = 0; rem = -1; count_n = 0
|
||||
for i in range(len(chart)):
|
||||
count_n = chart[i].count(1)
|
||||
if count_n > max_n:
|
||||
max_n = count_n
|
||||
rem = i
|
||||
|
||||
if max_n == 0:
|
||||
return temp
|
||||
|
||||
temp.append(prime_implicants[rem])
|
||||
|
||||
for i in range(len(chart[0])):
|
||||
if chart[rem][i] == 1:
|
||||
for j in range(len(chart)):
|
||||
chart[j][i] = 0
|
||||
|
||||
def prime_implicant_chart(prime_implicants, binary):
|
||||
chart = [[0 for x in range(len(binary))] for x in range(len(prime_implicants))]
|
||||
for i in range(len(prime_implicants)):
|
||||
count = prime_implicants[i].count('_')
|
||||
for j in range(len(binary)):
|
||||
if(is_for_table(prime_implicants[i], binary[j], count)):
|
||||
chart[i][j] = 1
|
||||
|
||||
return chart
|
||||
|
||||
def main():
|
||||
no_of_variable = int(raw_input("Enter the no. of variables\n"))
|
||||
minterms = [int(x) for x in raw_input("Enter the decimal representation of Minterms 'Spaces Seprated'\n").split()]
|
||||
binary = decimal_to_binary(no_of_variable, minterms)
|
||||
|
||||
prime_implicants = check(binary)
|
||||
print("Prime Implicants are:")
|
||||
print(prime_implicants)
|
||||
chart = prime_implicant_chart(prime_implicants, binary)
|
||||
|
||||
essential_prime_implicants = selection(chart,prime_implicants)
|
||||
print("Essential Prime Implicants are:")
|
||||
print(essential_prime_implicants)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,32 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import random
|
||||
|
||||
|
||||
class Onepad:
|
||||
def encrypt(self, text):
|
||||
'''Function to encrypt text using psedo-random numbers'''
|
||||
plain = [ord(i) for i in text]
|
||||
key = []
|
||||
cipher = []
|
||||
for i in plain:
|
||||
k = random.randint(1, 300)
|
||||
c = (i+k)*k
|
||||
cipher.append(c)
|
||||
key.append(k)
|
||||
return cipher, key
|
||||
|
||||
def decrypt(self, cipher, key):
|
||||
'''Function to decrypt text using psedo-random numbers.'''
|
||||
plain = []
|
||||
for i in range(len(key)):
|
||||
p = (cipher[i]-(key[i])**2)/key[i]
|
||||
plain.append(chr(p))
|
||||
plain = ''.join([i for i in plain])
|
||||
return plain
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
c, k = Onepad().encrypt('Hello')
|
||||
print(c, k)
|
||||
print(Onepad().decrypt(c, k))
|
File diff suppressed because it is too large
Load Diff
|
@ -1,209 +0,0 @@
|
|||
"""
|
||||
author: Christian Bender
|
||||
date: 21.12.2017
|
||||
class: XORCipher
|
||||
|
||||
This class implements the XOR-cipher algorithm and provides
|
||||
some useful methods for encrypting and decrypting strings and
|
||||
files.
|
||||
|
||||
Overview about methods
|
||||
|
||||
- encrypt : list of char
|
||||
- decrypt : list of char
|
||||
- encrypt_string : str
|
||||
- decrypt_string : str
|
||||
- encrypt_file : boolean
|
||||
- decrypt_file : boolean
|
||||
"""
|
||||
class XORCipher(object):
|
||||
|
||||
def __init__(self, key = 0):
|
||||
"""
|
||||
simple constructor that receives a key or uses
|
||||
default key = 0
|
||||
"""
|
||||
|
||||
#private field
|
||||
self.__key = key
|
||||
|
||||
def encrypt(self, content, key):
|
||||
"""
|
||||
input: 'content' of type string and 'key' of type int
|
||||
output: encrypted string 'content' as a list of chars
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
# precondition
|
||||
assert (isinstance(key,int) and isinstance(content,str))
|
||||
|
||||
key = key or self.__key or 1
|
||||
|
||||
# make sure key can be any size
|
||||
while (key > 255):
|
||||
key -= 255
|
||||
|
||||
# This will be returned
|
||||
ans = []
|
||||
|
||||
for ch in content:
|
||||
ans.append(chr(ord(ch) ^ key))
|
||||
|
||||
return ans
|
||||
|
||||
def decrypt(self,content,key):
|
||||
"""
|
||||
input: 'content' of type list and 'key' of type int
|
||||
output: decrypted string 'content' as a list of chars
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
# precondition
|
||||
assert (isinstance(key,int) and isinstance(content,list))
|
||||
|
||||
key = key or self.__key or 1
|
||||
|
||||
# make sure key can be any size
|
||||
while (key > 255):
|
||||
key -= 255
|
||||
|
||||
# This will be returned
|
||||
ans = []
|
||||
|
||||
for ch in content:
|
||||
ans.append(chr(ord(ch) ^ key))
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
def encrypt_string(self,content, key = 0):
|
||||
"""
|
||||
input: 'content' of type string and 'key' of type int
|
||||
output: encrypted string 'content'
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
# precondition
|
||||
assert (isinstance(key,int) and isinstance(content,str))
|
||||
|
||||
key = key or self.__key or 1
|
||||
|
||||
# make sure key can be any size
|
||||
while (key > 255):
|
||||
key -= 255
|
||||
|
||||
# This will be returned
|
||||
ans = ""
|
||||
|
||||
for ch in content:
|
||||
ans += chr(ord(ch) ^ key)
|
||||
|
||||
return ans
|
||||
|
||||
def decrypt_string(self,content,key = 0):
|
||||
"""
|
||||
input: 'content' of type string and 'key' of type int
|
||||
output: decrypted string 'content'
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
# precondition
|
||||
assert (isinstance(key,int) and isinstance(content,str))
|
||||
|
||||
key = key or self.__key or 1
|
||||
|
||||
# make sure key can be any size
|
||||
while (key > 255):
|
||||
key -= 255
|
||||
|
||||
# This will be returned
|
||||
ans = ""
|
||||
|
||||
for ch in content:
|
||||
ans += chr(ord(ch) ^ key)
|
||||
|
||||
return ans
|
||||
|
||||
|
||||
def encrypt_file(self, file, key = 0):
|
||||
"""
|
||||
input: filename (str) and a key (int)
|
||||
output: returns true if encrypt process was
|
||||
successful otherwise false
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
#precondition
|
||||
assert (isinstance(file,str) and isinstance(key,int))
|
||||
|
||||
try:
|
||||
with open(file,"r") as fin:
|
||||
with open("encrypt.out","w+") as fout:
|
||||
|
||||
# actual encrypt-process
|
||||
for line in fin:
|
||||
fout.write(self.encrypt_string(line,key))
|
||||
|
||||
except:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def decrypt_file(self,file, key):
|
||||
"""
|
||||
input: filename (str) and a key (int)
|
||||
output: returns true if decrypt process was
|
||||
successful otherwise false
|
||||
if key not passed the method uses the key by the constructor.
|
||||
otherwise key = 1
|
||||
"""
|
||||
|
||||
#precondition
|
||||
assert (isinstance(file,str) and isinstance(key,int))
|
||||
|
||||
try:
|
||||
with open(file,"r") as fin:
|
||||
with open("decrypt.out","w+") as fout:
|
||||
|
||||
# actual encrypt-process
|
||||
for line in fin:
|
||||
fout.write(self.decrypt_string(line,key))
|
||||
|
||||
except:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
|
||||
# Tests
|
||||
# crypt = XORCipher()
|
||||
# key = 67
|
||||
|
||||
# # test enrcypt
|
||||
# print crypt.encrypt("hallo welt",key)
|
||||
# # test decrypt
|
||||
# print crypt.decrypt(crypt.encrypt("hallo welt",key), key)
|
||||
|
||||
# # test encrypt_string
|
||||
# print crypt.encrypt_string("hallo welt",key)
|
||||
|
||||
# # test decrypt_string
|
||||
# print crypt.decrypt_string(crypt.encrypt_string("hallo welt",key),key)
|
||||
|
||||
# if (crypt.encrypt_file("test.txt",key)):
|
||||
# print "encrypt successful"
|
||||
# else:
|
||||
# print "encrypt unsuccessful"
|
||||
|
||||
# if (crypt.decrypt_file("encrypt.out",key)):
|
||||
# print "decrypt successful"
|
||||
# else:
|
||||
# print "decrypt unsuccessful"
|
|
@ -1,54 +0,0 @@
|
|||
from __future__ import print_function
|
||||
def decrypt(message):
|
||||
"""
|
||||
>>> decrypt('TMDETUX PMDVU')
|
||||
Decryption using Key #0: TMDETUX PMDVU
|
||||
Decryption using Key #1: SLCDSTW OLCUT
|
||||
Decryption using Key #2: RKBCRSV NKBTS
|
||||
Decryption using Key #3: QJABQRU MJASR
|
||||
Decryption using Key #4: PIZAPQT LIZRQ
|
||||
Decryption using Key #5: OHYZOPS KHYQP
|
||||
Decryption using Key #6: NGXYNOR JGXPO
|
||||
Decryption using Key #7: MFWXMNQ IFWON
|
||||
Decryption using Key #8: LEVWLMP HEVNM
|
||||
Decryption using Key #9: KDUVKLO GDUML
|
||||
Decryption using Key #10: JCTUJKN FCTLK
|
||||
Decryption using Key #11: IBSTIJM EBSKJ
|
||||
Decryption using Key #12: HARSHIL DARJI
|
||||
Decryption using Key #13: GZQRGHK CZQIH
|
||||
Decryption using Key #14: FYPQFGJ BYPHG
|
||||
Decryption using Key #15: EXOPEFI AXOGF
|
||||
Decryption using Key #16: DWNODEH ZWNFE
|
||||
Decryption using Key #17: CVMNCDG YVMED
|
||||
Decryption using Key #18: BULMBCF XULDC
|
||||
Decryption using Key #19: ATKLABE WTKCB
|
||||
Decryption using Key #20: ZSJKZAD VSJBA
|
||||
Decryption using Key #21: YRIJYZC URIAZ
|
||||
Decryption using Key #22: XQHIXYB TQHZY
|
||||
Decryption using Key #23: WPGHWXA SPGYX
|
||||
Decryption using Key #24: VOFGVWZ ROFXW
|
||||
Decryption using Key #25: UNEFUVY QNEWV
|
||||
"""
|
||||
LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
for key in range(len(LETTERS)):
|
||||
translated = ""
|
||||
for symbol in message:
|
||||
if symbol in LETTERS:
|
||||
num = LETTERS.find(symbol)
|
||||
num = num - key
|
||||
if num < 0:
|
||||
num = num + len(LETTERS)
|
||||
translated = translated + LETTERS[num]
|
||||
else:
|
||||
translated = translated + symbol
|
||||
print("Decryption using Key #%s: %s" % (key, translated))
|
||||
|
||||
def main():
|
||||
message = raw_input("Encrypted message: ")
|
||||
message = message.upper()
|
||||
decrypt(message)
|
||||
|
||||
if __name__ == '__main__':
|
||||
import doctest
|
||||
doctest.testmod()
|
||||
main()
|
|
@ -1,36 +0,0 @@
|
|||
from __future__ import print_function
|
||||
import time, os, sys
|
||||
import transposition_cipher as transCipher
|
||||
|
||||
def main():
|
||||
inputFile = 'Prehistoric Men.txt'
|
||||
outputFile = 'Output.txt'
|
||||
key = int(raw_input('Enter key: '))
|
||||
mode = raw_input('Encrypt/Decrypt [e/d]: ')
|
||||
|
||||
if not os.path.exists(inputFile):
|
||||
print('File %s does not exist. Quitting...' % inputFile)
|
||||
sys.exit()
|
||||
if os.path.exists(outputFile):
|
||||
print('Overwrite %s? [y/n]' % outputFile)
|
||||
response = raw_input('> ')
|
||||
if not response.lower().startswith('y'):
|
||||
sys.exit()
|
||||
|
||||
startTime = time.time()
|
||||
if mode.lower().startswith('e'):
|
||||
content = open(inputFile).read()
|
||||
translated = transCipher.encryptMessage(key, content)
|
||||
elif mode.lower().startswith('d'):
|
||||
content = open(outputFile).read()
|
||||
translated =transCipher .decryptMessage(key, content)
|
||||
|
||||
outputObj = open(outputFile, 'w')
|
||||
outputObj.write(translated)
|
||||
outputObj.close()
|
||||
|
||||
totalTime = round(time.time() - startTime, 2)
|
||||
print(('Done (', totalTime, 'seconds )'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -1,181 +0,0 @@
|
|||
"""
|
||||
An AVL tree
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
class Node:
|
||||
|
||||
def __init__(self, label):
|
||||
self.label = label
|
||||
self._parent = None
|
||||
self._left = None
|
||||
self._right = None
|
||||
self.height = 0
|
||||
|
||||
@property
|
||||
def right(self):
|
||||
return self._right
|
||||
|
||||
@right.setter
|
||||
def right(self, node):
|
||||
if node is not None:
|
||||
node._parent = self
|
||||
self._right = node
|
||||
|
||||
@property
|
||||
def left(self):
|
||||
return self._left
|
||||
|
||||
@left.setter
|
||||
def left(self, node):
|
||||
if node is not None:
|
||||
node._parent = self
|
||||
self._left = node
|
||||
|
||||
@property
|
||||
def parent(self):
|
||||
return self._parent
|
||||
|
||||
@parent.setter
|
||||
def parent(self, node):
|
||||
if node is not None:
|
||||
self._parent = node
|
||||
self.height = self.parent.height + 1
|
||||
else:
|
||||
self.height = 0
|
||||
|
||||
|
||||
class AVL:
|
||||
|
||||
def __init__(self):
|
||||
self.root = None
|
||||
self.size = 0
|
||||
|
||||
def insert(self, value):
|
||||
node = Node(value)
|
||||
|
||||
if self.root is None:
|
||||
self.root = node
|
||||
self.root.height = 0
|
||||
self.size = 1
|
||||
else:
|
||||
# Same as Binary Tree
|
||||
dad_node = None
|
||||
curr_node = self.root
|
||||
|
||||
while True:
|
||||
if curr_node is not None:
|
||||
|
||||
dad_node = curr_node
|
||||
|
||||
if node.label < curr_node.label:
|
||||
curr_node = curr_node.left
|
||||
else:
|
||||
curr_node = curr_node.right
|
||||
else:
|
||||
node.height = dad_node.height
|
||||
dad_node.height += 1
|
||||
if node.label < dad_node.label:
|
||||
dad_node.left = node
|
||||
else:
|
||||
dad_node.right = node
|
||||
self.rebalance(node)
|
||||
self.size += 1
|
||||
break
|
||||
|
||||
def rebalance(self, node):
|
||||
n = node
|
||||
|
||||
while n is not None:
|
||||
height_right = n.height
|
||||
height_left = n.height
|
||||
|
||||
if n.right is not None:
|
||||
height_right = n.right.height
|
||||
|
||||
if n.left is not None:
|
||||
height_left = n.left.height
|
||||
|
||||
if abs(height_left - height_right) > 1:
|
||||
if height_left > height_right:
|
||||
left_child = n.left
|
||||
if left_child is not None:
|
||||
h_right = (left_child.right.height
|
||||
if (left_child.right is not None) else 0)
|
||||
h_left = (left_child.left.height
|
||||
if (left_child.left is not None) else 0)
|
||||
if (h_left > h_right):
|
||||
self.rotate_left(n)
|
||||
break
|
||||
else:
|
||||
self.double_rotate_right(n)
|
||||
break
|
||||
else:
|
||||
right_child = n.right
|
||||
if right_child is not None:
|
||||
h_right = (right_child.right.height
|
||||
if (right_child.right is not None) else 0)
|
||||
h_left = (right_child.left.height
|
||||
if (right_child.left is not None) else 0)
|
||||
if (h_left > h_right):
|
||||
self.double_rotate_left(n)
|
||||
break
|
||||
else:
|
||||
self.rotate_right(n)
|
||||
break
|
||||
n = n.parent
|
||||
|
||||
def rotate_left(self, node):
|
||||
aux = node.parent.label
|
||||
node.parent.label = node.label
|
||||
node.parent.right = Node(aux)
|
||||
node.parent.right.height = node.parent.height + 1
|
||||
node.parent.left = node.right
|
||||
|
||||
|
||||
def rotate_right(self, node):
|
||||
aux = node.parent.label
|
||||
node.parent.label = node.label
|
||||
node.parent.left = Node(aux)
|
||||
node.parent.left.height = node.parent.height + 1
|
||||
node.parent.right = node.right
|
||||
|
||||
def double_rotate_left(self, node):
|
||||
self.rotate_right(node.getRight().getRight())
|
||||
self.rotate_left(node)
|
||||
|
||||
def double_rotate_right(self, node):
|
||||
self.rotate_left(node.getLeft().getLeft())
|
||||
self.rotate_right(node)
|
||||
|
||||
def empty(self):
|
||||
if self.root is None:
|
||||
return True
|
||||
return False
|
||||
|
||||
def preShow(self, curr_node):
|
||||
if curr_node is not None:
|
||||
self.preShow(curr_node.left)
|
||||
print(curr_node.label, end=" ")
|
||||
self.preShow(curr_node.right)
|
||||
|
||||
def preorder(self, curr_node):
|
||||
if curr_node is not None:
|
||||
self.preShow(curr_node.left)
|
||||
self.preShow(curr_node.right)
|
||||
print(curr_node.label, end=" ")
|
||||
|
||||
def getRoot(self):
|
||||
return self.root
|
||||
|
||||
t = AVL()
|
||||
t.insert(1)
|
||||
t.insert(2)
|
||||
t.insert(3)
|
||||
# t.preShow(t.root)
|
||||
# print("\n")
|
||||
# t.insert(4)
|
||||
# t.insert(5)
|
||||
# t.preShow(t.root)
|
||||
# t.preorden(t.root)
|
|
@ -1,3 +0,0 @@
|
|||
arr = [10, 20, 30, 40]
|
||||
arr[1] = 30
|
||||
print(arr)
|
|
@ -1,29 +0,0 @@
|
|||
from __future__ import print_function
|
||||
class FenwickTree:
|
||||
|
||||
def __init__(self, SIZE): # create fenwick tree with size SIZE
|
||||
self.Size = SIZE
|
||||
self.ft = [0 for i in range (0,SIZE)]
|
||||
|
||||
def update(self, i, val): # update data (adding) in index i in O(lg N)
|
||||
while (i < self.Size):
|
||||
self.ft[i] += val
|
||||
i += i & (-i)
|
||||
|
||||
def query(self, i): # query cumulative data from index 0 to i in O(lg N)
|
||||
ret = 0
|
||||
while (i > 0):
|
||||
ret += self.ft[i]
|
||||
i -= i & (-i)
|
||||
return ret
|
||||
|
||||
if __name__ == '__main__':
|
||||
f = FenwickTree(100)
|
||||
f.update(1,20)
|
||||
f.update(4,4)
|
||||
print (f.query(1))
|
||||
print (f.query(3))
|
||||
print (f.query(4))
|
||||
f.update(2,-5)
|
||||
print (f.query(1))
|
||||
print (f.query(3))
|
|
@ -1,91 +0,0 @@
|
|||
from __future__ import print_function
|
||||
import math
|
||||
|
||||
class SegmentTree:
|
||||
|
||||
def __init__(self, N):
|
||||
self.N = N
|
||||
self.st = [0 for i in range(0,4*N)] # approximate the overall size of segment tree with array N
|
||||
self.lazy = [0 for i in range(0,4*N)] # create array to store lazy update
|
||||
self.flag = [0 for i in range(0,4*N)] # flag for lazy update
|
||||
|
||||
def left(self, idx):
|
||||
return idx*2
|
||||
|
||||
def right(self, idx):
|
||||
return idx*2 + 1
|
||||
|
||||
def build(self, idx, l, r, A):
|
||||
if l==r:
|
||||
self.st[idx] = A[l-1]
|
||||
else :
|
||||
mid = (l+r)//2
|
||||
self.build(self.left(idx),l,mid, A)
|
||||
self.build(self.right(idx),mid+1,r, A)
|
||||
self.st[idx] = max(self.st[self.left(idx)] , self.st[self.right(idx)])
|
||||
|
||||
# update with O(lg N) (Normal segment tree without lazy update will take O(Nlg N) for each update)
|
||||
def update(self, idx, l, r, a, b, val): # update(1, 1, N, a, b, v) for update val v to [a,b]
|
||||
if self.flag[idx] == True:
|
||||
self.st[idx] = self.lazy[idx]
|
||||
self.flag[idx] = False
|
||||
if l!=r:
|
||||
self.lazy[self.left(idx)] = self.lazy[idx]
|
||||
self.lazy[self.right(idx)] = self.lazy[idx]
|
||||
self.flag[self.left(idx)] = True
|
||||
self.flag[self.right(idx)] = True
|
||||
|
||||
if r < a or l > b:
|
||||
return True
|
||||
if l >= a and r <= b :
|
||||
self.st[idx] = val
|
||||
if l!=r:
|
||||
self.lazy[self.left(idx)] = val
|
||||
self.lazy[self.right(idx)] = val
|
||||
self.flag[self.left(idx)] = True
|
||||
self.flag[self.right(idx)] = True
|
||||
return True
|
||||
mid = (l+r)//2
|
||||
self.update(self.left(idx),l,mid,a,b,val)
|
||||
self.update(self.right(idx),mid+1,r,a,b,val)
|
||||
self.st[idx] = max(self.st[self.left(idx)] , self.st[self.right(idx)])
|
||||
return True
|
||||
|
||||
# query with O(lg N)
|
||||
def query(self, idx, l, r, a, b): #query(1, 1, N, a, b) for query max of [a,b]
|
||||
if self.flag[idx] == True:
|
||||
self.st[idx] = self.lazy[idx]
|
||||
self.flag[idx] = False
|
||||
if l != r:
|
||||
self.lazy[self.left(idx)] = self.lazy[idx]
|
||||
self.lazy[self.right(idx)] = self.lazy[idx]
|
||||
self.flag[self.left(idx)] = True
|
||||
self.flag[self.right(idx)] = True
|
||||
if r < a or l > b:
|
||||
return -math.inf
|
||||
if l >= a and r <= b:
|
||||
return self.st[idx]
|
||||
mid = (l+r)//2
|
||||
q1 = self.query(self.left(idx),l,mid,a,b)
|
||||
q2 = self.query(self.right(idx),mid+1,r,a,b)
|
||||
return max(q1,q2)
|
||||
|
||||
def showData(self):
|
||||
showList = []
|
||||
for i in range(1,N+1):
|
||||
showList += [self.query(1, 1, self.N, i, i)]
|
||||
print (showList)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
A = [1,2,-4,7,3,-5,6,11,-20,9,14,15,5,2,-8]
|
||||
N = 15
|
||||
segt = SegmentTree(N)
|
||||
segt.build(1,1,N,A)
|
||||
print (segt.query(1,1,N,4,6))
|
||||
print (segt.query(1,1,N,7,11))
|
||||
print (segt.query(1,1,N,7,12))
|
||||
segt.update(1,1,N,1,3,111)
|
||||
print (segt.query(1,1,N,1,15))
|
||||
segt.update(1,1,N,7,8,235)
|
||||
segt.showData()
|
|
@ -1,71 +0,0 @@
|
|||
from __future__ import print_function
|
||||
import math
|
||||
|
||||
class SegmentTree:
|
||||
|
||||
def __init__(self, A):
|
||||
self.N = len(A)
|
||||
self.st = [0] * (4 * self.N) # approximate the overall size of segment tree with array N
|
||||
self.build(1, 0, self.N - 1)
|
||||
|
||||
def left(self, idx):
|
||||
return idx * 2
|
||||
|
||||
def right(self, idx):
|
||||
return idx * 2 + 1
|
||||
|
||||
def build(self, idx, l, r):
|
||||
if l == r:
|
||||
self.st[idx] = A[l]
|
||||
else:
|
||||
mid = (l + r) // 2
|
||||
self.build(self.left(idx), l, mid)
|
||||
self.build(self.right(idx), mid + 1, r)
|
||||
self.st[idx] = max(self.st[self.left(idx)] , self.st[self.right(idx)])
|
||||
|
||||
def update(self, a, b, val):
|
||||
return self.update_recursive(1, 0, self.N - 1, a - 1, b - 1, val)
|
||||
|
||||
def update_recursive(self, idx, l, r, a, b, val): # update(1, 1, N, a, b, v) for update val v to [a,b]
|
||||
if r < a or l > b:
|
||||
return True
|
||||
if l == r :
|
||||
self.st[idx] = val
|
||||
return True
|
||||
mid = (l+r)//2
|
||||
self.update_recursive(self.left(idx), l, mid, a, b, val)
|
||||
self.update_recursive(self.right(idx), mid+1, r, a, b, val)
|
||||
self.st[idx] = max(self.st[self.left(idx)] , self.st[self.right(idx)])
|
||||
return True
|
||||
|
||||
def query(self, a, b):
|
||||
return self.query_recursive(1, 0, self.N - 1, a - 1, b - 1)
|
||||
|
||||
def query_recursive(self, idx, l, r, a, b): #query(1, 1, N, a, b) for query max of [a,b]
|
||||
if r < a or l > b:
|
||||
return -math.inf
|
||||
if l >= a and r <= b:
|
||||
return self.st[idx]
|
||||
mid = (l+r)//2
|
||||
q1 = self.query_recursive(self.left(idx), l, mid, a, b)
|
||||
q2 = self.query_recursive(self.right(idx), mid + 1, r, a, b)
|
||||
return max(q1, q2)
|
||||
|
||||
def showData(self):
|
||||
showList = []
|
||||
for i in range(1,N+1):
|
||||
showList += [self.query(i, i)]
|
||||
print (showList)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
A = [1,2,-4,7,3,-5,6,11,-20,9,14,15,5,2,-8]
|
||||
N = 15
|
||||
segt = SegmentTree(A)
|
||||
print (segt.query(4, 6))
|
||||
print (segt.query(7, 11))
|
||||
print (segt.query(7, 12))
|
||||
segt.update(1,3,111)
|
||||
print (segt.query(1, 15))
|
||||
segt.update(7,8,235)
|
||||
segt.showData()
|
|
@ -1,258 +0,0 @@
|
|||
'''
|
||||
A binary search Tree
|
||||
'''
|
||||
from __future__ import print_function
|
||||
class Node:
|
||||
|
||||
def __init__(self, label, parent):
|
||||
self.label = label
|
||||
self.left = None
|
||||
self.right = None
|
||||
#Added in order to delete a node easier
|
||||
self.parent = parent
|
||||
|
||||
def getLabel(self):
|
||||
return self.label
|
||||
|
||||
def setLabel(self, label):
|
||||
self.label = label
|
||||
|
||||
def getLeft(self):
|
||||
return self.left
|
||||
|
||||
def setLeft(self, left):
|
||||
self.left = left
|
||||
|
||||
def getRight(self):
|
||||
return self.right
|
||||
|
||||
def setRight(self, right):
|
||||
self.right = right
|
||||
|
||||
def getParent(self):
|
||||
return self.parent
|
||||
|
||||
def setParent(self, parent):
|
||||
self.parent = parent
|
||||
|
||||
class BinarySearchTree:
|
||||
|
||||
def __init__(self):
|
||||
self.root = None
|
||||
|
||||
def insert(self, label):
|
||||
# Create a new Node
|
||||
new_node = Node(label, None)
|
||||
# If Tree is empty
|
||||
if self.empty():
|
||||
self.root = new_node
|
||||
else:
|
||||
#If Tree is not empty
|
||||
curr_node = self.root
|
||||
#While we don't get to a leaf
|
||||
while curr_node is not None:
|
||||
#We keep reference of the parent node
|
||||
parent_node = curr_node
|
||||
#If node label is less than current node
|
||||
if new_node.getLabel() < curr_node.getLabel():
|
||||
#We go left
|
||||
curr_node = curr_node.getLeft()
|
||||
else:
|
||||
#Else we go right
|
||||
curr_node = curr_node.getRight()
|
||||
#We insert the new node in a leaf
|
||||
if new_node.getLabel() < parent_node.getLabel():
|
||||
parent_node.setLeft(new_node)
|
||||
else:
|
||||
parent_node.setRight(new_node)
|
||||
#Set parent to the new node
|
||||
new_node.setParent(parent_node)
|
||||
|
||||
def delete(self, label):
|
||||
if (not self.empty()):
|
||||
#Look for the node with that label
|
||||
node = self.getNode(label)
|
||||
#If the node exists
|
||||
if(node is not None):
|
||||
#If it has no children
|
||||
if(node.getLeft() is None and node.getRight() is None):
|
||||
self.__reassignNodes(node, None)
|
||||
node = None
|
||||
#Has only right children
|
||||
elif(node.getLeft() is None and node.getRight() is not None):
|
||||
self.__reassignNodes(node, node.getRight())
|
||||
#Has only left children
|
||||
elif(node.getLeft() is not None and node.getRight() is None):
|
||||
self.__reassignNodes(node, node.getLeft())
|
||||
#Has two children
|
||||
else:
|
||||
#Gets the max value of the left branch
|
||||
tmpNode = self.getMax(node.getLeft())
|
||||
#Deletes the tmpNode
|
||||
self.delete(tmpNode.getLabel())
|
||||
#Assigns the value to the node to delete and keesp tree structure
|
||||
node.setLabel(tmpNode.getLabel())
|
||||
|
||||
def getNode(self, label):
|
||||
curr_node = None
|
||||
#If the tree is not empty
|
||||
if(not self.empty()):
|
||||
#Get tree root
|
||||
curr_node = self.getRoot()
|
||||
#While we don't find the node we look for
|
||||
#I am using lazy evaluation here to avoid NoneType Attribute error
|
||||
while curr_node is not None and curr_node.getLabel() is not label:
|
||||
#If node label is less than current node
|
||||
if label < curr_node.getLabel():
|
||||
#We go left
|
||||
curr_node = curr_node.getLeft()
|
||||
else:
|
||||
#Else we go right
|
||||
curr_node = curr_node.getRight()
|
||||
return curr_node
|
||||
|
||||
def getMax(self, root = None):
|
||||
if(root is not None):
|
||||
curr_node = root
|
||||
else:
|
||||
#We go deep on the right branch
|
||||
curr_node = self.getRoot()
|
||||
if(not self.empty()):
|
||||
while(curr_node.getRight() is not None):
|
||||
curr_node = curr_node.getRight()
|
||||
return curr_node
|
||||
|
||||
def getMin(self, root = None):
|
||||
if(root is not None):
|
||||
curr_node = root
|
||||
else:
|
||||
#We go deep on the left branch
|
||||
curr_node = self.getRoot()
|
||||
if(not self.empty()):
|
||||
curr_node = self.getRoot()
|
||||
while(curr_node.getLeft() is not None):
|
||||
curr_node = curr_node.getLeft()
|
||||
return curr_node
|
||||
|
||||
def empty(self):
|
||||
if self.root is None:
|
||||
return True
|
||||
return False
|
||||
|
||||
def __InOrderTraversal(self, curr_node):
|
||||
nodeList = []
|
||||
if curr_node is not None:
|
||||
nodeList.insert(0, curr_node)
|
||||
nodeList = nodeList + self.__InOrderTraversal(curr_node.getLeft())
|
||||
nodeList = nodeList + self.__InOrderTraversal(curr_node.getRight())
|
||||
return nodeList
|
||||
|
||||
def getRoot(self):
|
||||
return self.root
|
||||
|
||||
def __isRightChildren(self, node):
|
||||
if(node == node.getParent().getRight()):
|
||||
return True
|
||||
return False
|
||||
|
||||
def __reassignNodes(self, node, newChildren):
|
||||
if(newChildren is not None):
|
||||
newChildren.setParent(node.getParent())
|
||||
if(node.getParent() is not None):
|
||||
#If it is the Right Children
|
||||
if(self.__isRightChildren(node)):
|
||||
node.getParent().setRight(newChildren)
|
||||
else:
|
||||
#Else it is the left children
|
||||
node.getParent().setLeft(newChildren)
|
||||
|
||||
#This function traversal the tree. By default it returns an
|
||||
#In order traversal list. You can pass a function to traversal
|
||||
#The tree as needed by client code
|
||||
def traversalTree(self, traversalFunction = None, root = None):
|
||||
if(traversalFunction is None):
|
||||
#Returns a list of nodes in preOrder by default
|
||||
return self.__InOrderTraversal(self.root)
|
||||
else:
|
||||
#Returns a list of nodes in the order that the users wants to
|
||||
return traversalFunction(self.root)
|
||||
|
||||
#Returns an string of all the nodes labels in the list
|
||||
#In Order Traversal
|
||||
def __str__(self):
|
||||
list = self.__InOrderTraversal(self.root)
|
||||
str = ""
|
||||
for x in list:
|
||||
str = str + " " + x.getLabel().__str__()
|
||||
return str
|
||||
|
||||
def InPreOrder(curr_node):
|
||||
nodeList = []
|
||||
if curr_node is not None:
|
||||
nodeList = nodeList + InPreOrder(curr_node.getLeft())
|
||||
nodeList.insert(0, curr_node.getLabel())
|
||||
nodeList = nodeList + InPreOrder(curr_node.getRight())
|
||||
return nodeList
|
||||
|
||||
def testBinarySearchTree():
|
||||
'''
|
||||
Example
|
||||
8
|
||||
/ \
|
||||
3 10
|
||||
/ \ \
|
||||
1 6 14
|
||||
/ \ /
|
||||
4 7 13
|
||||
'''
|
||||
|
||||
'''
|
||||
Example After Deletion
|
||||
7
|
||||
/ \
|
||||
1 4
|
||||
|
||||
'''
|
||||
t = BinarySearchTree()
|
||||
t.insert(8)
|
||||
t.insert(3)
|
||||
t.insert(6)
|
||||
t.insert(1)
|
||||
t.insert(10)
|
||||
t.insert(14)
|
||||
t.insert(13)
|
||||
t.insert(4)
|
||||
t.insert(7)
|
||||
|
||||
#Prints all the elements of the list in order traversal
|
||||
print(t.__str__())
|
||||
|
||||
if(t.getNode(6) is not None):
|
||||
print("The label 6 exists")
|
||||
else:
|
||||
print("The label 6 doesn't exist")
|
||||
|
||||
if(t.getNode(-1) is not None):
|
||||
print("The label -1 exists")
|
||||
else:
|
||||
print("The label -1 doesn't exist")
|
||||
|
||||
if(not t.empty()):
|
||||
print(("Max Value: ", t.getMax().getLabel()))
|
||||
print(("Min Value: ", t.getMin().getLabel()))
|
||||
|
||||
t.delete(13)
|
||||
t.delete(10)
|
||||
t.delete(8)
|
||||
t.delete(3)
|
||||
t.delete(6)
|
||||
t.delete(14)
|
||||
|
||||
#Gets all the elements of the tree In pre order
|
||||
#And it prints them
|
||||
list = t.traversalTree(InPreOrder, t.root)
|
||||
for x in list:
|
||||
print(x)
|
||||
|
||||
if __name__ == "__main__":
|
||||
testBinarySearchTree()
|
|
@ -1,54 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
def printDist(dist, V):
|
||||
print("\nVertex Distance")
|
||||
for i in range(V):
|
||||
if dist[i] != float('inf') :
|
||||
print(i,"\t",int(dist[i]),end = "\t")
|
||||
else:
|
||||
print(i,"\t","INF",end="\t")
|
||||
print()
|
||||
|
||||
def BellmanFord(graph, V, E, src):
|
||||
mdist=[float('inf') for i in range(V)]
|
||||
mdist[src] = 0.0
|
||||
|
||||
for i in range(V-1):
|
||||
for j in range(V):
|
||||
u = graph[j]["src"]
|
||||
v = graph[j]["dst"]
|
||||
w = graph[j]["weight"]
|
||||
|
||||
if mdist[u] != float('inf') and mdist[u] + w < mdist[v]:
|
||||
mdist[v] = mdist[u] + w
|
||||
for j in range(V):
|
||||
u = graph[j]["src"]
|
||||
v = graph[j]["dst"]
|
||||
w = graph[j]["weight"]
|
||||
|
||||
if mdist[u] != float('inf') and mdist[u] + w < mdist[v]:
|
||||
print("Negative cycle found. Solution not possible.")
|
||||
return
|
||||
|
||||
printDist(mdist, V)
|
||||
|
||||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
|
||||
graph = [dict() for j in range(E)]
|
||||
|
||||
for i in range(V):
|
||||
graph[i][i] = 0.0
|
||||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
graph[i] = {"src": src,"dst": dst, "weight": weight}
|
||||
|
||||
gsrc = int(raw_input("\nEnter shortest path source:"))
|
||||
BellmanFord(graph, V, E, gsrc)
|
|
@ -1,67 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
""" Author: OMKAR PATHAK """
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
class Graph():
|
||||
def __init__(self):
|
||||
self.vertex = {}
|
||||
|
||||
# for printing the Graph vertexes
|
||||
def printGraph(self):
|
||||
for i in self.vertex.keys():
|
||||
print(i,' -> ', ' -> '.join([str(j) for j in self.vertex[i]]))
|
||||
|
||||
# for adding the edge beween two vertexes
|
||||
def addEdge(self, fromVertex, toVertex):
|
||||
# check if vertex is already present,
|
||||
if fromVertex in self.vertex.keys():
|
||||
self.vertex[fromVertex].append(toVertex)
|
||||
else:
|
||||
# else make a new vertex
|
||||
self.vertex[fromVertex] = [toVertex]
|
||||
|
||||
def BFS(self, startVertex):
|
||||
# Take a list for stoting already visited vertexes
|
||||
visited = [False] * len(self.vertex)
|
||||
|
||||
# create a list to store all the vertexes for BFS
|
||||
queue = []
|
||||
|
||||
# mark the source node as visited and enqueue it
|
||||
visited[startVertex] = True
|
||||
queue.append(startVertex)
|
||||
|
||||
while queue:
|
||||
startVertex = queue.pop(0)
|
||||
print(startVertex, end = ' ')
|
||||
|
||||
# mark all adjacent nodes as visited and print them
|
||||
for i in self.vertex[startVertex]:
|
||||
if visited[i] == False:
|
||||
queue.append(i)
|
||||
visited[i] = True
|
||||
|
||||
if __name__ == '__main__':
|
||||
g = Graph()
|
||||
g.addEdge(0, 1)
|
||||
g.addEdge(0, 2)
|
||||
g.addEdge(1, 2)
|
||||
g.addEdge(2, 0)
|
||||
g.addEdge(2, 3)
|
||||
g.addEdge(3, 3)
|
||||
|
||||
g.printGraph()
|
||||
print('BFS:')
|
||||
g.BFS(2)
|
||||
|
||||
# OUTPUT:
|
||||
# 0 -> 1 -> 2
|
||||
# 1 -> 2
|
||||
# 2 -> 0 -> 3
|
||||
# 3 -> 3
|
||||
# BFS:
|
||||
# 2 0 3 1
|
|
@ -1,66 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
# encoding=utf8
|
||||
|
||||
""" Author: OMKAR PATHAK """
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
class Graph():
|
||||
def __init__(self):
|
||||
self.vertex = {}
|
||||
|
||||
# for printing the Graph vertexes
|
||||
def printGraph(self):
|
||||
print(self.vertex)
|
||||
for i in self.vertex.keys():
|
||||
print(i,' -> ', ' -> '.join([str(j) for j in self.vertex[i]]))
|
||||
|
||||
# for adding the edge beween two vertexes
|
||||
def addEdge(self, fromVertex, toVertex):
|
||||
# check if vertex is already present,
|
||||
if fromVertex in self.vertex.keys():
|
||||
self.vertex[fromVertex].append(toVertex)
|
||||
else:
|
||||
# else make a new vertex
|
||||
self.vertex[fromVertex] = [toVertex]
|
||||
|
||||
def DFS(self):
|
||||
# visited array for storing already visited nodes
|
||||
visited = [False] * len(self.vertex)
|
||||
|
||||
# call the recursive helper function
|
||||
for i in range(len(self.vertex)):
|
||||
if visited[i] == False:
|
||||
self.DFSRec(i, visited)
|
||||
|
||||
def DFSRec(self, startVertex, visited):
|
||||
# mark start vertex as visited
|
||||
visited[startVertex] = True
|
||||
|
||||
print(startVertex, end = ' ')
|
||||
|
||||
# Recur for all the vertexes that are adjacent to this node
|
||||
for i in self.vertex.keys():
|
||||
if visited[i] == False:
|
||||
self.DFSRec(i, visited)
|
||||
|
||||
if __name__ == '__main__':
|
||||
g = Graph()
|
||||
g.addEdge(0, 1)
|
||||
g.addEdge(0, 2)
|
||||
g.addEdge(1, 2)
|
||||
g.addEdge(2, 0)
|
||||
g.addEdge(2, 3)
|
||||
g.addEdge(3, 3)
|
||||
|
||||
g.printGraph()
|
||||
print('DFS:')
|
||||
g.DFS()
|
||||
|
||||
# OUTPUT:
|
||||
# 0 -> 1 -> 2
|
||||
# 1 -> 2
|
||||
# 2 -> 0 -> 3
|
||||
# 3 -> 3
|
||||
# DFS:
|
||||
# 0 1 2 3
|
|
@ -1,57 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
def printDist(dist, V):
|
||||
print("\nVertex Distance")
|
||||
for i in range(V):
|
||||
if dist[i] != float('inf') :
|
||||
print(i,"\t",int(dist[i]),end = "\t")
|
||||
else:
|
||||
print(i,"\t","INF",end="\t")
|
||||
print()
|
||||
|
||||
def minDist(mdist, vset, V):
|
||||
minVal = float('inf')
|
||||
minInd = -1
|
||||
for i in range(V):
|
||||
if (not vset[i]) and mdist[i] < minVal :
|
||||
minInd = i
|
||||
minVal = mdist[i]
|
||||
return minInd
|
||||
|
||||
def Dijkstra(graph, V, src):
|
||||
mdist=[float('inf') for i in range(V)]
|
||||
vset = [False for i in range(V)]
|
||||
mdist[src] = 0.0;
|
||||
|
||||
for i in range(V-1):
|
||||
u = minDist(mdist, vset, V)
|
||||
vset[u] = True
|
||||
|
||||
for v in range(V):
|
||||
if (not vset[v]) and graph[u][v]!=float('inf') and mdist[u] + graph[u][v] < mdist[v]:
|
||||
mdist[v] = mdist[u] + graph[u][v]
|
||||
|
||||
|
||||
|
||||
printDist(mdist, V)
|
||||
|
||||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
|
||||
graph = [[float('inf') for i in range(V)] for j in range(V)]
|
||||
|
||||
for i in range(V):
|
||||
graph[i][i] = 0.0
|
||||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
graph[src][dst] = weight
|
||||
|
||||
gsrc = int(raw_input("\nEnter shortest path source:"))
|
||||
Dijkstra(graph, V, gsrc)
|
|
@ -1,48 +0,0 @@
|
|||
from __future__ import print_function
|
||||
|
||||
def printDist(dist, V):
|
||||
print("\nThe shortest path matrix using Floyd Warshall algorithm\n")
|
||||
for i in range(V):
|
||||
for j in range(V):
|
||||
if dist[i][j] != float('inf') :
|
||||
print(int(dist[i][j]),end = "\t")
|
||||
else:
|
||||
print("INF",end="\t")
|
||||
print()
|
||||
|
||||
|
||||
|
||||
def FloydWarshall(graph, V):
|
||||
dist=[[float('inf') for i in range(V)] for j in range(V)]
|
||||
|
||||
for i in range(V):
|
||||
for j in range(V):
|
||||
dist[i][j] = graph[i][j]
|
||||
|
||||
for k in range(V):
|
||||
for i in range(V):
|
||||
for j in range(V):
|
||||
if dist[i][k]!=float('inf') and dist[k][j]!=float('inf') and dist[i][k]+dist[k][j] < dist[i][j]:
|
||||
dist[i][j] = dist[i][k] + dist[k][j]
|
||||
|
||||
printDist(dist, V)
|
||||
|
||||
|
||||
|
||||
#MAIN
|
||||
V = int(raw_input("Enter number of vertices: "))
|
||||
E = int(raw_input("Enter number of edges: "))
|
||||
|
||||
graph = [[float('inf') for i in range(V)] for j in range(V)]
|
||||
|
||||
for i in range(V):
|
||||
graph[i][i] = 0.0
|
||||
|
||||
for i in range(E):
|
||||
print("\nEdge ",i+1)
|
||||
src = int(raw_input("Enter source:"))
|
||||
dst = int(raw_input("Enter destination:"))
|
||||
weight = float(raw_input("Enter weight:"))
|
||||
graph[src][dst] = weight
|
||||
|
||||
FloydWarshall(graph, V)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user