Skip to content

feat(arrays, puzzles, matrix): lucky number in a matrix#115

Merged
BrianLusina merged 3 commits intomainfrom
feat/arrays-lucky-number
Dec 3, 2025
Merged

feat(arrays, puzzles, matrix): lucky number in a matrix#115
BrianLusina merged 3 commits intomainfrom
feat/arrays-lucky-number

Conversation

@BrianLusina
Copy link
Copy Markdown
Owner

@BrianLusina BrianLusina commented Dec 3, 2025

Describe your change:

Finds the lucky number in a matrix where a lucky number is a number that is the minimum in its row, but the maximum in its column

  • 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}.

Summary by CodeRabbit

  • New Features

    • Added a new array puzzle: "Lucky Numbers In A Matrix" with two solution variants.
  • Documentation

    • Added a comprehensive README for the puzzle: description, constraints, visual examples, algorithm steps, and complexity analysis.
  • Tests

    • Added thorough unit tests covering multiple scenarios and edge cases for both solution variants.

✏️ Tip: You can customize this high-level summary in your review settings.

@BrianLusina BrianLusina self-assigned this Dec 3, 2025
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Greedy Greedy Algorithm Array Array data structure labels Dec 3, 2025
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a new "Lucky Numbers in a Matrix" puzzle: documentation, two implementations (lucky_numbers, lucky_numbers_simulation), and parameterized unit tests; also registers the puzzle in DIRECTORY.md.

Changes

Cohort / File(s) Summary
Directory Index
DIRECTORY.md
Inserts a new entry linking the "Lucky Numbers In A Matrix" puzzle and its test.
Documentation
puzzles/arrays/lucky_numbers_in_a_matrix/README.md
Adds full README: problem statement, constraints, examples, greedy approach explanation, stepwise algorithm, and complexity analysis.
Implementation
puzzles/arrays/lucky_numbers_in_a_matrix/__init__.py
Adds lucky_numbers(matrix: List[List[int]]) -> List[int] and lucky_numbers_simulation(matrix: List[List[int]]) -> List[int] with type hints, docstrings, and complexity notes.
Tests
puzzles/arrays/lucky_numbers_in_a_matrix/test_lucky_numbers_in_a_matrix.py
New parameterized test module validating both functions across multiple matrices and edge cases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Verify correctness of both implementations (the single-result greedy variant vs. the simulation collection).
  • Check handling of edge cases: empty matrix, single-row/column, rectangular shapes, and no-lucky-number cases.
  • Review tests for sufficient coverage and accurate expected results.
  • Confirm README examples match implementation behavior.

Possibly related PRs

Poem

🐇 I hopped through rows and columns with delight,
Seeking minima that spark a max's light,
A greedy nibble, a careful little plot,
I found the lucky numbers—tucked in a spot! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding a lucky number algorithm for matrices, which aligns with the changeset.
Description check ✅ Passed The PR description follows the template structure with a clear problem description and all checklist items addressed, indicating comprehensive compliance with contribution guidelines.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1e71628 and 03e8a32.

⛔ Files ignored due to path filters (1)
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_proof_of_contradiction.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • puzzles/arrays/lucky_numbers_in_a_matrix/README.md (1 hunks)
  • puzzles/arrays/lucky_numbers_in_a_matrix/__init__.py (1 hunks)
  • puzzles/arrays/lucky_numbers_in_a_matrix/test_lucky_numbers_in_a_matrix.py (1 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

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 (2)
DIRECTORY.md (1)

487-488: Lucky Numbers entry looks correct; markdownlint indent warning is likely stylistic

The new directory entries and test link follow the existing patterns for puzzles/arrays and point to the expected path. The markdownlint MD007 warning about indentation (2 vs 4 spaces) conflicts with the indentation already used by neighboring items in this section, so it’s more of a style/configuration concern than a content issue. If your pipeline enforces MD007 strictly, you may want to either tweak this list’s indentation globally or relax that rule for this file, rather than changing just these two lines.

puzzles/arrays/lucky_numbers_in_a_matrix/test_lucky_numbers_in_a_matrix.py (1)

1-40: Solid parameterized coverage of the lucky_numbers behavior

The tests exercise the core cases well: multiple 3×3 and 4×4 matrices with and without lucky numbers, plus the 1×1 edge case, all matching the definition used in the implementation. Using parameterized.expand keeps the suite compact and readable. If you want to push coverage slightly further, you could add an explicitly non-square rectangular case (e.g., 2×3) to demonstrate that the logic doesn’t rely on squareness, but that’s optional given the current constraints.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6da8745 and 1e71628.

⛔ Files ignored due to path filters (19)
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/examples/lucky_numbers_in_a_matrix_example_1.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/examples/lucky_numbers_in_a_matrix_example_2.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/examples/lucky_numbers_in_a_matrix_example_3.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_1.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_10.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_11.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_12.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_13.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_14.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_15.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_16.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_2.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_3.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_4.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_5.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_6.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_7.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_8.png is excluded by !**/*.png
  • puzzles/arrays/lucky_numbers_in_a_matrix/images/solutions/lucky_numbers_in_a_matrix_solution_9.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • DIRECTORY.md (1 hunks)
  • puzzles/arrays/lucky_numbers_in_a_matrix/README.md (1 hunks)
  • puzzles/arrays/lucky_numbers_in_a_matrix/__init__.py (1 hunks)
  • puzzles/arrays/lucky_numbers_in_a_matrix/test_lucky_numbers_in_a_matrix.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
puzzles/arrays/lucky_numbers_in_a_matrix/test_lucky_numbers_in_a_matrix.py (1)
puzzles/arrays/lucky_numbers_in_a_matrix/__init__.py (1)
  • lucky_numbers (4-54)
🪛 LanguageTool
puzzles/arrays/lucky_numbers_in_a_matrix/README.md

[grammar] ~56-~56: Ensure spelling is correct
Context: ...est_min or c_smallest_max. Otherwise if now matching value is found, we return an e...

(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)


[style] ~81-~81: Using many exclamation marks might seem excessive (in this case: 15 exclamation marks for a text that’s 5161 characters long)
Context: ...cky_numbers_in_a_matrix_solution_1.png) Solution 2 Solution 3 Solution 4 Solution 5 Solution 6 Solution 7 Solution 8 Solution 9 Solution 10 Solution 11 Solution 12 Solution 13 Solution 14 ![Solution 15](./images/solutions/lucky_n...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

487-487: Unordered list indentation
Expected: 2; Actual: 4

(MD007, ul-indent)


488-488: Unordered list indentation
Expected: 4; Actual: 6

(MD007, ul-indent)

puzzles/arrays/lucky_numbers_in_a_matrix/README.md

39-39: Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)


45-45: Multiple spaces after blockquote symbol

(MD027, no-multiple-space-blockquote)

@BrianLusina BrianLusina merged commit 56e8dff into main Dec 3, 2025
4 of 7 checks passed
@BrianLusina BrianLusina deleted the feat/arrays-lucky-number branch December 3, 2025 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Algorithm Algorithm Problem Array Array data structure Datastructures Datastructures Documentation Documentation Updates enhancement Greedy Greedy Algorithm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant