Skip to content

Embi/euler

Repository files navigation

Introduction

This is a fun project that:

  1. Implements a script euler.py for managing algo/math problems from projecteuler. The script is able to:
    • download problem description and all necessary input files
    • initialize directory structure for the problem with boilerplate solution files (see templates)
    • auto-tag problem using an LLM (e.g., #Combinatorics #BinomialCoefficient)
    • prompt an LLM to generate a solution
    • collect run statistics for my solutions and LLM solutions
  2. Collects all of my solutions to the projecteuler problems.
  3. Neatly presents all my, and LLM solutions in a markdown table, including runtime statistics (cpu, wall time)

Dependencies

System dependencies:

  • Python3
  • python-pip
  • Vim
  • Brave
  • pandoc
  • wget

Python dependencies:

pip install -r requirements.txt

Environment

The following env variable should be exposed before running

OPENAI_API_KEY=somekey
OPENAI_ORG=someorg

LLMs

LLMs in this project are utilize primarily to compare my solutions with solutions generated by state-of-art LLMs. A.k.a to answer the question whether my existence is still needed.

prompt used to obtain solutions

Solve the following problem in Python and make the
solution accessible via an argument-less function called
'solution'. The result returned by the 'solution' function
must be an integer value. The solution should be as
fast as possible. Do not output any other text in
your response other than the python code. Don't use
any third party libraries. Here is the problem: {readme}

prompt used to obtain tags

Create two tags. Each tag must consist of exactly one word
and be prefixed by a hash character. Separate the tags by
one space and never use a newline. These tags should describe
the nature of the following problem: {readme}

Usage

Make sure all dependencies are installed and make the euler.py script executable:

chmod u+x euler.py
  • to print help
./euler.py
  • to start solving a particular problem:
./euler.py solve 42
  • to prompt a LLM for a solution to a particular problem
./euler.py llm 42 gpt4
  • to execute my python solution to a problem
./euler.py run 42
  • to execute llm solution to a problem
./euler.py run 42 gpt4
  • to list available llms
./euler.py list-models
./euler.py stats

Solutions

Table explanation:

  • tags are auto-generated by gpt-3.5-turbo
  • problem ID links to the problem dir (where a full problem description can be found) and corresponds to the ID from project euler archive
  • solution columns (e.g. py) contain wall(cpu) time of the solution that they link to. All solutions were ran on 11th Gen Intel(R) Core(TM) i5-11400F @ 2.60GHz
  • {model}_py are solutions generated by various LLMs (e.g., gpt3_py, gpt4_py)
id tags py gpt3_py gpt4_py
1 #Multiples #Summation 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
2 #Fibonacci #Summation 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
3 #primefactors #largestprime 0.026s(0.026s) 0.000s(0.000s) 0.000s(0.000s)
4 #Palindrome #Multiplication 0.000s(0.000s) 0.163s(0.163s) 0.063s(0.063s)
5 #smallestnumber #divisibility 0.000s(0.000s) 0.012s(0.012s) 0.000s(0.000s)
6 #Arithmetic #Algebra 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
7 #prime #number 0.039s(0.039s) 1.278s(1.277s) 0.035s(0.035s)
8 #digitproduct #adjacentdigits 0.002s(0.002s) 0.001s(0.001s) 0.001s(0.001s)
9 #Pythagorean #Triplet 0.004s(0.004s) 0.085s(0.085s) 0.013s(0.013s)
10 #PrimeNumbers #Summation 1.606s(1.605s) 0.148s(0.148s) 2.344s(2.343s)
11 #grid #product 0.003s(0.004s) 0.000s(0.000s) 0.000s(0.000s)
12 #TriangleNumbers #Divisors 0.711s(1.368s) 1.720s(1.720s) 1.752s(1.752s)
13 #sum #largeNumbers 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
14 #Collatz #LongestChain 5.595s(5.590s) 7.577s(7.575s) 0.499s(0.499s)
15 #Combinatorics #GridPaths 0.001s(0.003s) 0.000s(0.000s) 0.000s(0.000s)
16 #exponential #digitalsum 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
17 #WordCount #NumberWords 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
18 #maximum #triangle 0.000s(0.026s) 0.000s(0.000s) 0.000s(0.000s)
19 #date #counting 0.001s(0.001s) 0.000s(0.000s) 0.000s(0.000s)
20 #Factorial #DigitSum 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
21 #AmicableNumbers #Divisors 0.548s(0.548s) 2.414s(2.412s) 0.028s(0.028s)
22 #Sorting #AlphabeticalValue 0.003s(0.003s) 0.004s(0.004s) 0.004s(0.004s)
23 #numbertheory #sumofdivisors 3.377s(3.376s) 1.383s(1.381s) 0.637s(0.637s)
24 #Permutations #LexicographicOrder 0.000s(0.000s) Failed Failed
25 #Fibonacci #Digits 0.017s(0.017s) 0.019s(0.019s) 0.017s(0.017s)
26 #recurring #fractions 0.014s(0.014s) 0.009s(0.009s) 0.009s(0.009s)
27 #quadraticprimes #coefficientsproduct 0.075s(0.075s) 1.772s(1.771s) 0.527s(0.527s)
28 #spiral #diagonals 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
29 #integercombinations #distinctterms 0.658s(0.657s) 0.004s(0.004s) 0.003s(0.003s)
30 #digitpowers #sum 0.352s(0.352s) 1.508s(1.507s) 0.275s(0.275s)
31 #UKCurrency #CoinCombinations 2.424s(3.087s) 0.000s(0.000s) 0.000s(0.000s)
32 #pandigital #multiplication 0.051s(0.599s) 0.282s(0.282s) 0.018s(0.018s)
33 #CuriousFractions #SimplificationError 0.001s(0.001s) Failed 0.002s(0.002s)
34 #FactorialSum #CuriousNumber 4.954s(4.952s) 0.075s(0.075s) 2.200s(2.199s)
35 #CircularPrimes #PrimeNumbers 0.229s(0.229s) 4.424s(4.421s) 2.343s(2.342s)
36 #PalindromicNumbers #BinaryConversion 0.593s(0.593s) 0.195s(0.194s) 0.224s(0.224s)
37 #Truncatable #Primes 1.735s(1.734s) 1.447s(1.446s) 0.677s(0.677s)
38 #Pandigital #Concatenation 0.007s(0.007s) 0.005s(0.005s) 0.005s(0.005s)
39 #Pythagorean #Perimeter 0.040s(0.040s) 13.062s(13.058s) 0.007s(0.007s)
40 #irrationaldecimal #digitsequence 0.016s(0.015s) 0.099s(0.099s) 0.046s(0.046s)
41 #Pandigital #Prime 0.424s(0.424s) 0.140s(0.139s) 0.104s(0.104s)
42 #sequence #triangle 0.001s(0.001s) 0.001s(0.001s) 0.001s(0.001s)
43 #pandigital #sub-string-divisibility 4.609s(4.608s) 1.728s(1.727s) 1.780s(1.778s)
44 #Pentagonal #Mathematics 53.025s(52.977s) 4.132s(4.130s) 0.369s(0.369s)
45 #NumberSequence 0.610s(0.610s) 0.010s(0.010s) 0.023s(0.023s)
46 #GoldbachConjecture #NumberTheory 0.005s(0.005s) 0.004s(0.004s) 0.003s(0.003s)
47 #PrimeFactors #ConsecutiveIntegers 0.204s(0.204s) 0.366s(0.366s) Failed
48 #exponential #digitcalculation 0.005s(0.005s) 0.005s(0.005s) 0.005s(0.005s)
49 #PrimePermutation #ArithmeticSequence 0.002s(0.002s) Failed 0.302s(0.302s)
50 #consecutiveprimes #primenumbers 0.056s(0.056s) Failed 1.257s(1.257s)
51 #numbertheory #primefamily 0.968s(0.967s) Failed
52 #digitpermutation #smallestinteger 0.054s(0.054s) 0.081s(0.080s) 0.148s(0.148s)
53 #Combinatorics #BinomialCoefficient 0.006s(0.005s) 0.005s(0.005s) 0.005s(0.005s)
54 #poker #cardgames 0.039s(0.039s) Failed Failed
55 #Palindrome #Lychrel 0.094s(0.093s) 0.021s(0.021s) 0.016s(0.016s)
56 #massivenumber #digitalsum 0.065s(0.065s) 0.062s(0.062s) 0.065s(0.065s)
57 #continuedfractions #digitcomparison 0.001s(0.001s) 0.002s(0.002s) 0.001s(0.001s)
58 #Spiral #Primes 2.568s(2.567s) 4.355s(4.349s) 1.612s(1.612s)
59 #EncryptionMethod #XOR 0.280s(0.279s) 0.411s(0.406s) 0.386s(0.385s)
60 #primeconcatenation #optimization 7.232s(7.227s) Failed 56.472s(56.450s)
61 #figurate #cyclic 0.001s(0.001s) Failed 0.010s(0.010s)
62 #Permutation #Cube 0.008s(0.008s) 0.008s(0.008s) 0.008s(0.008s)
63 #PowerfulNumbers #Exponentiation 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
64 #periodic #continuedfractions 0.085s(0.085s) Failed 0.023s(0.023s)
65 #continuedfractions #numeratorsum 0.000s(0.000s) 0.000s(0.000s) 0.000s(0.000s)
66 #Diophantine #Equations 0.012s(0.012s) 0.004s(0.004s)
67 #dynamicprogramming #maximumpathsum 0.001s(0.001s) 0.005s(0.001s) 0.001s(0.001s)
68 #MagicRing #Max16DigitString 3.533s(3.531s) Failed 0.661s(0.660s)
69 #EulerTotient #Optimization 0.000s(0.000s) 8.086s(8.083s) 8.046s(8.044s)
70 #Euler #Permutation 126.488s(126.407s) 243.387s(243.123s) 47.865s(47.848s)
71 #Fraction #Reduced 0.052s(0.051s) 0.086s(0.086s) 0.093s(0.093s)
72 #prime 17.424s(17.417s) Failed 7.848s(7.845s)

About

Solutions to project Euler problems

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages