repo_name stringclasses 25
values | repo_full_name stringclasses 25
values | owner stringclasses 25
values | stars int64 117k 496k | license stringclasses 7
values | repo_description stringclasses 25
values | filepath stringlengths 9 75 | file_type stringclasses 3
values | language stringclasses 2
values | content stringlengths 24 383k | size_bytes int64 25 387k | num_lines int64 2 4.44k |
|---|---|---|---|---|---|---|---|---|---|---|---|
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_031\sol2.py | python | Python | """
Problem 31: https://projecteuler.net/problem=31
Coin sums
In England the currency is made up of pound, f, and pence, p, and there are
eight coins in general circulation:
1p, 2p, 5p, 10p, 20p, 50p, f1 (100p) and f2 (200p).
It is possible to make f2 in the following way:
1xf1 + 1x50p + 2x20p + 1x5p + 1x2p + 3x1p
... | 1,569 | 60 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_032\sol32.py | python | Python | """
We shall say that an n-digit number is pandigital if it makes use of all the
digits 1 to n exactly once; for example, the 5-digit number, 15234, is 1 through
5 pandigital.
The product 7254 is unusual, as the identity, 39 x 186 = 7254, containing
multiplicand, multiplier, and product is 1 through 9 pandigital.
Fin... | 1,636 | 60 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_033\sol1.py | python | Python | """
Problem 33: https://projecteuler.net/problem=33
The fraction 49/98 is a curious fraction, as an inexperienced
mathematician in attempting to simplify it may incorrectly believe
that 49/98 = 4/8, which is correct, is obtained by cancelling the 9s.
We shall consider fractions like, 30/50 = 3/5, to be trivial exampl... | 2,019 | 73 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_034\sol1.py | python | Python | """
Problem 34: https://projecteuler.net/problem=34
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145.
Find the sum of all numbers which are equal to the sum of the factorial of their digits.
Note: As 1! = 1 and 2! = 2 are not sums they are not included.
"""
from math import factorial
DIGIT_FACTORIAL = {... | 999 | 39 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_035\sol1.py | python | Python | """
Project Euler Problem 35
https://projecteuler.net/problem=35
Problem Statement:
The number 197 is called a circular prime because all rotations of the digits:
197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73,
79, and 97.
How many circular pr... | 2,247 | 84 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_036\sol1.py | python | Python | """
Project Euler Problem 36
https://projecteuler.net/problem=36
Problem Statement:
Double-base palindromes
Problem 36
The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic in
base 10 and base 2.
(Please note that the ... | 1,480 | 70 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_037\sol1.py | python | Python | """
Truncatable primes
Problem 37: https://projecteuler.net/problem=37
The number 3797 has an interesting property. Being prime itself, it is possible
to continuously remove digits from left to right, and remain prime at each stage:
3797, 797, 97, and 7. Similarly we can work from right to left: 3797, 379, 37, and 3.
... | 3,211 | 120 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_038\sol1.py | python | Python | """
Project Euler Problem 38: https://projecteuler.net/problem=38
Take the number 192 and multiply it by each of 1, 2, and 3:
192 x 1 = 192
192 x 2 = 384
192 x 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call
192384576 the concatenated product of 192 and (1,2,3)
The same c... | 2,458 | 78 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_039\sol1.py | python | Python | """
Problem 39: https://projecteuler.net/problem=39
If p is the perimeter of a right angle triangle with integral length sides,
{a,b,c}, there are exactly three solutions for p = 120.
{20,48,52}, {24,45,51}, {30,40,50}
For which value of p ≤ 1000, is the number of solutions maximised?
"""
from __future__ import anno... | 1,705 | 56 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_040\sol1.py | python | Python | """
Champernowne's constant
Problem 40
An irrational decimal fraction is created by concatenating the positive
integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If dn represents the nth digit of the fractional part, find the value of the
following expres... | 913 | 46 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_041\sol1.py | python | Python | """
Pandigital prime
Problem 41: https://projecteuler.net/problem=41
We shall say that an n-digit number is pandigital if it makes use of all the digits
1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime.
What is the largest n-digit pandigital prime that exists?
All pandigital numbers ex... | 2,073 | 78 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_042\solution42.py | python | Python | """
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so
the first ten triangle numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
By converting each letter in a word to a number corresponding to its
alphabetical position and adding these values we form a word value. For example,
the word... | 1,410 | 48 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_043\sol1.py | python | Python | """
Problem 43: https://projecteuler.net/problem=43
The number, 1406357289, is a 0 to 9 pandigital number because it is made up of
each of the digits 0 to 9 in some order, but it also has a rather interesting
sub-string divisibility property.
Let d1 be the 1st digit, d2 be the 2nd digit, and so on. In this way, we no... | 1,793 | 67 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_044\sol1.py | python | Python | """
Problem 44: https://projecteuler.net/problem=44
Pentagonal numbers are generated by the formula, Pn=n(3n-1)/2. The first ten
pentagonal numbers are:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, ...
It can be seen that P4 + P7 = 22 + 70 = 92 = P8. However, their difference,
70 - 22 = 48, is not pentagonal.
Find the pai... | 1,491 | 50 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_045\sol1.py | python | Python | """
Problem 45: https://projecteuler.net/problem=45
Triangle, pentagonal, and hexagonal numbers are generated by the following formulae:
Triangle T(n) = (n * (n + 1)) / 2 1, 3, 6, 10, 15, ...
Pentagonal P(n) = (n * (3 * n - 1)) / 2 1, 5, 12, 22, 35, ...
Hexagonal H(n) = n * (2 * n - 1) 1, 6, 15, 28, 45, ..... | 1,529 | 60 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_046\sol1.py | python | Python | """
Problem 46: https://projecteuler.net/problem=46
It was proposed by Christian Goldbach that every odd composite number can be
written as the sum of a prime and twice a square.
9 = 7 + 2 x 12
15 = 7 + 2 x 22
21 = 3 + 2 x 32
25 = 7 + 2 x 32
27 = 19 + 2 x 22
33 = 31 + 2 x 12
It turns out that the conjecture was fals... | 2,802 | 117 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_047\sol1.py | python | Python | """
Combinatoric selections
Problem 47
The first two consecutive numbers to have two distinct prime factors are:
14 = 2 x 7
15 = 3 x 5
The first three consecutive numbers to have three distinct prime factors are:
644 = 2² x 7 x 23
645 = 3 x 5 x 43
646 = 2 x 17 x 19.
Find the first four consecutive integers to hav... | 2,669 | 113 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_048\sol1.py | python | Python | """
Self Powers
Problem 48
The series, 1^1 + 2^2 + 3^3 + ... + 10^10 = 10405071317.
Find the last ten digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
"""
def solution():
"""
Returns the last 10 digits of the series, 1^1 + 2^2 + 3^3 + ... + 1000^1000.
>>> solution()
'9110846700'
"""
... | 486 | 26 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_049\sol1.py | python | Python | """
Prime permutations
Problem 49
The arithmetic sequence, 1487, 4817, 8147, in which each of
the terms increases by 3330, is unusual in two ways:
(i) each of the three terms are prime,
(ii) each of the 4-digit numbers are permutations of one another.
There are no arithmetic sequences made up of three 1-, 2-, or 3-d... | 4,172 | 154 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_050\sol1.py | python | Python | """
Project Euler Problem 50: https://projecteuler.net/problem=50
Consecutive prime sum
The prime 41, can be written as the sum of six consecutive primes:
41 = 2 + 3 + 5 + 7 + 11 + 13
This is the longest sum of consecutive primes that adds to a prime below
one-hundred.
The longest sum of consecutive primes below on... | 2,027 | 87 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_051\sol1.py | python | Python | """
https://projecteuler.net/problem=51
Prime digit replacements
Problem 51
By replacing the 1st digit of the 2-digit number *3, it turns out that six of
the nine possible values: 13, 23, 43, 53, 73, and 83, are all prime.
By replacing the 3rd and 4th digits of 56**3 with the same digit, this 5-digit
number is the fi... | 3,137 | 115 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_052\sol1.py | python | Python | """
Permuted multiples
Problem 52
It can be seen that the number, 125874, and its double, 251748, contain exactly
the same digits, but in a different order.
Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x,
contain the same digits.
"""
def solution():
"""Returns the smallest positive inte... | 803 | 38 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_053\sol1.py | python | Python | """
Combinatoric selections
Problem 53
There are exactly ten ways of selecting three from five, 12345:
123, 124, 125, 134, 135, 145, 234, 235, 245, and 345
In combinatorics, we use the notation, 5C3 = 10.
In general,
nCr = n!/(r!(n-r)!),where r ≤ n, n! = nx(n-1)x...x3x2x1, and 0! = 1.
It is not until n = 23, t... | 1,003 | 45 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_054\sol1.py | python | Python | """
Problem: https://projecteuler.net/problem=54
In the card game poker, a hand consists of five cards and are ranked,
from lowest to highest, in the following way:
High Card: Highest value card.
One Pair: Two cards of the same value.
Two Pairs: Two different pairs.
Three of a Kind: Three cards of the same value.
Str... | 14,219 | 385 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_054\test_poker_hand.py | test | Python | import os
from itertools import chain
from random import randrange, shuffle
import pytest
from .sol1 import PokerHand
SORTED_HANDS = (
"4S 3H 2C 7S 5H",
"9D 8H 2C 6S 7H",
"2D 6D 9D TH 7D",
"TC 8C 2S JH 6C",
"JH 8S TH AH QH",
"TS KS 5S 9S AC",
"KD 6S 9D TH AD",
"KS 8D 4D 9S 4S", # pai... | 7,864 | 229 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_055\sol1.py | python | Python | """
Lychrel numbers
Problem 55: https://projecteuler.net/problem=55
If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.
Not all numbers produce palindromes so quickly. For example,
349 + 943 = 1292,
1292 + 2921 = 4213
4213 + 3124 = 7337
That is, 349 took three iterations to arrive at a palindrome.
A... | 2,409 | 82 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_056\sol1.py | python | Python | """
Project Euler Problem 56: https://projecteuler.net/problem=56
A googol (10^100) is a massive number: one followed by one-hundred zeros;
100^100 is almost unimaginably large: one followed by two-hundred zeros.
Despite their size, the sum of the digits in each number is only 1.
Considering natural numbers of the fo... | 1,050 | 42 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_057\sol1.py | python | Python | """
Project Euler Problem 57: https://projecteuler.net/problem=57
It is possible to show that the square root of two can be expressed as an infinite
continued fraction.
sqrt(2) = 1 + 1 / (2 + 1 / (2 + 1 / (2 + ...)))
By expanding this for the first four iterations, we get:
1 + 1 / 2 = 3 / 2 = 1.5
1 + 1 / (2 + 1 / 2} ... | 1,541 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_058\sol1.py | python | Python | """
Project Euler Problem 58:https://projecteuler.net/problem=58
Starting with 1 and spiralling anticlockwise in the following way,
a square spiral with side length 7 is formed.
37 36 35 34 33 32 31
38 17 16 15 14 13 30
39 18 5 4 3 12 29
40 19 6 1 2 11 28
41 20 7 8 9 10 27
42 21 22 23 24 25 26
43 44 45 46 4... | 2,892 | 106 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_059\sol1.py | python | Python | """
Each character on a computer is assigned a unique code and the preferred standard is
ASCII (American Standard Code for Information Interchange).
For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.
A modern encryption method is to take a text file, convert the bytes to ASCII, then
XOR each byte... | 5,019 | 129 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_062\sol1.py | python | Python | """
Project Euler 62
https://projecteuler.net/problem=62
The cube, 41063625 (345^3), can be permuted to produce two other cubes:
56623104 (384^3) and 66430125 (405^3). In fact, 41063625 is the smallest cube
which has exactly three permutations of its digits which are also cube.
Find the smallest cube for which exactl... | 1,676 | 63 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_063\sol1.py | python | Python | """
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number,
134217728=89, is a ninth power.
How many n-digit positive integers exist which are also an nth power?
"""
"""
The maximum base can be 9 because all n-digit numbers < 10^n.
Now 9**23 has 22 digits so the maximum power can be 22.
Usi... | 909 | 35 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_064\sol1.py | python | Python | """
Project Euler Problem 64: https://projecteuler.net/problem=64
All square roots are periodic when written as continued fractions.
For example, let us consider sqrt(23).
It can be seen that the sequence is repeating.
For conciseness, we use the notation sqrt(23)=[4;(1,3,1,8)],
to indicate that the block (1,3,1,8) re... | 2,140 | 77 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_065\sol1.py | python | Python | """
Project Euler Problem 65: https://projecteuler.net/problem=65
The square root of 2 can be written as an infinite continued fraction.
sqrt(2) = 1 + 1 / (2 + 1 / (2 + 1 / (2 + 1 / (2 + ...))))
The infinite continued fraction can be written, sqrt(2) = [1;(2)], (2)
indicates that 2 repeats ad infinitum. In a similar... | 2,672 | 100 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_067\sol1.py | python | Python | """
Problem Statement:
By starting at the top of the triangle below and moving to adjacent numbers on
the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom in triangle.txt (right click and
'Save Link/Target As...'), a 15K te... | 1,275 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_067\sol2.py | python | Python | """
Problem Statement:
By starting at the top of the triangle below and moving to adjacent numbers on
the row below, the maximum total from top to bottom is 23.
3
7 4
2 4 6
8 5 9 3
That is, 3 + 7 + 4 + 9 = 23.
Find the maximum total from top to bottom in triangle.txt (right click and
'Save Link/Target As...'), a 15K te... | 1,102 | 41 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_068\sol1.py | python | Python | """
Project Euler Problem 68: https://projecteuler.net/problem=68
Magic 5-gon ring
Problem Statement:
Consider the following "magic" 3-gon ring,
filled with the numbers 1 to 6, and each line adding to nine.
4
\
3
/ \
1 - 2 - 6
/
5
Working clockwise, and starting from the group of three
with th... | 4,146 | 135 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_069\sol1.py | python | Python | """
Totient maximum
Problem 69: https://projecteuler.net/problem=69
Euler's Totient function, φ(n) [sometimes called the phi function],
is used to determine the number of numbers less than n which are relatively prime to n.
For example, as 1, 2, 4, 5, 7, and 8,
are all less than nine and relatively prime to nine, φ(9)... | 1,842 | 67 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_070\sol1.py | python | Python | """
Project Euler Problem 70: https://projecteuler.net/problem=70
Euler's Totient function, φ(n) [sometimes called the phi function], is used to
determine the number of positive numbers less than or equal to n which are
relatively prime to n. For example, as 1, 2, 4, 5, 7, and 8, are all less than
nine and relatively ... | 2,790 | 102 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_071\sol1.py | python | Python | """
Ordered fractions
Problem 71
https://projecteuler.net/problem=71
Consider the fraction n/d, where n and d are positive
integers. If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8
in ascending order of size, we get:
1/8, 1/7, 1/6, 1/5, 1/4, ... | 1,616 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_072\sol1.py | python | Python | """
Problem 72 Counting fractions: https://projecteuler.net/problem=72
Description:
Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1,
it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size, we
get: 1/8, 1/7, 1/6... | 1,477 | 51 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_072\sol2.py | python | Python | """
Project Euler Problem 72: https://projecteuler.net/problem=72
Consider the fraction, n/d, where n and d are positive integers. If n<d and HCF(n,d)=1,
it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size,
we get:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, ... | 1,236 | 46 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_073\sol1.py | python | Python | """
Project Euler Problem 73: https://projecteuler.net/problem=73
Consider the fraction, n/d, where n and d are positive integers.
If n<d and HCF(n,d)=1, it is called a reduced proper fraction.
If we list the set of reduced proper fractions for d ≤ 8 in ascending order of size,
we get:
1/8, 1/7, 1/6, 1/5, 1/4, 2/7, ... | 1,309 | 52 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_074\sol1.py | python | Python | """
Project Euler Problem 74: https://projecteuler.net/problem=74
The number 145 is well known for the property that the sum of the factorial of its
digits is equal to 145:
1! + 4! + 5! = 1 + 24 + 120 = 145
Perhaps less well known is 169, in that it produces the longest chain of numbers that
link back to 169; it tur... | 2,883 | 110 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_074\sol2.py | python | Python | """
Project Euler Problem 074: https://projecteuler.net/problem=74
The number 145 is well known for the property that the sum of the factorial of its
digits is equal to 145:
1! + 4! + 5! = 1 + 24 + 120 = 145
Perhaps less well known is 169, in that it produces the longest chain of numbers that
link back to 169; it tu... | 4,904 | 148 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_075\sol1.py | python | Python | """
Project Euler Problem 75: https://projecteuler.net/problem=75
It turns out that 12 cm is the smallest length of wire that can be bent to form an
integer sided right angle triangle in exactly one way, but there are many more examples.
12 cm: (3,4,5)
24 cm: (6,8,10)
30 cm: (5,12,13)
36 cm: (9,12,15)
40 cm: (8,15,17... | 2,047 | 60 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_076\sol1.py | python | Python | """
Counting Summations
Problem 76: https://projecteuler.net/problem=76
It is possible to write five as a sum in exactly six different ways:
4 + 1
3 + 2
3 + 1 + 1
2 + 2 + 1
2 + 1 + 1 + 1
1 + 1 + 1 + 1 + 1
How many different ways can one hundred be written as a sum of at least two
positive integers?
"""
def solutio... | 1,160 | 56 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_077\sol1.py | python | Python | """
Project Euler Problem 77: https://projecteuler.net/problem=77
It is possible to write ten as the sum of primes in exactly five different ways:
7 + 3
5 + 5
5 + 3 + 2
3 + 3 + 2 + 2
2 + 2 + 2 + 2 + 2
What is the first value which can be written as the sum of primes in over
five thousand different ways?
"""
from __... | 2,080 | 83 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_078\sol1.py | python | Python | """
Problem 78
Url: https://projecteuler.net/problem=78
Statement:
Let p(n) represent the number of different ways in which n coins
can be separated into piles. For example, five coins can be separated
into piles in exactly seven different ways, so p(5)=7.
OOOOO
OOOO O
OOO OO
... | 1,394 | 63 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_079\sol1.py | python | Python | """
Project Euler Problem 79: https://projecteuler.net/problem=79
Passcode derivation
A common security method used for online banking is to ask the user for three
random characters from a passcode. For example, if the passcode was 531278,
they may ask for the 2nd, 3rd, and 5th characters; the expected reply would
be... | 2,245 | 71 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_080\sol1.py | python | Python | """
Project Euler Problem 80: https://projecteuler.net/problem=80
Author: Sandeep Gupta
Problem statement: For the first one hundred natural numbers, find the total of
the digital sums of the first one hundred decimal digits for all the irrational
square roots.
Time: 5 October 2020, 18:30
"""
import decimal
def solu... | 1,142 | 40 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_081\sol1.py | python | Python | """
Problem 81: https://projecteuler.net/problem=81
In the 5 by 5 matrix below, the minimal path sum from the top left to the bottom right,
by only moving to the right and down, is indicated in bold red and is equal to 2427.
[131] 673 234 103 18
[201] [96] [342] 965 150
630 803 [746] ... | 1,560 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_082\sol1.py | python | Python | """
Project Euler Problem 82: https://projecteuler.net/problem=82
The minimal path sum in the 5 by 5 matrix below, by starting in any cell
in the left column and finishing in any cell in the right column,
and only moving up, down, and right, is indicated in red and bold;
the sum is equal to 994.
131 673 [23... | 2,168 | 66 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_085\sol1.py | python | Python | """
Project Euler Problem 85: https://projecteuler.net/problem=85
By counting carefully it can be seen that a rectangular grid measuring 3 by 2
contains eighteen rectangles.

Although there exists no rectangular grid that contains exactly two million
rectangles, find the area of the grid with the nearest solution.
S... | 4,363 | 109 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_086\sol1.py | python | Python | """
Project Euler Problem 86: https://projecteuler.net/problem=86
A spider, S, sits in one corner of a cuboid room, measuring 6 by 5 by 3, and a fly, F,
sits in the opposite corner. By travelling on the surfaces of the room the shortest
"straight line" distance from S to F is 10 and the path is shown on the diagram.
... | 4,329 | 105 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_087\sol1.py | python | Python | """
Project Euler Problem 87: https://projecteuler.net/problem=87
The smallest number expressible as the sum of a prime square, prime cube, and prime
fourth power is 28. In fact, there are exactly four numbers below fifty that can be
expressed in such a way:
28 = 22 + 23 + 24
33 = 32 + 23 + 24
49 = 52 + 23 + 24
47 = ... | 1,571 | 53 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_089\sol1.py | python | Python | """
Project Euler Problem 89: https://projecteuler.net/problem=89
For a number written in Roman numerals to be considered valid there are basic rules
which must be followed. Even though the rules allow some numbers to be expressed in
more than one way there is always a "best" way of writing a particular number.
For e... | 3,625 | 142 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_091\sol1.py | python | Python | """
Project Euler Problem 91: https://projecteuler.net/problem=91
The points P (x1, y1) and Q (x2, y2) are plotted at integer coordinates 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 coordinate lies between 0 and 2 incl... | 1,736 | 59 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_092\sol1.py | python | Python | """
Project Euler Problem 092: https://projecteuler.net/problem=92
Square digit chains
A number chain is created by continuously adding the square of the digits in
a number to form a new number until it has been seen before.
For example,
44 → 32 → 13 → 10 → 1 → 1
85 → 89 → 145 → 42 → 20 → 4 → 16 → 37 → 58 → 89
Therefor... | 3,186 | 106 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_094\sol1.py | python | Python | """
Project Euler Problem 94: https://projecteuler.net/problem=94
It is easily proved that no equilateral triangle exists with integral length sides and
integral area. However, the almost equilateral triangle 5-5-6 has an area of 12 square
units.
We shall define an almost equilateral triangle to be a triangle for whi... | 1,256 | 45 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_095\sol1.py | python | Python | """
Project Euler Problem 95: https://projecteuler.net/problem=95
Amicable Chains
The proper divisors of a number are all the divisors excluding the number itself.
For example, the proper divisors of 28 are 1, 2, 4, 7, and 14.
As the sum of these divisors is equal to 28, we call it a perfect number.
Interestingly th... | 4,498 | 165 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_097\sol1.py | python | Python | """
The first known prime found to exceed one million digits was discovered in 1999,
and is a Mersenne prime of the form 2**6972593 - 1; it contains exactly 2,098,960
digits. Subsequently other Mersenne primes, of the form 2**p - 1, have been found
which contain more digits.
However, in 2004 there was found a massive n... | 1,294 | 47 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_099\sol1.py | python | Python | """
Problem:
Comparing two numbers written in index form like 2'11 and 3'7 is not difficult, as any
calculator would confirm that 2^11 = 2048 < 3^7 = 2187.
However, confirming that 632382^518061 > 519432^525806 would be much more difficult, as
both numbers contain over three million digits.
Using base_exp.txt, a 22K... | 1,064 | 37 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_100\sol1.py | python | Python | """
Project Euler Problem 100: https://projecteuler.net/problem=100
If a box contains twenty-one coloured discs, composed of fifteen blue discs and
six red discs, and two discs were taken at random, it can be seen that
the probability of taking two blue discs, P(BB) = (15/21) x (14/20) = 1/2.
The next such arrangemen... | 1,324 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_101\sol1.py | python | Python | """
If we are presented with the first k terms of a sequence it is impossible to say with
certainty the value of the next term, as there are infinitely many polynomial functions
that can model the sequence.
As an example, let us consider the sequence of cube
numbers. This is defined by the generating function,
u(n) = ... | 6,674 | 221 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_102\sol1.py | python | Python | """
Three distinct points are plotted at random on a Cartesian plane,
for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.
Consider the following two triangles:
A(-340,495), B(-153,-910), C(835,-947)
X(-175,41), Y(-421,-714), Z(574,-645)
It can be verified that triangle ABC contains the origin, whereas
tr... | 2,472 | 83 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_104\sol1.py | python | Python | """
Project Euler Problem 104 : https://projecteuler.net/problem=104
The Fibonacci sequence is defined by the recurrence relation:
Fn = Fn-1 + Fn-2, where F1 = 1 and F2 = 1.
It turns out that F541, which contains 113 digits, is the first Fibonacci number
for which the last nine digits are 1-9 pandigital (contain all ... | 3,106 | 142 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_107\sol1.py | python | Python | """
The following undirected network consists of seven vertices and twelve edges
with a total weight of 243.

The same network can be represented by the matrix below.
A B C D E F G
A - 16 12 21 - - -
B 16 - - 17 20 - -
C 12 - - 28 - 31 -
D 21 17 28 - 18 19 23
... | 4,352 | 131 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_109\sol1.py | python | Python | """
In the game of darts a player throws three darts at a target board which is
split into twenty equal sized sections numbered one to twenty.

The score of a dart is determined by the number of the region that the dart
lands in. A dart landing outside the red/green outer ring scores zero. The black
and cream regions ... | 3,157 | 90 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_112\sol1.py | python | Python | """
Problem 112: https://projecteuler.net/problem=112
Working from left-to-right if no digit is exceeded by the digit to its left it is
called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing
number; for example, 66420.
We shall call a pos... | 2,783 | 92 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_113\sol1.py | python | Python | """
Project Euler Problem 113: https://projecteuler.net/problem=113
Working from left-to-right if no digit is exceeded by the digit to its left it is
called an increasing number; for example, 134468.
Similarly if no digit is exceeded by the digit to its right it is called a decreasing
number; for example, 66420.
We ... | 1,947 | 76 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_114\sol1.py | python | Python | """
Project Euler Problem 114: https://projecteuler.net/problem=114
A row measuring seven units in length has red blocks with a minimum length
of three units placed on it, such that any two red blocks
(which are allowed to be different lengths) are separated by at least one grey square.
There are exactly seventeen way... | 1,659 | 59 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_115\sol1.py | python | Python | """
Project Euler Problem 115: https://projecteuler.net/problem=115
NOTE: This is a more difficult version of Problem 114
(https://projecteuler.net/problem=114).
A row measuring n units in length has red blocks
with a minimum length of m units placed on it, such that any two red blocks
(which are allowed to be differ... | 1,859 | 63 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_116\sol1.py | python | Python | """
Project Euler Problem 116: https://projecteuler.net/problem=116
A row of five grey square tiles is to have a number of its tiles
replaced with coloured oblong tiles chosen
from red (length two), green (length three), or blue (length four).
If red tiles are chosen there are exactly seven ways this can be done.
... | 2,106 | 65 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_117\sol1.py | python | Python | """
Project Euler Problem 117: https://projecteuler.net/problem=117
Using a combination of grey square tiles and oblong tiles chosen from:
red tiles (measuring two units), green tiles (measuring three units),
and blue tiles (measuring four units),
it is possible to tile a row measuring five units in length
in exactly ... | 1,590 | 54 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_119\sol1.py | python | Python | """
Problem 119: https://projecteuler.net/problem=119
Name: Digit power sum
The number 512 is interesting because it is equal to the sum of its digits
raised to some power: 5 + 1 + 2 = 8, and 8^3 = 512. Another example of a number
with this property is 614656 = 28^4. We shall define an to be the nth term of
this sequ... | 1,289 | 52 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_120\sol1.py | python | Python | """
Problem 120 Square remainders: https://projecteuler.net/problem=120
Description:
Let r be the remainder when (a-1)^n + (a+1)^n is divided by a^2.
For example, if a = 7 and n = 3, then r = 42: 6^3 + 8^3 = 728 ≡ 42 mod 49.
And as n varies, so too will r, but for a = 7 it turns out that r_max = 42.
For 3 ≤ a ≤ 1000,... | 856 | 33 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_121\sol1.py | python | Python | """
A bag contains one red disc and one blue disc. In a game of chance a player takes a
disc at random and its colour is noted. After each turn the disc is returned to the
bag, an extra red disc is added, and another disc is taken at random.
The player pays £1 to play and wins if they have taken more blue discs than r... | 2,130 | 65 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_122\sol1.py | python | Python | """
Project Euler Problem 122: https://projecteuler.net/problem=122
Efficient Exponentiation
The most naive way of computing n^15 requires fourteen multiplications:
n x n x ... x n = n^15.
But using a "binary" method you can compute it in six multiplications:
... | 2,728 | 90 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_123\sol1.py | python | Python | """
Problem 123: https://projecteuler.net/problem=123
Name: Prime square remainders
Let pn be the nth prime: 2, 3, 5, 7, 11, ..., and
let r be the remainder when (pn-1)^n + (pn+1)^n is divided by pn^2.
For example, when n = 3, p3 = 5, and 43 + 63 = 280 ≡ 5 mod 25.
The least value of n for which the remainder first e... | 2,399 | 102 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_125\sol1.py | python | Python | """
Problem 125: https://projecteuler.net/problem=125
The palindromic number 595 is interesting because it can be written as the sum
of consecutive squares: 6^2 + 7^2 + 8^2 + 9^2 + 10^2 + 11^2 + 12^2.
There are exactly eleven palindromes below one-thousand that can be written as
consecutive square sums, and the sum o... | 1,614 | 58 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_129\sol1.py | python | Python | """
Project Euler Problem 129: https://projecteuler.net/problem=129
A number consisting entirely of ones is called a repunit. We shall define R(k) to be
a repunit of length k; for example, R(6) = 111111.
Given that n is a positive integer and GCD(n, 10) = 1, it can be shown that there
always exists a value, k, for wh... | 1,595 | 58 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_131\sol1.py | python | Python | """
Project Euler Problem 131: https://projecteuler.net/problem=131
There are some prime values, p, for which there exists a positive integer, n,
such that the expression n^3 + n^2p is a perfect cube.
For example, when p = 19, 8^3 + 8^2 x 19 = 12^3.
What is perhaps most surprising is that for each prime with this pr... | 1,250 | 54 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_135\sol1.py | python | Python | """
Project Euler Problem 135: https://projecteuler.net/problem=135
Given the positive integers, x, y, and z, are consecutive terms of an arithmetic
progression, the least value of the positive integer, n, for which the equation,
x2 - y2 - z2 = n, has exactly two solutions is n = 27:
342 - 272 - 202 = 122 - 92 - 62 =... | 1,846 | 56 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_136\sol1.py | python | Python | """
Project Euler Problem 136: https://projecteuler.net/problem=136
Singleton Difference
The positive integers, x, y, and z, are consecutive terms of an arithmetic progression.
Given that n is a positive integer, the equation, x^2 - y^2 - z^2 = n,
has exactly one solution when n = 20:
13... | 1,590 | 64 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_144\sol1.py | python | Python | """
In laser physics, a "white cell" is a mirror system that acts as a delay line for the
laser beam. The beam enters the cell, bounces around on the mirrors, and eventually
works its way back out.
The specific white cell we will be considering is an ellipse with the equation
4x^2 + y^2 = 100
The section correspondin... | 3,936 | 101 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_145\sol1.py | python | Python | """
Project Euler problem 145: https://projecteuler.net/problem=145
Author: Vineet Rao, Maxim Smolskiy
Problem statement:
Some positive integers n have the property that the sum [ n + reverse(n) ]
consists entirely of odd (decimal) digits.
For instance, 36 + 63 = 99 and 409 + 904 = 1313.
We will call such numbers reve... | 4,334 | 154 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_164\sol1.py | python | Python | """
Project Euler Problem 164: https://projecteuler.net/problem=164
Three Consecutive Digital Sum Limit
How many 20 digit numbers n (without any leading zero) exist such that no three
consecutive digits of n have a sum greater than 9?
Brute-force recursive solution with caching of intermediate results.
"""
def sol... | 1,710 | 66 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_173\sol1.py | python | Python | """
Project Euler Problem 173: https://projecteuler.net/problem=173
We shall define a square lamina to be a square outline with a square "hole" so that
the shape possesses vertical and horizontal symmetry. For example, using exactly
thirty-two square tiles we can form two different square laminae:
With one-hundred ti... | 1,266 | 41 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_174\sol1.py | python | Python | """
Project Euler Problem 174: https://projecteuler.net/problem=174
We shall define a square lamina to be a square outline with a square "hole" so that
the shape possesses vertical and horizontal symmetry.
Given eight tiles it is possible to form a lamina in only one way: 3x3 square with a
1x1 hole in the middle. How... | 1,664 | 55 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_180\sol1.py | python | Python | """
Project Euler Problem 234: https://projecteuler.net/problem=234
For any integer n, consider the three functions
f1,n(x,y,z) = x^(n+1) + y^(n+1) - z^(n+1)
f2,n(x,y,z) = (xy + yz + zx)*(x^(n-1) + y^(n-1) - z^(n-1))
f3,n(x,y,z) = xyz*(xn-2 + yn-2 - zn-2)
and their combination
fn(x,y,z) = f1,n(x,y,z) + f2,n(x,y,z) ... | 5,939 | 175 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_187\sol1.py | python | Python | """
Project Euler Problem 187: https://projecteuler.net/problem=187
A composite is a number containing at least two prime factors.
For example, 15 = 3 x 5; 9 = 3 x 3; 12 = 2 x 2 x 3.
There are ten composites below thirty containing precisely two,
not necessarily distinct, prime factors: 4, 6, 9, 10, 14, 15, 21, 22, 2... | 4,674 | 163 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_188\sol1.py | python | Python | """
Project Euler Problem 188: https://projecteuler.net/problem=188
The hyperexponentiation of a number
The hyperexponentiation or tetration of a number a by a positive integer b,
denoted by a↑↑b or b^a, is recursively defined by:
a↑↑1 = a,
a↑↑(k+1) = a(a↑↑k).
Thus we have e.g. 3↑↑2 = 3^3 = 27, hence 3↑↑3 = 3^27 = ... | 1,901 | 69 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_190\sol1.py | python | Python | """
Project Euler Problem 190: https://projecteuler.net/problem=190
Maximising a Weighted Product
Let S_m = (x_1, x_2, ..., x_m) be the m-tuple of positive real numbers with
x_1 + x_2 + ... + x_m = m for which P_m = x_1 * x_2^2 * ... * x_m^m is maximised.
For example, it can be verified that |_ P_10 _| = 4112
(|_ _|... | 1,248 | 49 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_191\sol1.py | python | Python | """
Prize Strings
Problem 191
A particular school offers cash rewards to children with good attendance and
punctuality. If they are absent for three consecutive days or late on more
than one occasion then they forfeit their prize.
During an n-day period a trinary string is formed for each child consisting
of L's (lat... | 3,329 | 105 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_203\sol1.py | python | Python | """
Project Euler Problem 203: https://projecteuler.net/problem=203
The binomial coefficients (n k) can be arranged in triangular form, Pascal's
triangle, like this:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 ... | 3,904 | 118 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_205\sol1.py | python | Python | """
Project Euler Problem 205: https://projecteuler.net/problem=205
Peter has nine four-sided (pyramidal) dice, each with faces numbered 1, 2, 3, 4.
Colin has six six-sided (cubic) dice, each with faces numbered 1, 2, 3, 4, 5, 6.
Peter and Colin roll their dice and compare totals: the highest total wins.
The result i... | 2,346 | 76 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_206\sol1.py | python | Python | """
Project Euler Problem 206: https://projecteuler.net/problem=206
Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,
where each “_” is a single digit.
-----
Instead of computing every single permutation of that number and going
through a 10^9 search space, we can narrow it down conside... | 2,256 | 75 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_207\sol1.py | python | Python | """
Project Euler Problem 207: https://projecteuler.net/problem=207
Problem Statement:
For some positive integers k, there exists an integer partition of the form
4**t = 2**t + k, where 4**t, 2**t, and k are all positive integers and t is a real
number. The first two such partitions are 4**1 = 2**1 + 2 and
4**1.58496... | 2,928 | 101 |
Python | TheAlgorithms/Python | TheAlgorithms | 220,221 | MIT | All Algorithms implemented in Python | project_euler\problem_234\sol1.py | python | Python | """
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... | 3,388 | 120 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.