Documentation
¶
Overview ¶
This package contains all of the "Project Euler 100" problem solutions. Assertion tests for these can be found in `main_test.go` where test inputs are from the smaller scale (non-solution) typically provided in the question itself, in order to avoid explicitly spoiling the solution in source control.
Index ¶
- Constants
- Variables
- func CollatzNext(x int) int
- func CommaSeparatedQuotedStrings(data []byte, atEOF bool) (advance int, token []byte, err error)
- func CountAmicableUnder(limit int) int
- func CountLatticePaths(width, height int64) *big.Int
- func CountSetsOfPowers(start, until int) int64
- func CountSquareLatticePaths(d int) int64
- func CountingSundaysUsingTime(start_year, start_month, start_day, last_year, last_month, last_day int) int64
- func DigitFifthPowers(power, digits int) int64
- func DigitSeriesFile(filename string) digit_series
- func FactorialDigitSum(n int) int64
- func FindLargestPalindromeProduct(limit int) int64
- func FirstTriangleExceedingFactorCount(count_limit int) int64
- func GeneratePrimesUntil(limit uint64) <-chan uint64
- func IsPalindromicInt(number int) bool
- func LargestPrimeFactor(n int) int64
- func LexicographicPermutations(digits []int, goal int) int64
- func LongestCollatzChainStartingBelow(limit int) int64
- func LongestQuadraticPrimeRun(min, max int) int64
- func LongestReciprocalCycleLength(limit int) int
- func LongestReciprocalCycleLengthViaPatternSearch(limit int) int
- func NamesListFile(filename string) names_list
- func NonAbundantSumsUnder(limit int) int64
- func NthFibonacciExceedingDigitsCompareBigInt(num_digits int) int64
- func NthFibonacciExceedingDigitsStrlen(num_digits int) int64
- func NthPrime(limit int) int64
- func NumberGridFile(filename string) number_grid
- func NumberLetterCount(value int) int64
- func NumberListFile(digits_file string) bignum_list
- func NumberRangeLetterCount(last int) int64
- func NumberSpiralDiagonals(size int) int64
- func NumberTriangleFile(filename string) number_triangle
- func QuadraticPrimeRun(a, b int) int64
- func SmallestCommonMultiple(last int) int64
- func SpecialPythagoreanTriplet(triplet_sum int) int64
- func SqSumDifference(n int) int64
- func SumEvenFibonacciUntil(n int) int64
- func SumOf3or5_Constant(n int) int64
- func SumOf3or5_Naïve(n int) int64
- func SumOf3or5_Selective(n int) int64
- func SumOfDigitsOfPowersOfTwo(power int) int64
- func SummationOfPrimesBelow(n int) int64
- type Factors
- type SieveOfEratosthenes
Constants ¶
const ExampleN = 10
Variables ¶
var COMMA = []byte{','}
var NthFibonacciExceedingDigits = NthFibonacciExceedingDigitsStrlen
var SumOf3or5 = SumOf3or5_Constant
Problem 001 - Multiples of 3 or 5 see `/blog/001` for full commentary.
This one is pretty simple so let's see some variants.
Functions ¶
func CollatzNext ¶
Compute the next number in the sequence, where
if x is even, x' = x/2 if x is odd, x' = 3*x + 1
This is famously known as the Collatz Sequence.
func CountAmicableUnder ¶
func CountLatticePaths ¶
func CountSetsOfPowers ¶
func CountSquareLatticePaths ¶
func DigitFifthPowers ¶
func DigitSeriesFile ¶
func DigitSeriesFile(filename string) digit_series
func FactorialDigitSum ¶
func GeneratePrimesUntil ¶
func IsPalindromicInt ¶
func LargestPrimeFactor ¶
func LongestCollatzChainStartingBelow ¶
Returns the start of the longest sequence, for any start value below `limit`.
func NamesListFile ¶
func NamesListFile(filename string) names_list
func NonAbundantSumsUnder ¶
func NumberGridFile ¶
func NumberGridFile(filename string) number_grid
func NumberLetterCount ¶
func NumberListFile ¶
func NumberListFile(digits_file string) bignum_list
func NumberRangeLetterCount ¶
func NumberSpiralDiagonals ¶
func NumberTriangleFile ¶
func NumberTriangleFile(filename string) number_triangle
func QuadraticPrimeRun ¶
func SmallestCommonMultiple ¶
func SqSumDifference ¶
func SumEvenFibonacciUntil ¶
func SumOf3or5_Constant ¶
An even more efficient solution doesn't look at the numbers at all (except for the remainder at the end, which has a known bound).
func SumOf3or5_Naïve ¶
The most naive solution looks at every number in the range [1, n).
func SumOf3or5_Selective ¶
A more selective approach only looks at the numbers we know to be multiples.
func SummationOfPrimesBelow ¶
Types ¶
type SieveOfEratosthenes ¶
func NewSieve ¶
func NewSieve(limit uint64) SieveOfEratosthenes