Skip to content

Over 700 solutions. All satisfy the 1-minute rule.

Notifications You must be signed in to change notification settings

kevinychen/project-euler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Euler Java library and solutions

Java programs for Project Euler. Every solution satisfies the one-minute rule. Most solutions complete in less than a few seconds.

To keep with the spirit of Project Euler, each solution after the first 100 problems is encrypted with its corresponding answer. They can be decrypted with the setup steps below.

Level Problems Total time to run 25 solutions
1 1 to 25 0.3 seconds
2 26 to 50 0.8 seconds
3 51 to 75 1.8 seconds
4 76 to 100 1.0 seconds
5 101 to 125 0.7 seconds
6 126 to 150 1.1 seconds
7 151 to 175 2.6 seconds
8 176 to 200 2.1 seconds
9 201 to 225 4.4 seconds
10 226 to 250 5.5 seconds
11 251 to 275 25.4 seconds
12 276 to 300 8.9 seconds
13 301 to 325 8.1 seconds
14 326 to 350 10.8 seconds
15 351 to 375 14.0 seconds
16 376 to 400 13.2 seconds
17 401 to 425 31.0 seconds
18 426 to 450 18.6 seconds
19 451 to 475 30.4 seconds
20 476 to 500 25.1 seconds
21 501 to 525 18.5 seconds
22 526 to 550 24.5 seconds
23 551 to 575 55.7 seconds
24 576 to 600 35.3 seconds
25 601 to 625 29.2 seconds
26 626 to 650 37.2 seconds
27 651 to 675 16.4 seconds
28 676 to 700 37.7 seconds
29 701 to 725 26.7 seconds
30 726 to 750 37.9 seconds
31+ 751+ In progress!

(Run on Apple M2 Max.)

One-time setup

The solution files are encrypted. To decrypt them, you need a file named answers.txt in the root directory with the following format:

1. answer to Problem 1
2. answer to Problem 2
...

This file does not need to include all the answers, but only solution files with an included answer will be decrypted.

To generate this file automatically for all problems that you've solved on the Project Euler website, run this in the root directory:

$ ./gradlew fetchAnswers

You will be prompted to enter your Project Euler credentials. The task will generate an answers.txt file with answers for all solved problems on your account. It doesn't make any changes to your account.

Now run the following:

$ ./scripts/setup.sh

Files in Git will now be automatically decrypted, and files added to Git will be automatically encrypted.

The setup.sh script must be re-run if any changes are manually made to the answers.txt file.

Running tests

Each solution is a JUnit test that can be run in your IDE, or directly in Gradle:

$ ./gradlew test --tests *p001 // runs the program for Problem 1

To run all tests (takes a few minutes):

$ ./gradlew test

Development

This repository requires Java 8+.

For IntelliJ, run ./gradlew idea and open the project, or use the native Gradle integration.

For Eclipse, run ./gradlew eclipse and then import "Existing Projects into Workspace". You will also need to setup Lombok.

About

Over 700 solutions. All satisfy the 1-minute rule.

Topics

Resources

Stars

Watchers

Forks