Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pythagorean Triplet] Fix typos in Approaches Introduction Docs. #3742

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The problem space can easily become very large, and 'naive' or more 'brute force
There are three reasonably common variations to this problem
1. A [cubic time][approaches-cubic] solution, which uses highly nested loops and is non-performant.
2. A [quadratic time][approaches-quadratic] solution, which uses one nested loop, and is reasonably easy to figure out.
3. A [linear time][approaches-linear] solution, requiring some deeper understanding of the mathematics of finding trplets.
3. A [linear time][approaches-linear] solution, requiring some deeper understanding of the mathematics of finding triplets.


If those terms are unclear to you, you might like to read about [time complexity][time-complexity], and how it is described by [asymptotic notation][asymptotic-notation].
Expand Down Expand Up @@ -68,7 +68,7 @@ This gives a substantial speed advantage, allowing the tests to run to completio

However, the Exercism online test runner will still time out with this solution.

Examining the code, it is clear that the upper bounds on the `loop` variables are far too generous, and too much work is bing done.
Examining the code, it is clear that the upper bounds on the `loop` variables are far too generous, and too much work is being done.


The solution below tightens the bounds and pre-calculates `c * c` in the outer `loop`.
Expand Down Expand Up @@ -171,7 +171,7 @@ def triplets_with_sum(number):
If we could be sure that the code only had to handle small values of `n`, a quadratic method would have the advantage of clarity.

However, the test suite goes up to 30_000, and the online test runner quickly times out.
We therefor need to accept some less readable code and use a linear-time implementation.
We therefore need to accept some less readable code and use a linear-time implementation.

Full details of run-time benchmarking are given in the [Performance article][article-performance].

Expand Down
Loading