Skip to content

Commit

Permalink
Merged with main, fixing conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
tfpf committed Mar 20, 2024
2 parents bd893ba + 1444db2 commit 53ced36
Show file tree
Hide file tree
Showing 27 changed files with 4,612 additions and 239 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: lint
on: [push, workflow_dispatch]
on:
push:
paths:
- '.github/workflows/lint.yml'
- '**.rs'
workflow_dispatch:

jobs:
lint:
Expand Down
14 changes: 11 additions & 3 deletions .github/workflows/sanity.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
name: sanity
on: [push, workflow_dispatch]
on:
push:
paths:
- '.github/workflows/sanity.yml'
- 'Dockerfile'
- 'res/*.txt'
- '!res/*_test.txt'
- '**.rs'
workflow_dispatch:

jobs:
sanity32:
Expand All @@ -15,7 +23,7 @@ jobs:
- uses: addnab/docker-run-action@v3
with:
image: sanity32
run: cargo -vv run --release
run: cargo -vv run -vv --release
sanity64:
name: sanity on 64-bit ${{ matrix.os }}
runs-on: ${{ matrix.os }}
Expand All @@ -24,4 +32,4 @@ jobs:
os: [macos-12, ubuntu-22.04, windows-2022]
steps:
- uses: actions/checkout@v4
- run: cargo -vv run --release
- run: cargo -vv run -vv --release
10 changes: 8 additions & 2 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
name: style
on: [push, workflow_dispatch]
on:
push:
paths:
- '.github/workflows/style.yml'
- 'rustfmt.toml'
- '**.rs'
workflow_dispatch:

jobs:
style:
name: style
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: cargo fmt --check
- run: cargo fmt -v --check
5 changes: 4 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: tests
on:
push:
paths:
- src/utils.rs
- '.github/workflows/tests.yml'
- 'Dockerfile'
- 'src/utils.rs'
- 'res/*_test.txt'
workflow_dispatch:

jobs:
Expand Down
3 changes: 3 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Code of Conduct

Just be cool (optional).
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
# Contributing

Not accepting pull requests, since this is my personal learning project.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name = "project-euler"
version = "1.0.0"
edition = "2021"

[dev-dependencies]
criterion = "0.4.0"

[[bench]]
name = "benches"
harness = false

[profile.release]
incremental = true
strip = "debuginfo"
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Project Euler
Trying my hand at [Project Euler](https://projecteuler.net) as I stumble along learning Rust. I shall only add the
solutions to the first hundred problems here with the intention being to showcase whatever useful data structures I
build along the way. This is permitted according to the Project Euler guidelines.
build along the way. (This is permitted according to the Project Euler guidelines.) Further, I shall restrict myself to
the standard library.

[![style](https://github.com/tfpf/project-euler/actions/workflows/style.yml/badge.svg)](https://github.com/tfpf/project-euler/actions/workflows/style.yml)
[![lint](https://github.com/tfpf/project-euler/actions/workflows/lint.yml/badge.svg)](https://github.com/tfpf/project-euler/actions/workflows/lint.yml)
Expand Down Expand Up @@ -116,8 +117,11 @@ such as (but not limited to) Bard and ChatGPT.
|[68](https://projecteuler.net/problem=68)|[`magic_5_gon_ring.rs`](src/solutions/magic_5_gon_ring.rs)|
|[69](https://projecteuler.net/problem=69)|[`totient_maximum.rs`](src/solutions/totient_maximum.rs)|
|[70](https://projecteuler.net/problem=70)|[`totient_permutation.rs`](src/solutions/totient_permutation.rs)|
|[71](https://projecteuler.net/problem=71)|[`ordered_fractions.rs`](src/solutions/ordered_fractions.rs)|
|[74](https://projecteuler.net/problem=74)|[`digit_factorial_chains.rs`](src/solutions/digit_factorial_chains.rs)|
|[75](https://projecteuler.net/problem=75)|[`singular_integer_right_triangles.rs`](src/solutions/singular_integer_right_triangles.rs)|
|[76](https://projecteuler.net/problem=76)|[`counting_summations.rs`](src/solutions/counting_summations.rs)|
|[77](https://projecteuler.net/problem=77)|[`prime_summations.rs`](src/solutions/prime_summations.rs)|
|[81](https://projecteuler.net/problem=81)|[`path_sum_two_ways.rs`](src/solutions/path_sum_two_ways.rs)|
|[85](https://projecteuler.net/problem=85)|[`counting_rectangles.rs`](src/solutions/counting_rectangles.rs)|
|[87](https://projecteuler.net/problem=87)|[`prime_power_triples.rs`](src/solutions/prime_power_triples.rs)|
Expand Down
16 changes: 16 additions & 0 deletions benches/benches.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use project_euler::utils;

pub fn is_prime(c: &mut criterion::Criterion) {
c.bench_function("is_prime", |b| {
b.iter(|| (0..10i64.pow(5)).map(utils::is_prime).count())
});
}

pub fn sieve_of_atkin(c: &mut criterion::Criterion) {
c.bench_function("sieve_of_atkin", |b| {
b.iter(|| utils::SieveOfAtkin::new(10usize.pow(6)))
});
}

criterion::criterion_group!(benches, is_prime, sieve_of_atkin);
criterion::criterion_main!(benches);
Loading

0 comments on commit 53ced36

Please sign in to comment.