Skip to content

pythagorean-triplet: new tests require non-trivial solution #1347

Open
@omer-g

Description

@omer-g

I recently rewrote the Python version of this exercise based on canonical data 1.0.0.

I wanted to update that the trivial solution for finding triplets in a range by brute force takes a very long time on the latest tests (for example this). Almost all solutions I saw used this method and will not finish in reasonable time (if at all). I think it would be difficult for people to find an efficient solution by themselves. Perhaps a hint should be given?

The previous example.py would not handle these tests as well. The new example.py solves the tests quickly. It generates triplets in range efficiently by building triplets from multiples of primitive triplets.

Overall I think the new tests make the exercise more interesting. However, I think it would be difficult for people to come up with an efficient enough solution to pass them in reasonable time. I would be happy to hear what others think.

(related to #1211 )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions