Skip to content

tvarley/euler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

174 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Euler Solutions C++ Go Java JavaScript Python Rust License: MIT

Table of Contents

This repository contains solutions to Project Euler problems in multiple programming languages.

Description

Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.

This repository provides comprehensive solutions to the first 100 Project Euler problems in six different programming languages: C++, Go, Java, JavaScript, Python, and Rust. Each language implementation demonstrates optimal algorithms, performance considerations, and language-specific best practices. The solutions serve as educational examples for learning both mathematical problem-solving and programming techniques across paradigms.

These solutions are automatically generated using AI agents, guided by engineering expertise to ensure mathematically rigorous and optimal implementations. The AI employs Chain-of-Thought prompting strategies to derive mathematical proofs before coding, enforces Big-O complexity constraints, and translates logic idiomatically across programming languages while maintaining automated verification through test-driven generation.

Note: Everything in this repository before the ai_takeover tag was hand-written. This repository is now 100% generated and maintained using AI assistance.

Project Goals

This personal research project focuses on several key objectives:

  • Increased Project Euler Coverage: Provide comprehensive solutions for the first 100 Project Euler problems
  • More Languages: Add implementations in additional programming languages to showcase diverse approaches and paradigms
  • AI vs. Human Challenges: Explore the intersection of artificial intelligence and human problem-solving, comparing algorithmic approaches and efficiency across different implementation strategies

Features

  • Multi-language implementations: Compare approaches across six programming languages
  • Optimized algorithms: Solutions designed for efficiency and clarity
  • Comprehensive testing: Unit tests verify correctness against known Project Euler answers
  • Educational value: Learn both mathematics and programming through practical examples
  • Language-specific idioms: Demonstrates best practices in each programming language
  • Complete coverage: Solutions for problems 1-100, with answers verified

Languages

This repository includes solutions in the following languages:

  • C++ - High-performance implementations using modern C++17 features
  • Go - Concurrent and efficient solutions leveraging Go's strengths
  • Java - Object-oriented approaches with comprehensive testing via Gradle
  • JavaScript - Node.js solutions with modern ES6+ syntax
  • Python - Clean, readable code following PEP 8 standards
  • Rust - Memory-safe implementations with zero-cost abstractions

Note: Ruby implementations are deprecated and no new solutions will be generated for it.

Usage

Each language directory contains solutions to Project Euler problems. To run a specific solution:

  • Go (go/): go run eulerXXX.go
  • Rust (rust/): cargo run
  • C++ (cpp/): make && ./bin/eulerXXX (e.g., ./bin/euler026)
  • Java (java/): ./gradlew run
  • JavaScript (javascript/): npm test or node src/eulerXXX.js
  • Python (python/): python src/eulerXXX.py

Examples

Running a Specific Solution

# Run Problem 1 in Python
cd python && python src/euler001.py

# Run Problem 1 in Go
cd go && go run euler001.go

# Run Problem 1 in Rust
cd rust && cargo run --bin euler001

Using Automation Scripts

# Run all solutions across all languages
./run_solutions.sh

# Run tests for all languages
./test_all.sh

# Check problem completeness
./check_problems.sh

Running Tests

C++

Tests use Catch2 framework.

cd cpp
make bin/unittest
./bin/unittest

Rust

cd rust
cargo test

JavaScript

cd javascript
npm test

Java

cd java
./gradlew test

Go

cd go
go test ./euler

Python

cd python
pytest

Contributing

Contributions are welcome! To add a new solution or improve existing ones:

  1. Choose a problem and language (C++, Go, Java, JavaScript, Python, or Rust)
  2. Implement the solution following the existing code style
  3. Add appropriate tests
  4. Update the README.md in the language directory
  5. Submit a pull request

Please ensure all tests pass and the solution is efficient.

Links

Project Euler

Current Repository

Website

License

The MIT License (MIT) Copyright (c) 2014-2026 Tim Varley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.