Skip to content

Conversation

@AnshMNSoni
Copy link

@AnshMNSoni AnshMNSoni commented Jan 14, 2026

Description

Implements Grover's search algorithm for quantum computing.

Checklist

  • I have read the contributing guidelines
  • My code follows the style guidelines (passes ruff checks)
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Type of change

  • New feature (non-breaking change which adds functionality)

What is Grover's Algorithm?

Grover's algorithm is a quantum algorithm for searching an unsorted database
with N entries in O(√N) time, providing quadratic speedup over classical algorithms.

Implementation Details

  • Uses Qiskit for quantum circuit simulation
  • Implements oracle for 2-qubit search marking |11⟩ state
  • Includes diffusion operator (inversion about average)
  • Returns measurement counts from simulation

@algorithms-keeper algorithms-keeper bot added the tests are failing Do not merge until tests pass label Jan 14, 2026
@algorithms-keeper algorithms-keeper bot added the awaiting reviews This PR is ready to be reviewed label Jan 14, 2026
@AnshMNSoni AnshMNSoni requested a review from cclauss as a code owner January 14, 2026 16:48
@algorithms-keeper algorithms-keeper bot added the require type hints https://docs.python.org/3/library/typing.html label Jan 14, 2026
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

QISKIT_AVAILABLE = False


def grover_search(number_of_qubits: int = 2):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: grover_search. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute


def grover_search(number_of_qubits: int = 2):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: grover_search. If the function does not return a value, please provide the type hint as: def function() -> None:

Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

from qiskit import Aer, ClassicalRegister, QuantumCircuit, QuantumRegister, execute


def grover_search(number_of_qubits: int = 2):

Choose a reason for hiding this comment

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

Please provide return type hint for the function: grover_search. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot added the require tests Tests [doctest/unittest/pytest] are required label Jan 14, 2026
Copy link

@algorithms-keeper algorithms-keeper bot left a comment

Choose a reason for hiding this comment

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

Click here to look at the relevant links ⬇️

🔗 Relevant Links

Repository:

Python:

Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.

algorithms-keeper commands and options

algorithms-keeper actions can be triggered by commenting on this PR:

  • @algorithms-keeper review to trigger the checks for only added pull request files
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.

NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.

import math


def grover_search(number_of_qubits: int = 2):

Choose a reason for hiding this comment

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

As there is no test file in this pull request nor any test function or class in the file quantum/grover_search_algorithm.py, please provide doctest for the function grover_search

Please provide return type hint for the function: grover_search. If the function does not return a value, please provide the type hint as: def function() -> None:

@algorithms-keeper algorithms-keeper bot removed the tests are failing Do not merge until tests pass label Jan 14, 2026
@AnshMNSoni
Copy link
Author

Hi maintainers 👋
All checks are passing. Kindly review when convenient. Thank you!

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

Labels

awaiting reviews This PR is ready to be reviewed require tests Tests [doctest/unittest/pytest] are required require type hints https://docs.python.org/3/library/typing.html

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant