My Project Euler track in Rust. Every solution is commented, and some problems feature multiple solutions.
This project uses Cargo
. With rust
installed on your machine, you can execute my code with:
$ cargo run
The main program then asks for a Problem number to run, which you can enter in the command line:
$ cargo run
Compiling ...
Finished ...
Running ...
Problem number:
1
Alternatively, you can directly pass the problem number as an environment argument:
$ cargo run 1
Compiling ...
Finished ...
Running ...
Problem 1 solution: ...
Finally, I have configured unit tests for each problem. You can run them with:
$ cargo test
or to run a specific test:
$ cargo test test_problem1
Some problems have multiple solutions, and the unit tests are configured to run all of them.
$ cargo test test_problem1_v2
Some solutions, such as the one for Problem 23, take a few more seconds to run than the others. Corresponding tests are ignored by default, but you can run them with:
$ cargo test -- --ignored
or to run all tests, ignored or not:
$ cargo test -- --include-ignored
- Problem 1: Multiples of 3 or 5
- Problem 2: Even Fibonacci Numbers
- Problem 3: Largest Prime Factor
- Problem 4: Largest Palindrome Product
- Problem 5: Smallest Multiple
- Problem 6: Sum Square Difference
- Problem 7: 10001st Prime
- Problem 8: Largest Product in a Series
- Problem 9: Special Pythagorean Triplet
- Problem 10: Summation of Primes
- Problem 11: Largest Product in a Grid
- Problem 12: Highly Divisible Triangular Number
- Problem 13: Large Sum
- Problem 14: Longest Collatz Sequence
- Problem 15: Lattice Paths
- Problem 16: Power Digit Sum
- Problem 17: Number Letter Counts
- Problem 18: Maximum Path Sum I
- Problem 19: Counting Sundays
- Problem 20: Factorial Digit Sum
- Problem 21: Amicable Numbers
- Problem 22: Names Scores
- Problem 23: Non-Abundant Sums
- Problem 24: Lexicographic Permutations
- Problem 25: 1000-digit Fibonacci Number
- Problem 26: Reciprocal Cycles
- Problem 27: Quadratic Primes
- Problem 28: Number Spiral Diagonals
- Problem 29: Distinct Powers
- Problem 30: Digit Fifth Powers
This work is licensed under the CC-BY-NC-SA 4.0 license. Original content is the property of the Project Euler website and also licensed under CC-BY-NC-SA 4.0.