Skip to content

feat: add aggressive cows algorithm - #3233

Open
aartigawade2586 wants to merge 1 commit into
TheAlgorithms:masterfrom
aartigawade2586:aggressive_cows
Open

aartigawade2586 wants to merge 1 commit into
TheAlgorithms:masterfrom
aartigawade2586:aggressive_cows

Conversation

@aartigawade2586

@aartigawade2586 aartigawade2586 commented Sep 27, 2026 •

Copy link
Copy Markdown

Description of Change

Added an implementation of the Aggressive Cows problem using binary search
on the answer and a greedy feasibility check.

The solution:

  • Sorts the stall positions.
  • Uses binary search to find the maximum possible minimum distance.
  • Uses a greedy approach to check whether all cows can be placed.
  • Includes self-test cases using assert().

Checklist

  • Added description of change
  • Added file name matches File name guidelines
  • Added tests and example, test must pass
  • Added documentation so that the program is self-explanatory and educational - Doxygen guidelines
  • Relevant documentation/comments is changed or added
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes: Added search/aggressive_cows.cpp with a binary-search-based solution and self-tests.

@aartigawade2586 aartigawade2586 changed the title Add aggressive cows solution feat: add aggressive cows algorithm Sep 27, 2026
@realstealthninja

Copy link
Copy Markdown
Collaborator

could you add some references as to where this problem originates from?

@realstealthninja realstealthninja added the question Further information is requested label Sep 29, 2026

This branch has not been deployed

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

Labels

question Further information is requested

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants