Skip to content
/ euler Public

My Project Euler solutions & a CLI to access them.

Notifications You must be signed in to change notification settings

aaheen/euler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Euler Solutions CLI

aaheen Project Euler profile badge

I have tried to generalize these solutions somewhat, so they can be repurposed later. Each subdirectory of ans is numbered according to the problem it solves on Project Euler. Presently, I have only a few problems solved. If in the future this number grows, I will most likely fork this repository and make it private, leaving only the first 100 open for outside examination.

Structure:

  • This is all under the Go module aaheen/euler.
  • main accesses answers through the ans package, through the Sol(p int) and Ask(p int) functions, where p is the problem number.
  • Each problem is contained in its own sub-package of ans, named p<number>.
  • Example: The full name for the package that contains the solution for Problem 3 is m9ple/euler/ans/p3. To get the exact answer for Problem 3, call ans.Sol(3). To run the interactive session for Problem 3, call ans.Ask(3).
  • Note: All of the $$ you see in problem READMEs is just unrendered LaTeX. GitHub does not currently support any easy method of rendering LaTeX. This is such a hotly demanded feature that I have to believe they will implement it sometime relatively soon.
    • What I do: If you use a chromium-based browser, I highly recommend using AaronCQL's LaTeX on GitHub extension, Chrome Web Store version
    • xhub is a GitLab-flavored math workaround that I considered using, but decided against it.
    • Codecogs is also a great resource, I just didn't feel like it.

The euler CLI

A command line utility used to run any implemented solution and open URLs to specific problems this repo. All solutions are compiled into it, so it's portable.

The ans package just grabs from two big map[int]func() (declared in probmap.go), where the index corresponds to the problem number. I have struggled trying to come up with a more elegant implementation, but right now I'm not sure what that would be.

Usage:

euler  <p>     - Run the solution for problem <p>. Directly outputs answer
    -i <p>     - Run the interactive solution session for problem <p>
    -g         - Open this repo at github.com/m9ple/euler
    -g <p>     - Open the subdirectory for problem <p> on github.

Portrait of Leonhard Euler

About

My Project Euler solutions & a CLI to access them.

Topics

Resources

Stars

Watchers

Forks

Languages