Skip to content

Conversation

@BrianLusina
Copy link
Owner

@BrianLusina BrianLusina commented Jan 10, 2026

Describe your change:

Algorithm to return a list of all possible recipes from supplies

  • 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 recipe-resolution feature to determine all recipes that can be made from given supplies.
  • Documentation

    • New guide describing the recipe-finding approach, inputs, examples, edge cases, and complexity.
    • Directory updated with a "Recipes Supplies" entry and a link to the new guide.
  • Tests

    • Added a comprehensive parameterized test suite validating multiple supply/recipe scenarios.

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

@BrianLusina BrianLusina self-assigned this Jan 10, 2026
@BrianLusina BrianLusina added enhancement Algorithm Algorithm Problem Datastructures Datastructures Documentation Documentation Updates Graph Graph data structures and algorithms Array Array data structure Queue Topological Sort labels Jan 10, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 10, 2026

📝 Walkthrough

Walkthrough

Adds a new algorithm "Find All Possible Recipes from Given Supplies": documentation, a topological-sort-based implementation find_recipes(recipes, ingredients, supplies), and parameterized unit tests validating recipe discovery from initial supplies and recipe dependencies.

Changes

Cohort / File(s) Summary
Documentation
DIRECTORY.md, algorithms/graphs/recipes_supplies/README.md
Added directory entry and a README describing the problem, examples, graph construction, indegree-based/topological algorithm, handling cycles, and complexity (O(v+e)).
Implementation
algorithms/graphs/recipes_supplies/__init__.py
Added find_recipes(recipes: List[str], ingredients: List[List[str]], supplies: List[str]) -> List[str] which builds a dependency graph (ingredient -> recipes), tracks indegrees, and uses a queue/BFS-like topological traversal to return all makeable recipes.
Testing
algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py
Added parameterized unittest FindAllPossibleRecipesTestCase with multiple scenarios asserting correctness of find_recipes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through graphs with glee,
Mapping supplies to recipe,
Indegrees fall, the queue hums too,
Topo-bakes a tasty view,
Carrots, tests, and docs — voila! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(algorithms, graphs, topological-sort): possible recipes from supplies' clearly describes the main change—adding a topological-sort algorithm to find recipes from supplies, matching the changeset's content.
Description check ✅ Passed The pull request description largely follows the template with most checklist items completed, including algorithm addition, contribution guidelines acknowledgment, and type hints. However, the description has an issue: three checklist items are marked as completed when only one should be—the description mentions both 'Fix a bug or typo' and 'Documentation change' as checked, but these appear to be supporting changes rather than primary goals.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e5c7cca and 35442b6.

📒 Files selected for processing (1)
  • algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.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: 2

🤖 Fix all issues with AI agents
In @algorithms/graphs/recipes_supplies/__init__.py:
- Line 25: Rename the misspelled module-level variable possible_recipies to
possible_recipes and update every reference to it in this module (e.g., the
places that currently read possible_recipies on subsequent lines such as where
it's initialized and where it's referenced later). Ensure you update the
variable name consistently (assignment, reads, and any imports/exports within
the module) so there are no NameError or unresolved reference issues.

In @algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py:
- Around line 57-65: Rename the misspelled parameter `recipies` to `recipes` in
the test function `test_find_recipes` and likewise update the implementation
signature and all usages in the `find_recipes` function to use `recipes` (fix
the variable name where it's referenced in the function body and any
tests/fixtures that pass it); ensure spellings are consistent across the test
parameter, the call to `find_recipes(recipes, ingredients, supplies)`, and the
function definition for `find_recipes` so no references to `recipies` remain.
🧹 Nitpick comments (1)
DIRECTORY.md (1)

109-110: Optional: adjust indentation to match markdownlint conventions.

The indentation follows the existing pattern in this file, but markdownlint suggests using 2-space increments for nested list items. This is a minor style preference that could be adjusted for consistency with linting rules.

📝 Suggested indentation adjustment
-    * Recipes Supplies
-      * [Test Find All Possible Recipes](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py)
+  * Recipes Supplies
+    * [Test Find All Possible Recipes](https://github.com/BrianLusina/PythonSnips/blob/master/algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py)
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d960d9b and e5c7cca.

⛔ Files ignored due to path filters (12)
  • algorithms/graphs/recipes_supplies/images/examples/all_possible_recipes_from_supplies_example_1.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/examples/all_possible_recipes_from_supplies_example_2.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_1.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_10.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_2.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_3.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_4.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_5.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_6.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_7.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_8.png is excluded by !**/*.png
  • algorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_9.png is excluded by !**/*.png
📒 Files selected for processing (4)
  • DIRECTORY.md
  • algorithms/graphs/recipes_supplies/README.md
  • algorithms/graphs/recipes_supplies/__init__.py
  • algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py
🧰 Additional context used
🧬 Code graph analysis (1)
algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py (1)
algorithms/graphs/recipes_supplies/__init__.py (1)
  • find_recipes (5-40)
🪛 LanguageTool
algorithms/graphs/recipes_supplies/README.md

[style] ~3-~3: Try using a synonym here to strengthen your writing.
Context: ...le Recipes from Given Supplies You are given information about n different recipes. ...

(GIVE_PROVIDE)


[style] ~70-~70: Using many exclamation marks might seem excessive (in this case: 8 exclamation marks for a text that’s 4936 characters long)
Context: ...e_recipes_from_supplies_solution_1.png) Solution 2 Solution 3 Solution 4 Solution 5 Solution 6 Solution 7 Solution 8 ![Solution 9](./images/solutions/all_poss...

(EN_EXCESSIVE_EXCLAMATION)

🪛 markdownlint-cli2 (0.18.1)
DIRECTORY.md

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

(MD007, ul-indent)


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

(MD007, ul-indent)

🔇 Additional comments (3)
algorithms/graphs/recipes_supplies/README.md (1)

1-89: Excellent documentation!

The README provides comprehensive coverage of the problem statement, constraints, solution approach, and complexity analysis. The step-by-step algorithm walkthrough clearly explains how topological sort is applied to solve the recipe dependency problem.

algorithms/graphs/recipes_supplies/__init__.py (1)

5-40: Algorithm implementation is correct!

The topological sort approach properly handles all cases including circular dependencies. The graph construction and BFS traversal correctly identify which recipes can be made given the initial supplies.

algorithms/graphs/recipes_supplies/test_find_all_possible_recipes.py (1)

6-52: Comprehensive test coverage!

The test cases effectively validate the algorithm across various scenarios including simple cases, dependency chains, and circular dependencies. The parameterized approach keeps the tests clean and maintainable.

recipe_graph[ingredient].append(recipe)

# List to store the possible recipes that can be made
possible_recipies: List[str] = []
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix variable name typo.

The variable name possible_recipies contains a spelling error and should be possible_recipes (note: "recipes" not "recipies").

✏️ Proposed fix
-    possible_recipies: List[str] = []
+    possible_recipes: List[str] = []

Also update line 37:

-                possible_recipies.append(recipe)
+                possible_recipes.append(recipe)

And line 40:

-    return possible_recipies
+    return possible_recipes
🤖 Prompt for AI Agents
In @algorithms/graphs/recipes_supplies/__init__.py at line 25, Rename the
misspelled module-level variable possible_recipies to possible_recipes and
update every reference to it in this module (e.g., the places that currently
read possible_recipies on subsequent lines such as where it's initialized and
where it's referenced later). Ensure you update the variable name consistently
(assignment, reads, and any imports/exports within the module) so there are no
NameError or unresolved reference issues.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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 Graph Graph data structures and algorithms Queue Topological Sort

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants