GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Return slope 0 for horizontal lines and fix duplicate count in MaxPointsOnALine by lyn1dev · Pull Request #216 · spring1843/go-dsa

Conversation

@lyn1dev

@lyn1dev lyn1dev commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Fixes issue #202

What is being changed?

  • In hashtable/max_points_on_line.go, calculateSlope now returns 0 instead of 1 when a[1] == b[1], so horizontal lines no longer collide with lines of slope 1.
  • localMax is initialized to 0 instead of 1 per anchor point so that inputs where all remaining points duplicate the anchor point return samePoint + 1 rather than samePoint + 2.
  • Added regression cases to TestMaxPointsOnALine covering horizontal lines alongside a 45-degree pair, a 3-point horizontal line, and all-identical points. These cases fail before the change (Failed test case #7. Want 2 got 3) and pass with 100% statement coverage in ./hashtable.

What are the advantages of this change over what exists?

MaxPointsOnALine distinguishes horizontal segments (slope == 0) from 45-degree segments (slope == 1) and returns the exact count when all input points have identical coordinates.

What are the downsides of this change?

None beyond continuing to represent slopes as float64, matching the existing implementation.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

AI was used to write this code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lyn1dev
Return slope 0 for horizontal lines and fix duplicate count in MaxPoi…
3fdfe6f
…ntsOnALine
@spring1843
spring1843 self-requested a review November 26, 2026 21:23
spring1843
spring1843 approved these changes Nov 26, 2026
View reviewed changes

@spring1843 spring1843 left a comment

Copy link
Copy Markdown
Owner

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

LGTM Thank you for your contribution.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@spring1843
spring1843 merged commit 701219b into spring1843:main Nov 26, 2026
3 checks passed

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@spring1843 spring1843 spring1843 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@lyn1dev @spring1843
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.