Added doctest and more explanation about Dijkstra execution. (#1014)

* Added doctest and more explanation about Dijkstra execution.

* tests were not passing with python2 due to missing __init__.py file at number_theory folder

* Removed the dot at the beginning of the imported modules names because 'python3 -m doctest -v data_structures/hashing/*.py' and 'python3 -m doctest -v data_structures/stacks/*.py' were failing not finding hash_table.py and stack.py modules.

* Moved global code to main scope and added doctest for project euler problems 1 to 14.

* Added test case for negative input.

* Changed N variable to do not use end of line scape because in case there is a space after it the script will break making it much more error prone.

* Added problems description and doctests to the ones that were missing. Limited line length to 79 and executed python black over all scripts.

* Changed the way files are loaded to support pytest call.

* Added __init__.py to problems to make them modules and allow pytest execution.

* Added project_euler folder to test units execution

* Changed 'os.path.split(os.path.realpath(__file__))' to 'os.path.dirname()'
This commit is contained in:
Bruno Simas Hadlich 2019-07-16 20:09:53 -03:00 committed by cclauss
parent 2fb3beeaf1
commit 267b5eff40
100 changed files with 2621 additions and 1438 deletions

View File

@ -26,6 +26,7 @@ script:
matrix
networking_flow
other
project_euler
searches
sorts
strings

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from .hash_table import HashTable
from hash_table import HashTable
from number_theory.prime_numbers import next_prime, check_prime

View File

@ -1,4 +1,4 @@
from .hash_table import HashTable
from hash_table import HashTable
from collections import deque

View File

@ -1,6 +1,6 @@
#!/usr/bin/env python3
from .hash_table import HashTable
from hash_table import HashTable
class QuadraticProbing(HashTable):

View File

@ -2,7 +2,7 @@ from __future__ import print_function
from __future__ import absolute_import
import string
from .Stack import Stack
from stack import Stack
__author__ = 'Omkar Pathak'

View File

@ -1,24 +1,50 @@
"""pseudo-code"""
"""
DIJKSTRA(graph G, start vertex s,destination vertex d):
// all nodes initially unexplored
let H = min heap data structure, initialized with 0 and s [here 0 indicates the distance from start vertex]
while H is non-empty:
remove the first node and cost of H, call it U and cost
if U is not explored
mark U as explored
if U is d:
return cost // total cost from start to destination vertex
for each edge(U, V): c=cost of edge(u,V) // for V in graph[U]
if V unexplored:
next=cost+c
add next,V to H (at the end)
DIJKSTRA(graph G, start vertex s, destination vertex d):
//all nodes initially unexplored
1 - let H = min heap data structure, initialized with 0 and s [here 0 indicates
the distance from start vertex s]
2 - while H is non-empty:
3 - remove the first node and cost of H, call it U and cost
4 - if U has been previously explored:
5 - go to the while loop, line 2 //Once a node is explored there is no need
to make it again
6 - mark U as explored
7 - if U is d:
8 - return cost // total cost from start to destination vertex
9 - for each edge(U, V): c=cost of edge(U,V) // for V in graph[U]
10 - if V explored:
11 - go to next V in line 9
12 - total_cost = cost + c
13 - add (total_cost,V) to H
You can think at cost as a distance where Dijkstra finds the shortest distance
between vertexes s and v in a graph G. The use of a min heap as H guarantees
that if a vertex has already been explored there will be no other path with
shortest distance, that happens because heapq.heappop will always return the
next vertex with the shortest distance, considering that the heap stores not
only the distance between previous vertex and current vertex but the entire
distance between each vertex that makes up the path from start vertex to target
vertex.
"""
import heapq
def dijkstra(graph, start, end):
"""Return the cost of the shortest path between vertexes start and end.
>>> dijkstra(G, "E", "C")
6
>>> dijkstra(G2, "E", "F")
3
>>> dijkstra(G3, "E", "F")
3
"""
heap = [(0, start)] # cost from start node,end node
visited = set()
while heap:
@ -28,20 +54,65 @@ def dijkstra(graph, start, end):
visited.add(u)
if u == end:
return cost
for v, c in G[u]:
for v, c in graph[u]:
if v in visited:
continue
next = cost + c
heapq.heappush(heap, (next, v))
return (-1, -1)
return -1
G = {'A': [['B', 2], ['C', 5]],
'B': [['A', 2], ['D', 3], ['E', 1]],
'C': [['A', 5], ['F', 3]],
'D': [['B', 3]],
'E': [['B', 1], ['F', 3]],
'F': [['C', 3], ['E', 3]]}
G = {
"A": [["B", 2], ["C", 5]],
"B": [["A", 2], ["D", 3], ["E", 1], ["F", 1]],
"C": [["A", 5], ["F", 3]],
"D": [["B", 3]],
"E": [["B", 4], ["F", 3]],
"F": [["C", 3], ["E", 3]],
}
shortDistance = dijkstra(G, 'E', 'C')
print(shortDistance)
"""
Layout of G2:
E -- 1 --> B -- 1 --> C -- 1 --> D -- 1 --> F
\ /\
\ ||
----------------- 3 --------------------
"""
G2 = {
"B": [["C", 1]],
"C": [["D", 1]],
"D": [["F", 1]],
"E": [["B", 1], ["F", 3]],
"F": [],
}
"""
Layout of G3:
E -- 1 --> B -- 1 --> C -- 1 --> D -- 1 --> F
\ /\
\ ||
-------- 2 ---------> G ------- 1 ------
"""
G3 = {
"B": [["C", 1]],
"C": [["D", 1]],
"D": [["F", 1]],
"E": [["B", 1], ["G", 2]],
"F": [],
"G": [["F", 1]],
}
shortDistance = dijkstra(G, "E", "C")
print(shortDistance) # E -- 3 --> F -- 3 --> C == 6
shortDistance = dijkstra(G2, "E", "F")
print(shortDistance) # E -- 3 --> F == 3
shortDistance = dijkstra(G3, "E", "F")
print(shortDistance) # E -- 2 --> G -- 1 --> F == 3
if __name__ == "__main__":
import doctest
doctest.testmod()

View File

View File

@ -1,13 +1,34 @@
'''
"""
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
raw_input # Python 2
except NameError:
raw_input = input # Python 3
n = int(raw_input().strip())
print(sum([e for e in range(3, n) if e % 3 == 0 or e % 5 == 0]))
def solution(n):
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
>>> solution(-7)
0
"""
return sum([e for e in range(3, n) if e % 3 == 0 or e % 5 == 0])
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,20 +1,39 @@
'''
"""
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
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)
def solution(n):
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
"""
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
return sum
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,50 +1,66 @@
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.
'''
"""
from __future__ import print_function
try:
raw_input # Python 2
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);
def solution(n):
"""
This solution is based on the pattern that the successive numbers in the
series follow: 0+3,+2,+1,+3,+1,+2,+3.
Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
"""
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
return sum
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,4 +1,30 @@
def mulitples(limit):
"""
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
def solution(n):
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
"""
xmulti = []
zmulti = []
z = 3
@ -6,7 +32,7 @@ def mulitples(limit):
temp = 1
while True:
result = z * temp
if (result < limit):
if result < n:
zmulti.append(result)
temp += 1
else:
@ -14,17 +40,14 @@ def mulitples(limit):
break
while True:
result = x * temp
if (result < limit):
if result < n:
xmulti.append(result)
temp += 1
else:
break
collection = list(set(xmulti+zmulti))
return (sum(collection))
print (mulitples(1000))
collection = list(set(xmulti + zmulti))
return sum(collection)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,16 +1,34 @@
'''
"""
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:
input = raw_input #python3
raw_input # Python 2
except NameError:
pass #python 2
raw_input = input # Python 3
"""A straightforward pythonic solution using list comprehension"""
n = int(input().strip())
print(sum([i for i in range(n) if i%3==0 or i%5==0]))
def solution(n):
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
"""
return sum([i for i in range(n) if i % 3 == 0 or i % 5 == 0])
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,9 +1,40 @@
a = 3
result = 0
while a < 1000:
if(a % 3 == 0 or a % 5 == 0):
result += a
elif(a % 15 == 0):
result -= a
a += 1
print(result)
"""
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
def solution(n):
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution(3)
0
>>> solution(4)
3
>>> solution(10)
23
>>> solution(600)
83700
"""
a = 3
result = 0
while a < n:
if a % 3 == 0 or a % 5 == 0:
result += a
elif a % 15 == 0:
result -= a
a += 1
return result
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,24 +1,47 @@
'''
"""
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.
'''
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
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%2 == 0:
sum+=j
i , j = j, i+j
print(sum)
def solution(n):
"""Returns the sum of all fibonacci sequence even elements that are lower
or equals to n.
>>> solution(10)
10
>>> solution(15)
10
>>> solution(2)
2
>>> solution(1)
0
>>> solution(34)
44
"""
i = 1
j = 2
sum = 0
while j <= n:
if j % 2 == 0:
sum += j
i, j = j, i + j
return sum
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,15 +1,45 @@
def fib(n):
"""
Returns a list of all the even terms in the Fibonacci sequence that are less than n.
"""
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
def solution(n):
"""Returns the sum of all fibonacci sequence even elements that are lower
or equals to n.
>>> solution(10)
[2, 8]
>>> solution(15)
[2, 8]
>>> solution(2)
[2]
>>> solution(1)
[]
>>> solution(34)
[2, 8, 34]
"""
ls = []
a, b = 0, 1
while b < n:
while b <= n:
if b % 2 == 0:
ls.append(b)
a, b = b, a+b
a, b = b, a + b
return ls
if __name__ == '__main__':
n = int(input("Enter max number: ").strip())
print(sum(fib(n)))
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,18 +1,47 @@
'''
"""
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(input())
a=0
b=2
count=0
while 4*b+a<n:
a, b = b, 4*b+a
count+= a
print(count+b)
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
def solution(n):
"""Returns the sum of all fibonacci sequence even elements that are lower
or equals to n.
>>> solution(10)
10
>>> solution(15)
10
>>> solution(2)
2
>>> solution(1)
0
>>> solution(34)
44
"""
if n <= 1:
return 0
a = 0
b = 2
count = 0
while 4 * b + a <= n:
a, b = b, 4 * b + a
count += a
return count + b
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,13 +1,47 @@
"""
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
import math
from decimal import *
getcontext().prec = 100
phi = (Decimal(5) ** Decimal(0.5) + 1) / Decimal(2)
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
n = Decimal(int(input()) - 1)
index = (math.floor(math.log(n * (phi + 2), phi) - 1) // 3) * 3 + 2
num = round(phi ** Decimal(index + 1)) / (phi + 2)
sum = num // 2
def solution(n):
"""Returns the sum of all fibonacci sequence even elements that are lower
or equals to n.
>>> solution(10)
10
>>> solution(15)
10
>>> solution(2)
2
>>> solution(1)
0
>>> solution(34)
44
"""
getcontext().prec = 100
phi = (Decimal(5) ** Decimal(0.5) + 1) / Decimal(2)
print(int(sum))
index = (math.floor(math.log(n * (phi + 2), phi) - 1) // 3) * 3 + 2
num = Decimal(round(phi ** Decimal(index + 1))) / (phi + 2)
sum = num // 2
return int(sum)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,39 +1,61 @@
'''
"""
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
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
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def isprime(no):
if(no==2):
if no == 2:
return True
elif (no%2==0):
elif no % 2 == 0:
return False
sq = int(math.sqrt(no))+1
for i in range(3,sq,2):
if(no%i==0):
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(input())
if(isprime(n)):
print(n)
else:
while (n%2==0):
n=n/2
if(isprime(n)):
print(n)
def solution(n):
"""Returns the largest prime factor of a given number n.
>>> solution(13195)
29
>>> solution(10)
5
>>> solution(17)
17
"""
maxNumber = 0
if isprime(n):
return 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)
while n % 2 == 0:
n = n / 2
if isprime(n):
return int(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
return maxNumber
return int(sum)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,18 +1,40 @@
'''
"""
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.
'''
The prime factors of 13195 are 5,7,13 and 29. What is the largest prime factor
of a given number N?
from __future__ import print_function
n=int(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)
e.g. for 10, largest prime factor = 5. For 17, largest prime factor = 17.
"""
from __future__ import print_function, division
import math
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the largest prime factor of a given number n.
>>> solution(13195)
29
>>> solution(10)
5
>>> solution(17)
17
"""
prime = 1
i = 2
while i * i <= n:
while n % i == 0:
prime = i
n //= i
i += 1
if n > 1:
prime = n
return int(prime)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,29 +1,50 @@
'''
"""
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.
'''
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(input("limit? "))
# fetchs the next number
for number in range(limit-1,10000,-1):
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
# converts number into string.
strNumber = str(number)
# checks whether 'strNumber' is a palindrome.
if(strNumber == strNumber[::-1]):
def solution(n):
"""Returns the largest palindrome made from the product of two 3-digit
numbers which is less than n.
>>> solution(20000)
19591
>>> solution(30000)
29992
>>> solution(40000)
39893
"""
# fetchs the next number
for number in range(n - 1, 10000, -1):
divisor = 999
# converts number into string.
strNumber = str(number)
# 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)):
# checks whether 'strNumber' is a palindrome.
if strNumber == strNumber[::-1]:
print(number)
exit(0)
divisor = 999
divisor -=1
# 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(int(number / divisor))) == 3
):
return number
divisor -= 1
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,17 +1,38 @@
'''
"""
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.
'''
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
n = int(input().strip())
answer = 0
for i in range(999,99,-1): #3 digit nimbers range from 999 down to 100
for j in range(999,99,-1):
t = str(i*j)
if t == t[::-1] and i*j < n:
answer = max(answer,i*j)
print(answer)
exit(0)
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the largest palindrome made from the product of two 3-digit
numbers which is less than n.
>>> solution(20000)
19591
>>> solution(30000)
29992
>>> solution(40000)
39893
"""
answer = 0
for i in range(999, 99, -1): # 3 digit nimbers range from 999 down to 100
for j in range(999, 99, -1):
t = str(i * j)
if t == t[::-1] and i * j < n:
answer = max(answer, i * j)
return answer
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,21 +1,46 @@
'''
"""
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?
'''
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(input())
i = 0
while 1:
i+=n*(n-1)
nfound=0
for j in range(2,n):
if (i%j != 0):
nfound=1
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the smallest positive number that is evenly divisible(divisible
with no remainder) by all of the numbers from 1 to n.
>>> solution(10)
2520
>>> solution(15)
360360
>>> solution(20)
232792560
>>> solution(22)
232792560
"""
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
return i
break
if(nfound==0):
if(i==0):
i=1
print(i)
break
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,20 +1,50 @@
#!/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?
'''
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
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
""" Euclidean GCD Algorithm """
def gcd(x,y):
return x if y==0 else gcd(y,x%y)
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(input())
g=1
for i in range(1,n+1):
g=lcm(g,i)
print(g)
def lcm(x, y):
return (x * y) // gcd(x, y)
def solution(n):
"""Returns the smallest positive number that is evenly divisible(divisible
with no remainder) by all of the numbers from 1 to n.
>>> solution(10)
2520
>>> solution(15)
360360
>>> solution(20)
232792560
>>> solution(22)
232792560
"""
g = 1
for i in range(1, n + 1):
g = lcm(g, i)
return g
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,20 +1,48 @@
# -*- 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.
'''
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(input())
for i in range(1,n+1):
suma += i**2
sumb += i
sum = sumb**2 - suma
print(sum)
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the difference between the sum of the squares of the first n
natural numbers and the square of the sum.
>>> solution(10)
2640
>>> solution(15)
13160
>>> solution(20)
41230
>>> solution(50)
1582700
"""
suma = 0
sumb = 0
for i in range(1, n + 1):
suma += i ** 2
sumb += i
sum = sumb ** 2 - suma
return sum
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,16 +1,45 @@
# -*- 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.
'''
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(input())
suma = n*(n+1)/2
suma **= 2
sumb = n*(n+1)*(2*n+1)/6
print(suma-sumb)
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the difference between the sum of the squares of the first n
natural numbers and the square of the sum.
>>> solution(10)
2640
>>> solution(15)
13160
>>> solution(20)
41230
>>> solution(50)
1582700
"""
suma = n * (n + 1) / 2
suma **= 2
sumb = n * (n + 1) * (2 * n + 1) / 6
return int(suma - sumb)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,20 +1,45 @@
'''
# -*- 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.
'''
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
import math
def problem6(number=100):
sum_of_squares = sum([i*i for i in range(1,number+1)])
square_of_sum = int(math.pow(sum(range(1,number+1)),2))
return square_of_sum - sum_of_squares
def main():
print(problem6())
if __name__ == '__main__':
main()
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""Returns the difference between the sum of the squares of the first n
natural numbers and the square of the sum.
>>> solution(10)
2640
>>> solution(15)
13160
>>> solution(20)
41230
>>> solution(50)
1582700
"""
sum_of_squares = sum([i * i for i in range(1, n + 1)])
square_of_sum = int(math.pow(sum(range(1, n + 1)), 2))
return square_of_sum - sum_of_squares
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,30 +1,61 @@
'''
# -*- coding: utf-8 -*-
"""
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?
'''
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
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def isprime(n):
if (n==2):
if n == 2:
return True
elif (n%2==0):
elif n % 2 == 0:
return False
else:
sq = int(sqrt(n))+1
for i in range(3,sq,2):
if(n%i==0):
sq = int(sqrt(n)) + 1
for i in range(3, sq, 2):
if n % i == 0:
return False
return True
n = int(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)
def solution(n):
"""Returns the n-th prime number.
>>> solution(6)
13
>>> solution(1)
2
>>> solution(3)
5
>>> solution(20)
71
>>> solution(50)
229
>>> solution(100)
541
"""
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
return j
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,16 +1,53 @@
# 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?
# -*- coding: utf-8 -*-
"""
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
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def isprime(number):
for i in range(2,int(number**0.5)+1):
if number%i==0:
return False
return True
n = int(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])
for i in range(2, int(number ** 0.5) + 1):
if number % i == 0:
return False
return True
def solution(n):
"""Returns the n-th prime number.
>>> solution(6)
13
>>> solution(1)
2
>>> solution(3)
5
>>> solution(20)
71
>>> solution(50)
229
>>> solution(100)
541
"""
primes = []
num = 2
while len(primes) < n:
if isprime(num):
primes.append(num)
num += 1
else:
num += 1
return primes[len(primes) - 1]
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,28 +1,53 @@
'''
# -*- coding: utf-8 -*-
"""
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?
'''
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 Python.Math import PrimeCheck
import math
import itertools
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def primeCheck(number):
if number % 2 == 0 and number > 2:
return False
return all(number % i for i in range(3, int(math.sqrt(number)) + 1, 2))
def prime_generator():
num = 2
while True:
if primeCheck(num):
yield num
num+=1
def main():
n = int(input('Enter The N\'th Prime Number You Want To Get: ')) # Ask For The N'th Prime Number Wanted
print(next(itertools.islice(prime_generator(),n-1,n)))
num += 1
if __name__ == '__main__':
main()
def solution(n):
"""Returns the n-th prime number.
>>> solution(6)
13
>>> solution(1)
2
>>> solution(3)
5
>>> solution(20)
71
>>> solution(50)
229
>>> solution(100)
541
"""
return next(itertools.islice(prime_generator(), n - 1, n))
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,15 +1,72 @@
# -*- coding: utf-8 -*-
"""
The four adjacent digits in the 1000-digit number that have the greatest
product are 9 × 9 × 8 × 9 = 5832.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Find the thirteen adjacent digits in the 1000-digit number that have the
greatest product. What is the value of this product?
"""
import sys
def main():
LargestProduct = -sys.maxsize-1
number=input().strip()
for i in range(len(number)-12):
product=1
N = """73167176531330624919225119674426574742355349194934\
96983520312774506326239578318016984801869478851843\
85861560789112949495459501737958331952853208805511\
12540698747158523863050715693290963295227443043557\
66896648950445244523161731856403098711121722383113\
62229893423380308135336276614282806444486645238749\
30358907296290491560440772390713810515859307960866\
70172427121883998797908792274921901699720888093776\
65727333001053367881220235421809751254540594752243\
52584907711670556013604839586446706324415722155397\
53697817977846174064955149290862569321978468622482\
83972241375657056057490261407972968652414535100474\
82166370484403199890008895243450658541227588666881\
16427171479924442928230863465674813919123162824586\
17866458359124566529476545682848912883142607690042\
24219022671055626321111109370544217506941658960408\
07198403850962455444362981230987879927244284909188\
84580156166097919133875499200524063689912560717606\
05886116467109405077541002256983155200055935729725\
71636269561882670428252483600823257530420752963450"""
def solution(n):
"""Find the thirteen adjacent digits in the 1000-digit number n that have
the greatest product and returns it.
>>> solution(N)
23514624000
"""
LargestProduct = -sys.maxsize - 1
for i in range(len(n) - 12):
product = 1
for j in range(13):
product *= int(number[i+j])
product *= int(n[i + j])
if product > LargestProduct:
LargestProduct = product
print(LargestProduct)
return LargestProduct
if __name__ == '__main__':
main()
if __name__ == "__main__":
print(solution(N))

View File

@ -1,8 +1,73 @@
# -*- coding: utf-8 -*-
"""
The four adjacent digits in the 1000-digit number that have the greatest
product are 9 × 9 × 8 × 9 = 5832.
73167176531330624919225119674426574742355349194934
96983520312774506326239578318016984801869478851843
85861560789112949495459501737958331952853208805511
12540698747158523863050715693290963295227443043557
66896648950445244523161731856403098711121722383113
62229893423380308135336276614282806444486645238749
30358907296290491560440772390713810515859307960866
70172427121883998797908792274921901699720888093776
65727333001053367881220235421809751254540594752243
52584907711670556013604839586446706324415722155397
53697817977846174064955149290862569321978468622482
83972241375657056057490261407972968652414535100474
82166370484403199890008895243450658541227588666881
16427171479924442928230863465674813919123162824586
17866458359124566529476545682848912883142607690042
24219022671055626321111109370544217506941658960408
07198403850962455444362981230987879927244284909188
84580156166097919133875499200524063689912560717606
05886116467109405077541002256983155200055935729725
71636269561882670428252483600823257530420752963450
Find the thirteen adjacent digits in the 1000-digit number that have the
greatest product. What is the value of this product?
"""
from functools import reduce
def main():
number=input().strip()
print(max([reduce(lambda x,y: int(x)*int(y),number[i:i+13]) for i in range(len(number)-12)]))
if __name__ == '__main__':
main()
N = (
"73167176531330624919225119674426574742355349194934"
"96983520312774506326239578318016984801869478851843"
"85861560789112949495459501737958331952853208805511"
"12540698747158523863050715693290963295227443043557"
"66896648950445244523161731856403098711121722383113"
"62229893423380308135336276614282806444486645238749"
"30358907296290491560440772390713810515859307960866"
"70172427121883998797908792274921901699720888093776"
"65727333001053367881220235421809751254540594752243"
"52584907711670556013604839586446706324415722155397"
"53697817977846174064955149290862569321978468622482"
"83972241375657056057490261407972968652414535100474"
"82166370484403199890008895243450658541227588666881"
"16427171479924442928230863465674813919123162824586"
"17866458359124566529476545682848912883142607690042"
"24219022671055626321111109370544217506941658960408"
"07198403850962455444362981230987879927244284909188"
"84580156166097919133875499200524063689912560717606"
"05886116467109405077541002256983155200055935729725"
"71636269561882670428252483600823257530420752963450"
)
def solution(n):
"""Find the thirteen adjacent digits in the 1000-digit number n that have
the greatest product and returns it.
>>> solution(N)
23514624000
"""
return max(
[
reduce(lambda x, y: int(x) * int(y), n[i : i + 13])
for i in range(len(n) - 12)
]
)
if __name__ == "__main__":
print(solution(str(N)))

View File

View File

@ -1,15 +1,36 @@
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
"""
Problem Statement:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
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
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
from __future__ import print_function
def solution():
"""
Returns the product of a,b,c which are Pythagorean Triplet that satisfies
the following:
1. a < b < c
2. a**2 + b**2 = c**2
3. a + b + c = 1000
>>> solution()
31875000
"""
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:
return a * b * c
break
if __name__ == "__main__":
print("Please Wait...")
print(solution())

View File

@ -1,18 +1,44 @@
"""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
"""
Problem Statement:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
product=-1
d=0
N = int(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)
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
from __future__ import print_function
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def solution(n):
"""
Return the product of a,b,c which are Pythagorean Triplet that satisfies
the following:
1. a < b < c
2. a**2 + b**2 = c**2
3. a + b + c = 1000
>>> solution(1000)
31875000
"""
product = -1
d = 0
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
return product
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,6 +1,37 @@
def main():
print([a*b*c for a in range(1,999) for b in range(a,999) for c in range(b,999)
if (a*a+b*b==c*c) and (a+b+c==1000 ) ][0])
if __name__ == '__main__':
main()
"""
Problem Statement:
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
from __future__ import print_function
def solution():
"""
Returns the product of a,b,c which are Pythagorean Triplet that satisfies
the following:
1. a**2 + b**2 = c**2
2. a + b + c = 1000
>>> solution()
31875000
"""
return [
a * b * c
for a in range(1, 999)
for b in range(a, 999)
for c in range(b, 999)
if (a * a + b * b == c * c) and (a + b + c == 1000)
][0]
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,38 +1,60 @@
"""
Problem Statement:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
from __future__ import print_function
from math import sqrt
try:
xrange #Python 2
raw_input # Python 2
except NameError:
xrange = range #Python 3
raw_input = input # Python 3
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
for i in xrange(2, int(sqrt(n)) + 1):
if n % i == 0:
return False
return True
return True
def sum_of_primes(n):
if n > 2:
sumOfPrimes = 2
else:
return 0
if n > 2:
sumOfPrimes = 2
else:
return 0
for i in xrange(3, n, 2):
if is_prime(i):
sumOfPrimes += i
for i in xrange(3, n, 2):
if is_prime(i):
sumOfPrimes += i
return sumOfPrimes
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.')
def solution(n):
"""Returns the sum of all the primes below n.
>>> solution(2000000)
142913828922
>>> solution(1000)
76127
>>> solution(5000)
1548136
>>> solution(10000)
5736396
>>> solution(7)
10
"""
return sum_of_primes(n)
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

@ -1,22 +1,49 @@
#from Python.Math import prime_generator
import math
from itertools import takewhile
"""
Problem Statement:
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
"""
from __future__ import print_function
import math
from itertools import takewhile
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def primeCheck(number):
if number % 2 == 0 and number > 2:
return False
return all(number % i for i in range(3, int(math.sqrt(number)) + 1, 2))
def prime_generator():
num = 2
while True:
if primeCheck(num):
yield num
num+=1
def main():
n = int(input('Enter The upper limit of prime numbers: '))
print(sum(takewhile(lambda x: x < n,prime_generator())))
num += 1
def solution(n):
"""Returns the sum of all the primes below n.
if __name__ == '__main__':
main()
>>> solution(2000000)
142913828922
>>> solution(1000)
76127
>>> solution(5000)
1548136
>>> solution(10000)
5736396
>>> solution(7)
10
"""
return sum(takewhile(lambda x: x < n, prime_generator()))
if __name__ == "__main__":
print(solution(int(raw_input().strip())))

View File

View File

@ -1,6 +1,6 @@
from __future__ import print_function
'''
What is the greatest product of four adjacent numbers (horizontally, vertically, or diagonally) in this 20x20 array?
"""
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
@ -22,47 +22,78 @@ What is the greatest product of four adjacent numbers (horizontally, vertically,
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
'''
"""
from __future__ import print_function
import os
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 2
xrange = range # Python 2
def largest_product(grid):
nColumns = len(grid[0])
nRows = len(grid)
nColumns = len(grid[0])
nRows = len(grid)
largest = 0
lrDiagProduct = 0
rlDiagProduct = 0
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]
# 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]
# 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]
# 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
maxProduct = max(
vertProduct, horzProduct, lrDiagProduct, rlDiagProduct
)
if maxProduct > largest:
largest = maxProduct
return largest
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))]
def solution():
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution()
70600674
"""
grid = []
with open(os.path.dirname(__file__) + "/grid.txt") as file:
for line in file:
grid.append(line.strip("\n").split(" "))
print(largest_product(grid))
grid = [[int(i) for i in grid[j]] for j in xrange(len(grid))]
return largest_product(grid)
if __name__ == "__main__":
print(solution())

View File

@ -1,39 +1,90 @@
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()])
"""
What is the greatest product of four adjacent numbers (horizontally,
vertically, or diagonally) in this 20x20 array?
maximum = 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
"""
# 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
from __future__ import print_function
import os
# 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
try:
xrange # Python 2
except NameError:
xrange = range # Python 2
#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()
def solution():
"""Returns the sum of all the multiples of 3 or 5 below n.
>>> solution()
70600674
"""
with open(os.path.dirname(__file__) + "/grid.txt") as f:
l = []
for i in xrange(20):
l.append([int(x) for x in f.readline().split()])
maximum = 0
# right
for i in xrange(20):
for j in xrange(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 xrange(17):
for j in xrange(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 xrange(17):
for j in xrange(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 xrange(17):
for j in xrange(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
return maximum
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,9 +1,9 @@
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:
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, ...
@ -18,31 +18,48 @@ Let us list the factors of the first seven triangle numbers:
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?
'''
What is the value of the first triangle number to have over five hundred
divisors?
"""
from __future__ import print_function
from math import sqrt
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
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
#check if n is perfect square
if n**0.5 == int(n**0.5):
nDivisors -= 1
return nDivisors
nDivisors = 0
for i in xrange(1, int(sqrt(n)) + 1):
if n % i == 0:
nDivisors += 2
# check if n is perfect square
if n ** 0.5 == int(n ** 0.5):
nDivisors -= 1
return nDivisors
tNum = 1
i = 1
while True:
i += 1
tNum += i
def solution():
"""Returns the value of the first triangle number to have over five hundred
divisors.
>>> solution()
76576500
"""
tNum = 1
i = 1
if count_divisors(tNum) > 500:
break
while True:
i += 1
tNum += i
print(tNum)
if count_divisors(tNum) > 500:
break
return tNum
if __name__ == "__main__":
print(solution())

View File

@ -1,8 +1,51 @@
def triangle_number_generator():
for n in range(1,1000000):
yield n*(n+1)//2
def count_divisors(n):
return sum([2 for i in range(1,int(n**0.5)+1) if n%i==0 and i*i != n])
"""
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:
print(next(i for i in triangle_number_generator() if count_divisors(i) > 500))
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?
"""
from __future__ import print_function
def triangle_number_generator():
for n in range(1, 1000000):
yield n * (n + 1) // 2
def count_divisors(n):
return sum(
[2 for i in range(1, int(n ** 0.5) + 1) if n % i == 0 and i * i != n]
)
def solution():
"""Returns the value of the first triangle number to have over five hundred
divisors.
>>> solution()
76576500
"""
return next(
i for i in triangle_number_generator() if count_divisors(i) > 500
)
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,14 +1,36 @@
'''
"""
Problem Statement:
Work out the first ten digits of the sum of the N 50-digit numbers.
'''
Work out the first ten digits of the sum of the following one-hundred 50-digit
numbers.
"""
from __future__ import print_function
import os
n = int(input().strip())
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
array = []
for i in range(n):
array.append(int(input().strip()))
print(str(sum(array))[:10])
def solution(array):
"""Returns the first ten digits of the sum of the array elements.
>>> sum = 0
>>> array = []
>>> with open(os.path.dirname(__file__) + "/num.txt","r") as f:
... for line in f:
... array.append(int(line))
...
>>> solution(array)
'5537376230'
"""
return str(sum(array))[:10]
if __name__ == "__main__":
n = int(input().strip())
array = []
for i in range(n):
array.append(int(input().strip()))
print(solution(array))

View File

@ -1,5 +0,0 @@
sum = 0
with open("num.txt",'r') as f:
for line in f:
sum += int(line)
print(str(sum)[:10])

View File

View File

@ -1,21 +1,73 @@
# -*- coding: utf-8 -*-
"""
Problem Statement:
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
It can be seen that this sequence (starting at 13 and finishing at 1) contains
10 terms. Although it has not been proved yet (Collatz Problem), it is thought
that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
"""
from __future__ import print_function
largest_number = 0
pre_counter = 0
for input1 in range(750000,1000000):
counter = 1
number = input1
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
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
def solution(n):
"""Returns the number under n that generates the longest sequence using the
formula:
n n/2 (n is even)
n 3n + 1 (n is odd)
>>> solution(1000000)
{'counter': 525, 'largest_number': 837799}
>>> solution(200)
{'counter': 125, 'largest_number': 171}
>>> solution(5000)
{'counter': 238, 'largest_number': 3711}
>>> solution(15000)
{'counter': 276, 'largest_number': 13255}
"""
largest_number = 0
pre_counter = 0
print(('Largest Number:',largest_number,'->',pre_counter,'digits'))
for input1 in range(n):
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
return {"counter": pre_counter, "largest_number": largest_number}
if __name__ == "__main__":
result = solution(int(raw_input().strip()))
print(
(
"Largest Number:",
result["largest_number"],
"->",
result["counter"],
"digits",
)
)

View File

@ -1,16 +1,69 @@
def collatz_sequence(n):
"""Collatz conjecture: start with any positive integer n.Next termis obtained from the previous term as follows:
if the previous term is even, the next term is one half the previous term.
If the previous term is odd, the next term is 3 times the previous term plus 1.
The conjecture states the sequence will always reach 1 regaardess of starting n."""
sequence = [n]
while n != 1:
if n % 2 == 0:# even
n //= 2
else:
n = 3*n +1
sequence.append(n)
return sequence
# -*- coding: utf-8 -*-
"""
Collatz conjecture: start with any positive integer n. Next term obtained from
the previous term as follows:
answer = max([(len(collatz_sequence(i)), i) for i in range(1,1000000)])
print("Longest Collatz sequence under one million is %d with length %d" % (answer[1],answer[0]))
If the previous term is even, the next term is one half the previous term.
If the previous term is odd, the next term is 3 times the previous term plus 1.
The conjecture states the sequence will always reach 1 regardless of starting
n.
Problem Statement:
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
It can be seen that this sequence (starting at 13 and finishing at 1) contains
10 terms. Although it has not been proved yet (Collatz Problem), it is thought
that all starting numbers finish at 1.
Which starting number, under one million, produces the longest chain?
"""
from __future__ import print_function
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def collatz_sequence(n):
"""Returns the Collatz sequence for n."""
sequence = [n]
while n != 1:
if n % 2 == 0:
n //= 2
else:
n = 3 * n + 1
sequence.append(n)
return sequence
def solution(n):
"""Returns the number under n that generates the longest Collatz sequence.
>>> solution(1000000)
{'counter': 525, 'largest_number': 837799}
>>> solution(200)
{'counter': 125, 'largest_number': 171}
>>> solution(5000)
{'counter': 238, 'largest_number': 3711}
>>> solution(15000)
{'counter': 276, 'largest_number': 13255}
"""
result = max([(len(collatz_sequence(i)), i) for i in range(1, n)])
return {"counter": result[0], "largest_number": result[1]}
if __name__ == "__main__":
result = solution(int(raw_input().strip()))
print(
"Longest Collatz sequence under one million is %d with length %d"
% (result["largest_number"], result["counter"])
)

View File

View File

@ -1,20 +1,57 @@
from __future__ import print_function
"""
Starting in the top left corner of a 2×2 grid, and only being able to move to
the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
"""
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
"""
Returns the number of paths possible in a n x n grid starting at top left
corner going to bottom right corner and being able to move right and down
only.
return factorial(n)/(factorial(k)*factorial(n-k))
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 50
1.008913445455642e+29
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 25
126410606437752.0
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 23
8233430727600.0
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 15
155117520.0
bruno@bruno-laptop:~/git/Python/project_euler/problem_15$ python3 sol1.py 1
2.0
if __name__ == '__main__':
import sys
>>> lattice_paths(25)
126410606437752
>>> lattice_paths(23)
8233430727600
>>> lattice_paths(20)
137846528820
>>> lattice_paths(15)
155117520
>>> lattice_paths(1)
2
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.')
"""
n = (
2 * n
) # middle entry of odd rows starting at row 3 is the solution for n = 1,
# 2, 3,...
k = n / 2
return int(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.")

View File

View File

@ -1,15 +1,34 @@
power = int(input("Enter the power of 2: "))
num = 2**power
"""
2^15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
string_num = str(num)
What is the sum of the digits of the number 2^1000?
"""
list_num = list(string_num)
sum_of_num = 0
def solution(power):
"""Returns the sum of the digits of the number 2^power.
>>> solution(1000)
1366
>>> solution(50)
76
>>> solution(20)
31
>>> solution(15)
26
"""
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)
for i in list_num:
sum_of_num += int(i)
return sum_of_num
print("Sum of the digits are:",sum_of_num)
if __name__ == "__main__":
power = int(input("Enter the power of 2: ").strip())
print("2 ^ ", power, " = ", 2 ** power)
result = solution(power)
print("Sum of the digits is: ", result)

View File

@ -1,6 +1,28 @@
from __future__ import print_function
n = 2**1000
r = 0
while n:
r, n = r + n % 10, n // 10
print(r)
"""
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?
"""
def solution(power):
"""Returns the sum of the digits of the number 2^power.
>>> solution(1000)
1366
>>> solution(50)
76
>>> solution(20)
31
>>> solution(15)
26
"""
n = 2 ** power
r = 0
while n:
r, n = r + n % 10, n // 10
return r
if __name__ == "__main__":
print(solution(int(str(input()).strip())))

View File

View File

@ -1,35 +1,63 @@
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 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?
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.
'''
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 withBritish
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
def solution(n):
"""Returns the number of letters used to write all numbers from 1 to n.
where n is lower or equals to 1000.
>>> solution(1000)
21124
>>> solution(5)
19
"""
# number of letters in zero, one, two, ..., nineteen (0 for zero since it's
# never said aloud)
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 twenty, thirty, ..., ninety (0 for numbers less than
# 20 due to inconsistency in teens)
tens_counts = [0, 0, 6, 6, 5, 5, 5, 7, 6, 6]
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"
count = 0
if i%100 != 0:
count += 3 #add number of letters for "and" if number is not multiple of 100
for i in range(1, n + 1):
if i < 1000:
if i >= 100:
# add number of letters for "n hundred"
count += ones_counts[i // 100] + 7
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
if i % 100 != 0:
# add number of letters for "and" if number is not multiple
# of 100
count += 3
print(count)
if 0 < i % 100 < 20:
# add number of letters for one, two, three, ..., nineteen
# (could be combined with below if not for inconsistency in
# teens)
count += ones_counts[i % 100]
else:
# add number of letters for twenty, twenty one, ..., ninety
# nine
count += ones_counts[i % 10]
count += tens_counts[(i % 100 - i % 10) // 10]
else:
count += ones_counts[i // 1000] + 8
return count
if __name__ == "__main__":
print(solution(int(input().strip())))

View File

View File

@ -1,9 +1,9 @@
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.
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,
@ -13,39 +13,52 @@ 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.
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)?
'''
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
def solution():
"""Returns the number of mondays that fall on the first of the month during
the twentieth century (1 Jan 1901 to 31 Dec 2000)?
sundays = 0
>>> solution()
171
"""
days_per_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
while year < 2001:
day += 7
day = 6
month = 1
year = 1901
if (year%4 == 0 and not year%100 == 0) or (year%400 == 0):
if day > days_per_month[month-1] and month != 2:
month += 1
day = day-days_per_month[month-2]
elif day > 29 and month == 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
sundays = 0
if year < 2001 and day == 1:
sundays += 1
while year < 2001:
day += 7
print(sundays)
if (year % 4 == 0 and not year % 100 == 0) or (year % 400 == 0):
if day > days_per_month[month - 1] and month != 2:
month += 1
day = day - days_per_month[month - 2]
elif day > 29 and month == 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 == 1:
sundays += 1
return sundays
if __name__ == "__main__":
print(solution(171))

View File

View File

@ -1,27 +1,51 @@
# Finding the factorial.
"""
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!
"""
def factorial(n):
fact = 1
for i in range(1,n+1):
for i in range(1, n + 1):
fact *= i
return fact
# Spliting the digits and adding it.
def split_and_add(number):
"""Split number digits and add them."""
sum_of_digits = 0
while(number>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.
number = number // 10 # Removing the last_digit from the given number
return sum_of_digits
# Taking the user input.
number = int(input("Enter the Number: "))
# Assigning the factorial from the factorial function.
factorial = factorial(number)
def solution(n):
"""Returns the sum of the digits in the number 100!
>>> solution(100)
648
>>> solution(50)
216
>>> solution(10)
27
>>> solution(5)
3
>>> solution(3)
6
>>> solution(2)
2
>>> solution(1)
1
"""
f = factorial(n)
result = split_and_add(f)
return result
# Spliting and adding the factorial into answer.
answer = split_and_add(factorial)
# Printing the answer.
print(answer)
if __name__ == "__main__":
print(solution(int(input("Enter the Number: ").strip())))

View File

@ -1,5 +1,33 @@
"""
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!
"""
from math import factorial
def main():
print(sum([int(x) for x in str(factorial(100))]))
if __name__ == '__main__':
main()
def solution(n):
"""Returns the sum of the digits in the number 100!
>>> solution(100)
648
>>> solution(50)
216
>>> solution(10)
27
>>> solution(5)
3
>>> solution(3)
6
>>> solution(2)
2
>>> solution(1)
1
"""
return sum([int(x) for x in str(factorial(n))])
if __name__ == "__main__":
print(solution(int(input("Enter the Number: ").strip())))

View File

View File

@ -1,30 +1,61 @@
#-.- coding: latin-1 -.-
from __future__ import print_function
# -.- coding: latin-1 -.-
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.
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.
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
xrange # Python 2
except NameError:
xrange = range #Python 3
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
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
total = [i for i in range(1,10000) if sum_of_divisors(sum_of_divisors(i)) == i and sum_of_divisors(i) != i]
print(sum(total))
def solution(n):
"""Returns the sum of all the amicable numbers under n.
>>> solution(10000)
31626
>>> solution(5000)
8442
>>> solution(1000)
504
>>> solution(100)
0
>>> solution(50)
0
"""
total = sum(
[
i
for i in range(1, n)
if sum_of_divisors(sum_of_divisors(i)) == i
and sum_of_divisors(i) != i
]
)
return total
if __name__ == "__main__":
print(solution(int(str(input()).strip())))

View File

View File

@ -1,37 +1,52 @@
# -*- 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.
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.
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?
'''
"""
import os
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
xrange = range # Python 3
with open('p022_names.txt') as file:
names = str(file.readlines()[0])
names = names.replace('"', '').split(',')
names.sort()
def solution():
"""Returns the total of all the name scores in the file.
name_score = 0
total_score = 0
>>> solution()
871198282
"""
with open(os.path.dirname(__file__) + "/p022_names.txt") as file:
names = str(file.readlines()[0])
names = names.replace('"', "").split(",")
for i, name in enumerate(names):
for letter in name:
name_score += ord(letter) - 64
names.sort()
total_score += (i+1)*name_score
name_score = 0
name_score = 0
total_score = 0
print(total_score)
for i, name in enumerate(names):
for letter in name:
name_score += ord(letter) - 64
total_score += (i + 1) * name_score
name_score = 0
return total_score
if __name__ == "__main__":
print(solution())

View File

@ -1,533 +1,43 @@
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)
# -*- coding: latin-1 -*-
"""
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?
"""
import os
if __name__ == '__main__':
main()
def solution():
"""Returns the total of all the name scores in the file.
>>> solution()
871198282
"""
total_sum = 0
temp_sum = 0
with open(os.path.dirname(__file__) + "/p022_names.txt") as file:
name = str(file.readlines()[0])
name = name.replace('"', "").split(",")
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
return total_sum
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,4 +1,22 @@
# https://projecteuler.net/problem=234
"""
https://projecteuler.net/problem=234
For an integer n 4, we define the lower prime square root of n, denoted by
lps(n), as the largest prime n and the upper prime square root of n, ups(n),
as the smallest prime n.
So, for example, lps(4) = 2 = ups(4), lps(1000) = 31, ups(1000) = 37. Let us
call an integer n 4 semidivisible, if one of lps(n) and ups(n) divides n,
but not both.
The sum of the semidivisible numbers not exceeding 15 is 30, the numbers are 8,
10 and 12. 15 is not semidivisible because it is a multiple of both lps(15) = 3
and ups(15) = 5. As a further example, the sum of the 92 semidivisible numbers
up to 1000 is 34825.
What is the sum of all semidivisible numbers not exceeding 999966663333 ?
"""
def fib(a, b, n):
if n==1:
@ -17,16 +35,22 @@ def fib(a, b, n):
return c
q=int(input())
for x in range(q):
l=[i for i in input().split()]
c1=0
c2=1
while(1):
if len(fib(l[0],l[1],c2))<int(l[2]):
c2+=1
else:
break
print(fib(l[0],l[1],c2+1)[int(l[2])-1])
def solution(n):
"""Returns the sum of all semidivisible numbers not exceeding n."""
semidivisible = []
for x in range(n):
l=[i for i in input().split()]
c1=0
c2=1
while(1):
if len(fib(l[0],l[1],c2))<int(l[2]):
c2+=1
else:
break
semidivisible.append(fib(l[0],l[1],c2+1)[int(l[2])-1])
return semidivisible
if __name__ == "__main__":
for i in solution(int(str(input()).strip())):
print(i)

View File

View File

@ -1,7 +1,27 @@
from itertools import permutations
def main():
result=list(map("".join, permutations('0123456789')))
print(result[999999])
"""
A permutation is an ordered arrangement of objects. For example, 3124 is one
possible permutation of the digits 1, 2, 3 and 4. If all of the permutations
are listed numerically or alphabetically, we call it lexicographic order. The
lexicographic permutations of 0, 1 and 2 are:
if __name__ == '__main__':
main()
012 021 102 120 201 210
What is the millionth lexicographic permutation of the digits 0, 1, 2, 3, 4, 5,
6, 7, 8 and 9?
"""
from itertools import permutations
def solution():
"""Returns the millionth lexicographic permutation of the digits 0, 1, 2,
3, 4, 5, 6, 7, 8 and 9.
>>> solution()
'2783915460'
"""
result = list(map("".join, permutations("0123456789")))
return result[999999]
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,31 +1,75 @@
from __future__ import print_function
# -*- coding: utf-8 -*-
"""
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.
What is the index of the first term in the Fibonacci sequence to contain 1000
digits?
"""
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
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])
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]
return sequence[n]
def fibonacci_digits_index(n):
digits = 0
index = 2
digits = 0
index = 2
while digits < n:
index += 1
digits = len(str(fibonacci(index)))
while digits < n:
index += 1
digits = len(str(fibonacci(index)))
return index
return index
if __name__ == '__main__':
print(fibonacci_digits_index(1000))
def solution(n):
"""Returns the index of the first term in the Fibonacci sequence to contain
n digits.
>>> solution(1000)
4782
>>> solution(100)
476
>>> solution(50)
237
>>> solution(3)
12
"""
return fibonacci_digits_index(n)
if __name__ == "__main__":
print(solution(int(str(input()).strip())))

View File

@ -1,10 +1,57 @@
def fibonacci_genrator():
a, b = 0,1
while True:
a,b = b,a+b
yield b
answer = 1
gen = fibonacci_genrator()
while len(str(next(gen))) < 1000:
answer += 1
assert answer+1 == 4782
# -*- coding: utf-8 -*-
"""
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn1 + Fn2, where F1 = 1 and F2 = 1.
Hence the first 12 terms will be:
F1 = 1
F2 = 1
F3 = 2
F4 = 3
F5 = 5
F6 = 8
F7 = 13
F8 = 21
F9 = 34
F10 = 55
F11 = 89
F12 = 144
The 12th term, F12, is the first term to contain three digits.
What is the index of the first term in the Fibonacci sequence to contain 1000
digits?
"""
def fibonacci_generator():
a, b = 0, 1
while True:
a, b = b, a + b
yield b
def solution(n):
"""Returns the index of the first term in the Fibonacci sequence to contain
n digits.
>>> solution(1000)
4782
>>> solution(100)
476
>>> solution(50)
237
>>> solution(3)
12
"""
answer = 1
gen = fibonacci_generator()
while len(str(next(gen))) < n:
answer += 1
return answer + 1
if __name__ == "__main__":
print(solution(int(str(input()).strip())))

View File

View File

@ -1,29 +1,60 @@
from __future__ import print_function
"""
Starting with the number 1 and moving to the right in a clockwise direction a 5
by 5 spiral is formed as follows:
21 22 23 24 25
20 7 8 9 10
19 6 1 2 11
18 5 4 3 12
17 16 15 14 13
It can be verified that the sum of the numbers on the diagonals is 101.
What is the sum of the numbers on the diagonals in a 1001 by 1001 spiral formed
in the same way?
"""
from math import ceil
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
xrange = range # Python 3
def diagonal_sum(n):
total = 1
"""Returns the sum of the numbers on the diagonals in a n by n spiral
formed in the same way.
for i in xrange(1, int(ceil(n/2.0))):
odd = 2*i+1
even = 2*i
total = total + 4*odd**2 - 6*even
>>> diagonal_sum(1001)
669171001
>>> diagonal_sum(500)
82959497
>>> diagonal_sum(100)
651897
>>> diagonal_sum(50)
79697
>>> diagonal_sum(10)
537
"""
total = 1
return total
for i in xrange(1, int(ceil(n / 2.0))):
odd = 2 * i + 1
even = 2 * i
total = total + 4 * odd ** 2 - 6 * even
if __name__ == '__main__':
import sys
return total
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')
if __name__ == "__main__":
import sys
if len(sys.argv) == 1:
print(diagonal_sum(1001))
else:
try:
n = int(sys.argv[1])
print(diagonal_sum(n))
except ValueError:
print("Invalid entry - please enter a number")

View File

View File

@ -1,33 +1,51 @@
def main():
"""
Consider all integer combinations of ab for 2 <= a <= 5 and 2 <= b <= 5:
2^2=4, 2^3=8, 2^4=16, 2^5=32
3^2=9, 3^3=27, 3^4=81, 3^5=243
4^2=16, 4^3=64, 4^4=256, 4^5=1024
5^2=25, 5^3=125, 5^4=625, 5^5=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?
"""
from __future__ import print_function
def solution(n):
"""Returns the number of distinct terms in the sequence generated by a^b
for 2 <= a <= 100 and 2 <= b <= 100.
>>> solution(100)
9183
>>> solution(50)
2184
>>> solution(20)
324
>>> solution(5)
15
>>> solution(2)
1
>>> solution(1)
0
"""
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
N = n + 1 # 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))
currentPow = a ** b # calculates the current power
collectPowers.add(currentPow) # adds the result to the set
return len(collectPowers)
if __name__ == '__main__':
main()
if __name__ == "__main__":
print("Number of terms ", solution(int(str(input()).strip())))

View File

View File

@ -1,10 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import print_function
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
'''
"""
Coin sums
Problem 31
In England the currency is made up of pound, £, and pence, p, and there are
@ -15,7 +10,13 @@ It is possible to make £2 in the following way:
1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
How many different ways can £2 be made using any number of coins?
'''
"""
from __future__ import print_function
try:
raw_input # Python 2
except NameError:
raw_input = input # Python 3
def one_pence():
@ -50,4 +51,21 @@ def two_pound(x):
return 0 if x < 0 else two_pound(x - 200) + one_pound(x)
print(two_pound(200))
def solution(n):
"""Returns the number of different ways can £n be made using any number of
coins?
>>> solution(500)
6295434
>>> solution(200)
73682
>>> solution(50)
451
>>> solution(10)
11
"""
return two_pound(n)
if __name__ == "__main__":
print(solution(int(str(input()).strip())))

View File

View File

@ -1,30 +1,57 @@
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.
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.)
'''
(Please note that the palindromic number, in either base, may not include
leading zeros.)
"""
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
xrange = range # Python 3
def is_palindrome(n):
n = str(n)
n = str(n)
if n == n[::-1]:
return True
else:
return False
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
def solution(n):
"""Return the sum of all numbers, less than n , which are palindromic in
base 10 and base 2.
print(total)
>>> solution(1000000)
872187
>>> solution(500000)
286602
>>> solution(100000)
286602
>>> solution(1000)
1772
>>> solution(100)
157
>>> solution(10)
25
>>> solution(2)
1
>>> solution(1)
0
"""
total = 0
for i in xrange(1, n):
if is_palindrome(i) and is_palindrome(bin(i).split("b")[1]):
total += i
return total
if __name__ == "__main__":
print(solution(int(str(input().strip()))))

View File

View File

@ -1,26 +1,47 @@
#-.- coding: latin-1 -.-
from __future__ import print_function
'''
# -.- coding: latin-1 -.-
"""
Champernowne's constant
Problem 40
An irrational decimal fraction is created by concatenating the positive integers:
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.
If dn represents the nth digit of the fractional part, find the value of the
following expression.
d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000
'''
"""
from __future__ import print_function
constant = []
i = 1
while len(constant) < 1e6:
constant.append(str(i))
i += 1
def solution():
"""Returns
constant = ''.join(constant)
>>> solution()
210
"""
constant = []
i = 1
print(int(constant[0])*int(constant[9])*int(constant[99])*int(constant[999])*int(constant[9999])*int(constant[99999])*int(constant[999999]))
while len(constant) < 1e6:
constant.append(str(i))
i += 1
constant = "".join(constant)
return (
int(constant[0])
* int(constant[9])
* int(constant[99])
* int(constant[999])
* int(constant[9999])
* int(constant[99999])
* int(constant[999999])
)
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,21 +1,29 @@
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
xrange
except NameError:
xrange = range
total = 0
for i in xrange(1, 1001):
total += i**i
xrange = range
print(str(total)[-10:])
def solution():
"""Returns the last 10 digits of the series, 11 + 22 + 33 + ... + 10001000.
>>> solution()
'9110846700'
"""
total = 0
for i in xrange(1, 1001):
total += i ** i
return str(total)[-10:]
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,23 +1,37 @@
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.
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
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
contain the same digits.
"""
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
def solution():
"""Returns the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and
6x, contain the same digits.
print(i)
>>> solution()
142857
"""
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)))
):
return i
i += 1
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,13 +1,11 @@
#-.- coding: latin-1 -.-
from __future__ import print_function
from math import factorial
'''
# -.- coding: latin-1 -.-
"""
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
123, 124, 125, 134, 135, 145, 234, 235, 245, and 345
In combinatorics, we use the notation, 5C3 = 10.
@ -16,21 +14,37 @@ In general,
nCr = n!/(r!(nr)!),where r n, n! = n×(n1)×...×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?
'''
How many, not necessarily distinct, values of nCr, for 1 n 100, are greater
than one-million?
"""
from __future__ import print_function
from math import factorial
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
xrange = range # Python 3
def combinations(n, r):
return factorial(n)/(factorial(r)*factorial(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
def solution():
"""Returns the number of values of nCr, for 1 ≤ n ≤ 100, are greater than
one-million
print(total)
>>> solution()
4075
"""
total = 0
for i in xrange(1, 101):
for j in xrange(1, i + 1):
if combinations(i, j) > 1e6:
total += 1
return total
if __name__ == "__main__":
print(solution())

View File

View File

@ -1,5 +1,4 @@
from __future__ import print_function
'''
"""
Counting Summations
Problem 76
@ -12,24 +11,50 @@ It is possible to write five as a sum in exactly six different ways:
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?
'''
How many different ways can one hundred be written as a sum of at least two
positive integers?
"""
from __future__ import print_function
try:
xrange #Python 2
xrange # Python 2
except NameError:
xrange = range #Python 3
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
"""Returns the number of different ways one hundred can be written as a sum
of at least two positive integers.
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]
>>> partition(100)
190569291
>>> partition(50)
204225
>>> partition(30)
5603
>>> partition(10)
41
>>> partition(5)
6
>>> partition(3)
2
>>> partition(2)
1
>>> partition(1)
0
"""
memo = [[0 for _ in xrange(m)] for _ in xrange(m + 1)]
for i in xrange(m + 1):
memo[i][0] = 1
return (memo[m][m-1] - 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]
print(partition(100))
return memo[m][m - 1] - 1
if __name__ == "__main__":
print(partition(int(str(input()).strip())))