Style improvement
This commit is contained in:
parent
adca45e24f
commit
48503b8e27
@ -27,7 +27,7 @@ def p022():
|
||||
sum_ = 0
|
||||
i = 1
|
||||
|
||||
# Calculate the score of each name an multiply by its position.
|
||||
# Calculate the score of each name an multiply by its position.
|
||||
for name in names:
|
||||
l = len(name)
|
||||
score = 0
|
||||
|
@ -17,7 +17,8 @@
|
||||
# where |n| is the modulus/absolute value of n
|
||||
# e.g. |11|=11 and |−4|=4
|
||||
#
|
||||
# Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n, starting with n=0.
|
||||
# Find the product of the coefficients, a and b, for the quadratic expression that produces the maximum number of primes for consecutive values of n,
|
||||
# starting with n=0.
|
||||
|
||||
from projecteuler import is_prime, timing
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# A natural number, N, hat can be written as the sum and product of a given set of at least two natural numbers, {a1,a2,...,ak} is called a product sum number: N = a1 + a2 + ... + ak = a1 x a2 x ... ak.
|
||||
# A natural number, N, hat can be written as the sum and product of a given set of at least two natural numbers, {a1,a2,...,ak} is called a product sum number:
|
||||
# N = a1 + a2 + ... + ak = a1 x a2 x ... ak.
|
||||
#
|
||||
# For example, 6 = 1 + 2 + 3 = 1 x 2 x 3
|
||||
#
|
||||
# For a given set of size, k, we shall call the smallest N with this property a minimal product-sum number. The minimal product-sum numbers for sets of size, k = 2,3,4,5, and 6 are as follows.
|
||||
# For a given set of size, k, we shall call the smallest N with this property a minimal product-sum number. The minimal product-sum numbers for sets of size,
|
||||
# k = 2,3,4,5, and 6 are as follows.
|
||||
#
|
||||
# k = 2: 4 = 2 x 2 = 2 + 2
|
||||
# k = 3: 6 = 1 x 2 x 3 = 1 + 2 + 3
|
||||
|
@ -1,22 +1,26 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Each of the six faces on a cube has a different digit (0 to 9) written on it; the same is done to a second cube. By placing the two cubes side-by-side in different positions we can form a variety of 2-digit numbers.
|
||||
# Each of the six faces on a cube has a different digit (0 to 9) written on it; the same is done to a second cube. By placing the two cubes side-by-side
|
||||
# in different positions we can form a variety of 2-digit numbers.
|
||||
#
|
||||
# For example, the square number 64 could be formed:
|
||||
# |6||4|
|
||||
#
|
||||
# In fact, by carefully choosing the digits on both cubes it is possible to display all of the square numbers below one-hundred: 01, 04, 09, 16, 25, 36, 49, 64, and 81.
|
||||
# In fact, by carefully choosing the digits on both cubes it is possible to display all of the square numbers below one-hundred:
|
||||
# 01, 04, 09, 16, 25, 36, 49, 64, and 81.
|
||||
#
|
||||
# For example, one way this can be achieved is by placing {0,5,6,7,8,9} on one cube and {1,2,3,4,8,9} on the other cube.
|
||||
#
|
||||
# However, for this problem we shall allow the 6 or 9 to be turned upside-down so that an arrangement like {0,5,6,7,8,9} and {1,2,3,4,6,7} allows for all nine square numbers to be displayed; otherwise it would be impossible to obtain 09.
|
||||
# However, for this problem we shall allow the 6 or 9 to be turned upside-down so that an arrangement like {0,5,6,7,8,9} and {1,2,3,4,6,7} allows
|
||||
# for all nine square numbers to be displayed; otherwise it would be impossible to obtain 09.
|
||||
#
|
||||
# In determining a distinct arrangement we are interested in the digits on each cube, not the order.
|
||||
#
|
||||
# {1,2,3,4,5,6} is equivalent to {3,6,4,1,2,5}
|
||||
# {1,2,3,4,5,6} is distinct from {1,2,3,4,5,9}
|
||||
#
|
||||
# But because we are allowing 6 and 9 to be reversed, the two distinct sets in the last example both represent the extended set {1,2,3,4,5,6,9} for the purpose of forming 2-digit numbers.
|
||||
# But because we are allowing 6 and 9 to be reversed, the two distinct sets in the last example both represent the extended set {1,2,3,4,5,6,9}
|
||||
# for the purpose of forming 2-digit numbers.
|
||||
#
|
||||
# How many distinct arrangements of the two cubes allow for all of the square numbers to be displayed?
|
||||
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
# The points P(x1,y1) and Q(x2,y2) are plotted at integer co-ordinates and are joined to the origin, O(0,0), to form ΔOPQ.
|
||||
#
|
||||
# There are exactly fourteen triangles containing a right angle that can be formed when each co-ordinate lies between 0 and 2 inclusive; that is, 0<=x1,y1,x2,y2<=2.
|
||||
# There are exactly fourteen triangles containing a right angle that can be formed when each co-ordinate lies between 0 and 2 inclusive;
|
||||
# that is, 0<=x1,y1,x2,y2<=2.
|
||||
#
|
||||
# Given that 0<=x1,y1,x2,y2<=50, how many right triangles can be formed?
|
||||
|
||||
|
@ -294,7 +294,7 @@ def is_semiprime(n, primes):
|
||||
return False, -1, -1
|
||||
|
||||
# Check if n is semiprime and one of the factors is 3.
|
||||
elif n % 3 == 0:
|
||||
if n % 3 == 0:
|
||||
if primes[n//3] == 1:
|
||||
p = 3
|
||||
q = n // 3
|
||||
|
Loading…
x
Reference in New Issue
Block a user