Skip to content

Added solution for Project Euler problem 144 #4280

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

Merged
merged 4 commits into from
Jul 8, 2021
Merged

Added solution for Project Euler problem 144 #4280

merged 4 commits into from
Jul 8, 2021

Conversation

fpringle
Copy link
Contributor

Problem 144: Investigating multiple reflections of a laser beam

In laser physics, a "white cell" is a mirror system that acts as a delay line for the laser beam. The beam enters the cell, bounces around on the mirrors, and eventually works its way back out.

The specific white cell we will be considering is an ellipse with the equation 4x2 + y2 = 100

The section corresponding to −0.01 ≤ x ≤ +0.01 at the top is missing, allowing the light to enter and exit through the hole.

The light beam in this problem starts at the point (0.0,10.1) just outside the white cell, and the beam first impacts the mirror at (1.4,-9.6).

Each time the laser beam hits the surface of the ellipse, it follows the usual law of reflection "angle of incidence equals angle of reflection." That is, both the incident and reflected beams make the same angle with the normal line at the point of incidence.

In the figure on the left, the red line shows the first two points of contact between the laser beam and the wall of the white cell; the blue line shows the line tangent to the ellipse at the point of incidence of the first bounce.

The slope m of the tangent line at any point (x,y) of the given ellipse is: m = −4x/y

The normal line is perpendicular to this tangent line at the point of incidence.

The animation on the right shows the first 10 reflections of the beam.

How many times does the beam hit the internal surface of the white cell before exiting?

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new Python files are placed inside an existing directory.
  • All filenames are in all lowercase characters with no spaces or dashes.
  • All functions and variable names follow Python naming conventions.
  • All function parameters and return values are annotated with Python type hints.
  • All functions have doctests that pass the automated testing.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

@ghost ghost added the awaiting reviews This PR is ready to be reviewed label Mar 20, 2021
Copy link
Member

@l3str4nge l3str4nge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve conflicts.

@ghost ghost added awaiting changes A maintainer has requested changes to this PR awaiting reviews This PR is ready to be reviewed and removed awaiting reviews This PR is ready to be reviewed awaiting changes A maintainer has requested changes to this PR labels Mar 24, 2021
Copy link
Member

@dhruvmanila dhruvmanila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small nitpick and then this will be good to go. Thanks for doing this :)

@ghost ghost added awaiting changes A maintainer has requested changes to this PR awaiting reviews This PR is ready to be reviewed and removed awaiting reviews This PR is ready to be reviewed awaiting changes A maintainer has requested changes to this PR labels Apr 28, 2021
@stale
Copy link

stale bot commented Jun 2, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Jun 2, 2021
@stale stale bot removed the stale Used to mark an issue or pull request stale. label Jun 4, 2021
@stale
Copy link

stale bot commented Jul 8, 2021

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Used to mark an issue or pull request stale. label Jul 8, 2021
@XmenchoX
Copy link

XmenchoX commented Jul 8, 2021 via email

@stale stale bot removed the stale Used to mark an issue or pull request stale. label Jul 8, 2021
@ghost ghost removed the awaiting reviews This PR is ready to be reviewed label Jul 8, 2021
@dhruvmanila dhruvmanila dismissed l3str4nge’s stale review July 8, 2021 08:34

Conflicts resolved.

@dhruvmanila dhruvmanila merged commit 8c13a77 into TheAlgorithms:master Jul 8, 2021
@fpringle fpringle deleted the problem_144 branch July 8, 2021 12:58
shermanhui pushed a commit to shermanhui/Python that referenced this pull request Oct 22, 2021
* Added solution for Project Euler problem 144

* updating DIRECTORY.md

* Better variable names

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants