Skip to content

Fixed Issue #1772: Added a math folder to the Algorithms_and_Data_Structures section. - #1786

Merged
UTSAVS26 merged 5 commits into
UTSAVS26:mainfrom
muskansngh07:Add-maths-folder
Sep 15, 2025
Merged

UTSAVS26 merged 5 commits into
UTSAVS26:mainfrom
muskansngh07:Add-maths-folder

Conversation

@muskansngh07

@muskansngh07 muskansngh07 commented Sep 5, 2025 •

Copy link
Copy Markdown
Contributor

Pull Request for PyVerse 💡

Requesting to submit a pull request to the PyVerse repository.


Issue Title

Please enter the title of the issue related to your pull request.
Add a Math folder to the 'Algorithms_and_Data_Structures' folder.

  • I have provided the issue title.

Info about the Related Issue

What's the goal of the project?
All things python.

  • I have described the aim of the project.

Name

Please mention your name.
Muskan Singh

  • I have provided my name.

GitHub ID

Please mention your GitHub ID.
muskansngh07

  • I have provided my GitHub ID.

Email ID

Please mention your email ID for further communication.
muskansngh15@gmail.com

  • I have provided my email ID.

Identify Yourself

Mention in which program you are contributing (e.g., WoB, GSSOC, SSOC, SWOC).
GSSoC

  • I have mentioned my participant role.

Closes

Enter the issue number that will be closed through this PR.
Closes: #1772

  • I have provided the issue number.

Describe the Add-ons or Changes You've Made

Give a clear description of what you have added or modified.
Added a Maths folder to the Algorithms_and_Data_Structures section of the repository, which includes the following codes:

  1. Reverse Integer without converting it to string- Leetcode 7
  2. Pow(x,n)- Leetcode 50
  3. Sqrt of a non-negative number without any built-in functions- Leetcode 69
  4. Count of matches in a tournament- Leetcode 1688
  5. k-beauty of a number- Leetcode 2269
  6. Fascinating Number- Leetcode 2729
  • I have described my changes.

Type of Change

Select the type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Describe how your changes have been tested.
Tested on VS Code.

  • I have described my testing process.

Checklist

Please confirm the following:

  • My code follows the guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly wherever it was hard to understand.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added things that prove my fix is effective or that my feature works.
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • New Features
    • Tournament match counter: input team count, get total matches to determine a winner.
    • Fascinating-number checker: validates 3‑digit inputs where n,2n,3n concatenate to digits 1–9 exactly once.
    • k‑beauty calculator: counts length‑k substrings that evenly divide the number.
    • Fast power calculator with negative‑exponent support.
    • 32‑bit integer reverser with overflow handling.
    • Integer square‑root (floor) calculator.
    • Each tool includes simple command‑line prompts and printed results.

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

👋 Thank you for opening this pull request! We're excited to review your contribution. Please give us a moment, and we'll get back to you shortly!

Feel free to join our community on Discord to discuss more!

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@coderabbitai

coderabbitai Bot commented Sep 5, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Adds six new Math modules under Algorithms_and_Data_Structures/Maths providing CLI input helpers and core functions for Reverse Integer, Pow(x,n), Integer sqrt (floor), Count of Matches, k-beauty, and Fascinating Number.

Changes

Cohort / File(s) Summary of Changes
Maths: New problem implementations
Algorithms_and_Data_Structures/Maths/count_of_matches.py, Algorithms_and_Data_Structures/Maths/fascinating.py, Algorithms_and_Data_Structures/Maths/k_beauty.py, Algorithms_and_Data_Structures/Maths/pow(x,n).py, Algorithms_and_Data_Structures/Maths/reverse_integer.py, Algorithms_and_Data_Structures/Maths/sqrt.py
Add six standalone modules. Each provides an input helper (input_value/input_values), a core function (tournament_matches, is_fascinating, k_beauty, pow_func, reverse_integer, sqrt_floor) implementing the algorithm, and a __main__ block that reads input, invokes the core function, and prints the result.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    actor User
    participant CLI as "Module CLI"
    participant Core as "Core Function"

    User->>CLI: Provide input via prompts
    CLI->>Core: Call core(input)
    alt valid computation
        Core-->>CLI: Return result
        CLI-->>User: Print formatted output
    else invalid input / edge
        Core-->>CLI: Return handled value or raise
        CLI-->>User: Print handled output / error
    end

    rect rgba(198,235,197,0.25)
    Note right of CLI: Applies to modules: `reverse_integer`, `pow(x,n)`, `sqrt`, `count_of_matches`, `k_beauty`, `fascinating`
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Create Math/Maths folder under Algorithms_and_Data_Structures and add requested modules (#1772) ✅
Add Reverse Integer, Pow(x,n), Sqrt implementations (LeetCode 7, 50, 69) (#1772) ✅
Add Count of Matches, k-Beauty, Fascinating Number implementations (LeetCode 1688, 2269, 2729) (#1772) ✅

Suggested labels

level1

Suggested reviewers

  • TheChaoticor
  • UTSAVS26

Poem

In tunnels of math I twitch my nose,
Six carrots of code in tidy rows.
Pow and sqrt, I nibble through,
Reverse a hop, find k-beauty too.
Fascinating matches — a happy hare's clue. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
github-actions Bot requested a review from UTSAVS26 September 5, 2025 17:09
@github-actions github-actions Bot added Contributor Denotes issues or PRs submitted by contributors to acknowledge their participation. gssoc25 level2 Status: Review Ongoing 🔄 PR is currently under review and awaiting feedback from reviewers. labels Sep 5, 2025
@muskansngh07 muskansngh07 changed the title Added maths folder Fixed Issue #1772: Added a math folder to the Algorithms_and_Data_Structures section. Sep 5, 2025
@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

1 similar comment
@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (7)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (1)

5-15: Use O(1) formula and validate input.

The iterative simulation is correct but unnecessary; total matches in a knockout is max(n-1, 0). Also guard against negative n.

-def tournament_matches(n):
-    total_matches = 0
-    while n > 1:
-        if n % 2 == 0:
-            matches = n // 2
-            n = matches
-        else:
-            matches = (n - 1) // 2
-            n = matches + 1
-        total_matches += matches
-    return total_matches
+def tournament_matches(n):
+    if n < 0:
+        raise ValueError("n must be non-negative")
+    return max(n - 1, 0)
Algorithms_and_Data_Structures/Maths/reverse_integer.py (2)

1-4: Remove unused parameter and simplify input helper.

n is unused; align with other modules’ input_value pattern.

-def input_array(arr, n):  # Not needed for single integer, but keeping format
-    num = int(input("Enter integer x: "))
-    arr.append(num)
+def input_value():
+    return int(input("Enter integer x: "))

23-29: Simplify CLI: no need for list scaffolding.

This also removes the ARG001 warning.

-if __name__ == "__main__":
-    nums = []
-    input_array(nums, 1)
-    display_array(nums)
-    x = nums[0]  # Extract integer from list
-    result = reverse_integer(x)  # Pass the integer, not the list
-    print(f"Reversed integer is: {result}")
+if __name__ == "__main__":
+    x = input_value()
+    print(f"Reversed integer is: {reverse_integer(x)}")
Algorithms_and_Data_Structures/Maths/sqrt.py (1)

5-20: Validate non-negative input and avoid duplicate multiplication.

Minor guard for x < 0 and micro-opt to store mid*mid.

 def sqrt_floor(x):
-    if x < 2:
+    if x < 0:
+        raise ValueError("x must be non-negative")
+    if x < 2:
         return x  # sqrt(0)=0, sqrt(1)=1
-
-    left, right = 1, x
+    left, right = 1, x
     ans = 1
     while left <= right:
-        mid = (left + right) // 2
-        if mid * mid == x:
+        mid = (left + right) // 2
+        sq = mid * mid
+        if sq == x:
             return mid
-        elif mid * mid < x:
+        elif sq < x:
             ans = mid
             left = mid + 1
         else:
             right = mid - 1
     return ans
Algorithms_and_Data_Structures/Maths/fascinating.py (3)

1-3: Harden interactive input and add typing

Current int(input(...)) will crash on non-integers; also add return type for clarity. Loop with a friendly reprompt keeps UX consistent with the 3‑digit constraint.

-def input_value():
-    n = int(input("Enter 3-digit integer n: "))
-    return n
+def input_value() -> int:
+    while True:
+        try:
+            n = int(input("Enter 3-digit integer n: "))
+        except ValueError:
+            print("Invalid input. Please enter a 3-digit integer.")
+            continue
+        if 100 <= n <= 999:
+            return n
+        print("Please enter a 3-digit integer between 100 and 999.")

8-8: Micro: use f-string for readability

Slightly cleaner and avoids multiple str(...) calls.

-    concat_str = str(n) + str(2*n) + str(3*n)
+    concat_str = f"{n}{2*n}{3*n}"

14-17: Drop redundant newline in print

print already appends a newline.

-    print(f"Is {n} fascinating? {result}\n")
+    print(f"Is {n} fascinating? {result}")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d569dd4 and 8f69ecc.

📒 Files selected for processing (6)
  • Algorithms_and_Data_Structures/Maths/count_of_matches.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/fascinating.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/k_beauty.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/pow(x,n).py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/reverse_integer.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/sqrt.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (5)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (2)
Algorithms_and_Data_Structures/Maths/fascinating.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/sqrt.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/sqrt.py (2)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/fascinating.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/k_beauty.py (1)
Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)
  • input_values (1-4)
Algorithms_and_Data_Structures/Maths/fascinating.py (2)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/sqrt.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)
Algorithms_and_Data_Structures/Maths/k_beauty.py (1)
  • input_values (1-4)
🪛 Ruff (0.12.2)
Algorithms_and_Data_Structures/Maths/reverse_integer.py

1-1: Unused function argument: n

(ARG001)

🔇 Additional comments (3)
Algorithms_and_Data_Structures/Maths/reverse_integer.py (1)

8-21: Core reverse logic looks good and handles 32-bit bounds.

Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)

1-1: Rename Algorithms_and_Data_Structures/Maths/pow(x,n).py → Algorithms_and_Data_Structures/Maths/pow_x_n.py

Parentheses break Python imports; repository search found no direct imports of pow(x,n).py — rename to pow_x_n.py and update any external/dynamic references (notebooks, scripts, CI, docs).

Algorithms_and_Data_Structures/Maths/fascinating.py (1)

5-12: LGTM: Correct fascinating-number logic

Validates 3-digit input, concatenates n, 2n, 3n, and checks uniqueness and length; the combination of len == 9 and set equality correctly enforces “each 1–9 exactly once.” Early '0' check is fine.

Comment thread Algorithms_and_Data_Structures/Maths/k_beauty.py Outdated
Comment on lines +6 to +18
def pow_func(x, n):
if n == 0:
return 1
if n < 0:
x = 1 / x
n = -n
result = 1
while n > 0:
if n % 2 == 1:
result *= x
x *= x
n //= 2
return result

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix division-by-zero for 0 base with negative exponent.

When x == 0 and n < 0, line 10 raises ZeroDivisionError. Handle explicitly and return 0 for x == 0, n > 0.

 def pow_func(x, n):
     if n == 0:
         return 1
+    if x == 0:
+        if n < 0:
+            raise ZeroDivisionError("0 cannot be raised to a negative power")
+        return 0
     if n < 0:
         x = 1 / x
         n = -n
     result = 1
     while n > 0:
         if n % 2 == 1:
             result *= x
         x *= x
         n //= 2
     return result
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def pow_func(x, n):
if n == 0:
return 1
if n < 0:
x = 1 / x
n = -n
result = 1
while n > 0:
if n % 2 == 1:
result *= x
x *= x
n //= 2
return result
def pow_func(x, n):
if n == 0:
return 1
if x == 0:
if n < 0:
raise ZeroDivisionError("0 cannot be raised to a negative power")
return 0
if n < 0:
x = 1 / x
n = -n
result = 1
while n > 0:
if n % 2 == 1:
result *= x
x *= x
n //= 2
return result
🤖 Prompt for AI Agents
In Algorithms_and_Data_Structures/Maths/pow(x,n).py around lines 6 to 18, the
code does x = 1 / x for n < 0 which raises ZeroDivisionError when x == 0; fix by
handling x == 0 before any inversion: if x == 0 and n > 0 return 0, and if x ==
0 and n <= 0 raise a clear ZeroDivisionError (or ValueError) indicating 0 cannot
be raised to a non-positive power; only after these checks perform the n < 0
inversion and proceed with the fast exponentiation loop.

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@muskansngh07

Copy link
Copy Markdown
Contributor Author

@UTSAVS26 I have resolved the issue.

@github-actions

github-actions Bot commented Sep 5, 2025

Copy link
Copy Markdown

✅ PR validation passed! Syncing labels and assignees from the linked issue...

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)

10-13: Use ZeroDivisionError for 0 to negative exponent (matches math semantics).

Aligns with prior feedback and user expectations.

-        if x == 0:
-            raise ValueError("0 cannot be raised to a negative exponent")
+        if x == 0:
+            raise ZeroDivisionError("0 cannot be raised to a negative exponent")
🧹 Nitpick comments (9)
Algorithms_and_Data_Structures/Maths/k_beauty.py (3)

1-4: Add return type annotation for input helper for consistency.

Other modules annotate these helpers; do the same here.

-def input_values():
+def input_values() -> tuple[int, int]:
     num = int(input("Enter integer num: "))
     k = int(input("Enter substring length k: "))
     return num, k

8-9: Minor: shorten error message (Ruff TRY003).

Tiny style nit; message is fine, but shorter is okay too.

-        raise ValueError("k must be a positive integer")
+        raise ValueError("k must be > 0")

20-23: Optional: make CLI friendlier on bad input.

Catching ValueError avoids a traceback for users.

 if __name__ == "__main__":
-    num, k = input_values()
-    result = k_beauty(num, k)
-    print(f"The k-beauty of {num} with k = {k} is: {result}\n")
+    try:
+        num, k = input_values()
+        result = k_beauty(num, k)
+        print(f"The k-beauty of {num} with k = {k} is: {result}\n")
+    except ValueError as e:
+        print(f"Error: {e}")
Algorithms_and_Data_Structures/Maths/sqrt.py (1)

15-19: Avoid recomputing mid*mid.

Small perf/readability win in the loop.

-        if mid * mid == x:
+        mid_sq = mid * mid
+        if mid_sq == x:
             return mid
-        elif mid * mid < x:
+        elif mid_sq < x:
             ans = mid
             left = mid + 1
Algorithms_and_Data_Structures/Maths/pow(x,n).py (3)

6-6: Annotate return type.

Function may return float for negative exponents.

-def pow_func(x: int, n: int):
+def pow_func(x: int, n: int) -> float:

22-25: Optional: handle exceptions in CLI.

Gracefully report invalid cases.

 if __name__ == "__main__":
-    x, n = input_values()
-    power = pow_func(x, n)
-    print(f"Result of pow({x},{n}): {power}\n")
+    try:
+        x, n = input_values()
+        power = pow_func(x, n)
+        print(f"Result of pow({x},{n}): {power}\n")
+    except Exception as e:
+        print(f"Error: {e}")

1-1: Consider renaming file to avoid parentheses in path.

pow_x_n.py is shell/import friendly.

Algorithms_and_Data_Structures/Maths/reverse_integer.py (2)

4-5: Print scalar instead of list for input echo.

Small UX tweak.

-def display_array(arr):
-    print(f"\nInput integer is: {arr}")
+def display_array(x: int):
+    print(f"\nInput integer is: {x}")

And update call site:

-    display_array([x])
+    display_array(x)

1-3: Add type hints and minor style nit.

Annotate reverse_integer and prefer while x: idiom.

-def input_value() -> int:
+def input_value() -> int:
     return int(input("Enter integer x: "))

-def reverse_integer(x):
+def reverse_integer(x: int) -> int:
@@
-    while x != 0:
+    while x:

Also applies to: 7-7, 13-13

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 8f69ecc and 81a7573.

📒 Files selected for processing (4)
  • Algorithms_and_Data_Structures/Maths/k_beauty.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/pow(x,n).py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/reverse_integer.py (1 hunks)
  • Algorithms_and_Data_Structures/Maths/sqrt.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
Algorithms_and_Data_Structures/Maths/k_beauty.py (1)
Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)
  • input_values (1-4)
Algorithms_and_Data_Structures/Maths/reverse_integer.py (3)
Algorithms_and_Data_Structures/Maths/sqrt.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/fascinating.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/pow(x,n).py (1)
Algorithms_and_Data_Structures/Maths/k_beauty.py (1)
  • input_values (1-4)
Algorithms_and_Data_Structures/Maths/sqrt.py (3)
Algorithms_and_Data_Structures/Maths/reverse_integer.py (1)
  • input_value (1-2)
Algorithms_and_Data_Structures/Maths/fascinating.py (1)
  • input_value (1-3)
Algorithms_and_Data_Structures/Maths/count_of_matches.py (1)
  • input_value (1-3)
🪛 Ruff (0.12.2)
Algorithms_and_Data_Structures/Maths/k_beauty.py

9-9: Avoid specifying long messages outside the exception class

(TRY003)

Algorithms_and_Data_Structures/Maths/pow(x,n).py

11-11: Avoid specifying long messages outside the exception class

(TRY003)

Algorithms_and_Data_Structures/Maths/sqrt.py

1-1: SyntaxError: Unexpected indentation


5-5: SyntaxError: Expected a statement

🔇 Additional comments (2)
Algorithms_and_Data_Structures/Maths/k_beauty.py (1)

6-18: Core logic looks correct and robust (handles negatives and k bounds).

Validates k, uses abs(num) for slices, skips zero divisors, and counts divisors correctly.

Algorithms_and_Data_Structures/Maths/reverse_integer.py (1)

7-20: Reverse logic with 32-bit overflow checks looks solid.

Handles sign, overflow, and returns 0 on overflow as expected.

@@ -0,0 +1,27 @@
def input_value() -> int:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix leading indentation causing SyntaxError.

Top-level def must not be indented.

- def input_value() -> int:
+def input_value() -> int:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
def input_value() -> int:
def input_value() -> int:
🧰 Tools
🪛 Ruff (0.12.2)

1-1: SyntaxError: Unexpected indentation

🤖 Prompt for AI Agents
In Algorithms_and_Data_Structures/Maths/sqrt.py around line 1, the top-level
function definition is incorrectly indented; remove the leading indentation so
"def input_value() -> int:" starts at column 0 (no preceding spaces or tabs).
Ensure subsequent function body lines are indented consistently (using 4 spaces)
relative to the def, and run a quick syntax check (python -m py_compile) to
confirm the SyntaxError is resolved.

@muskansngh07

Copy link
Copy Markdown
Contributor Author

@UTSAVS26 hi, if you could review this as the checks have successfully passed.

@UTSAVS26
UTSAVS26 merged commit 4591ebf into UTSAVS26:main Sep 15, 2025
4 checks passed
@UTSAVS26 UTSAVS26 added Status: Approved ✔️ PRs that have passed review and are approved for merging. and removed Status: Review Ongoing 🔄 PR is currently under review and awaiting feedback from reviewers. labels Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Contributor Denotes issues or PRs submitted by contributors to acknowledge their participation. gssoc25 level2 Status: Approved ✔️ PRs that have passed review and are approved for merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Addition Request]: Add a Math folder to the 'Algorithms_and_Data_Structures' folder.

2 participants