Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Dec 25, 2025

Describe your change:

Flowers in full bloom on people's arrivals

  • 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 the "Number of Flowers in Full Bloom" problem with two implementations.
    • Added an alternative implementation for the Count Days interval problem.
  • Documentation

    • Added a README detailing the Full Bloom problem and solution approach.
  • Tests

    • Added comprehensive tests validating the new Full Bloom implementations.

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

@BrianLusina BrianLusina self-assigned this Dec 25, 2025
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Array Array data structure Binary Search Binary Search Algorithm Intervals labels Dec 25, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 25, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Adds a new "Full Bloom Flowers" problem module with two implementations and tests, and introduces an alternative merge-based count_days_2 implementation in the existing intervals/count_days module. Documentation and tests for the new module were also added.

Changes

Cohort / File(s) Summary
Directory index
DIRECTORY.md
Added sub-entry under Algorithms > Intervals for "Full Bloom Flowers" linking to its tests.
Count Days (alternative)
algorithms/intervals/count_days/__init__.py
Added count_days_2, a merge-based implementation that sorts meetings, merges overlaps to compute occupied days, and returns free days; implementation differs in control flow from existing count_days.
Full Bloom Flowers module
algorithms/intervals/full_bloom_flowers/...
algorithms/intervals/full_bloom_flowers/README.md, algorithms/intervals/full_bloom_flowers/__init__.py
New module and README; two implementations (full_bloom_flowers, full_bloom_flowers_2) count blooming flowers per arrival using sorted start/end lists and bisect-based binary searches.
Full Bloom Flowers tests
algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py
New parameterized test suite exercising both implementations across multiple cases and expected outputs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I hopped through ranges, sorted each start and end,
Counting blooms for every arriving friend.
Two ways to merge, two ways to seek,
Tests and docs to make the logic sleek. 🌸

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 describes the main change: adding a full bloom flowers algorithm to the intervals directory, making it specific and appropriate.
Description check ✅ Passed The description follows the template with detailed change description and properly completed checklist items, though one non-critical item about issue resolution is unchecked.

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1c52afb and fed8eaf.

📒 Files selected for processing (1)
  • algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py

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
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: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
algorithms/intervals/count_days/__init__.py (1)

73-88: Remove duplicate code.

Lines 73–78 duplicate the logic that begins at line 80, including redundant sorts and variable initializations. This leftover code should be removed.

🔎 Proposed fix
-    # Sort the meetings based on their start time to process them in order
-    meetings.sort()
-
-    # Initialize a variable with 0 to count the number of days when the employee has meetings scheduled
-    occupied = 0
-
     # Initialize two variables with the first meeting's start and end times
     # Sort the meetings based on their start time to process them in order
     meetings.sort()
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d2e851 and 1c52afb.

📒 Files selected for processing (5)
  • DIRECTORY.md
  • algorithms/intervals/count_days/__init__.py
  • algorithms/intervals/full_bloom_flowers/README.md
  • algorithms/intervals/full_bloom_flowers/__init__.py
  • algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py
🧰 Additional context used
🧬 Code graph analysis (1)
algorithms/intervals/full_bloom_flowers/test_full_bloom_flowers.py (1)
algorithms/intervals/full_bloom_flowers/__init__.py (2)
  • full_bloom_flowers (5-29)
  • full_bloom_flowers_2 (32-49)
🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

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

(MD007, ul-indent)


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

(MD007, ul-indent)

🔇 Additional comments (3)
algorithms/intervals/full_bloom_flowers/README.md (1)

1-62: Excellent documentation!

The README provides a clear problem description, well-explained solution approach with step-by-step breakdown, and accurate complexity analysis. This will help future developers understand the algorithm.

algorithms/intervals/full_bloom_flowers/__init__.py (2)

5-29: LGTM!

The implementation correctly uses bisect_right to count flowers that started at or before the arrival time and bisect_left to count flowers that ended strictly before arrival. The logic is sound and well-documented.


32-49: LGTM!

The alternative implementation using end + 1 adjustment is clever and correct. By shifting the end boundary, both binary searches can consistently use bisect_right. The result matches the first implementation's behavior.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@BrianLusina BrianLusina merged commit aa7a075 into main Dec 26, 2025
4 of 7 checks passed
@BrianLusina BrianLusina deleted the feat/algorithms-intervals-full-bloom-flowers branch December 26, 2025 06:05
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 Binary Search Binary Search Algorithm Datastructures Datastructures Documentation Documentation Updates enhancement Intervals

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants