-
Notifications
You must be signed in to change notification settings - Fork 2
feat(algorithms, graphs, topological-sort): possible recipes from supplies #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughAdds a new algorithm "Find All Possible Recipes from Given Supplies": documentation, a topological-sort-based implementation Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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. Comment |
There was a problem hiding this 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
⛔ Files ignored due to path filters (12)
algorithms/graphs/recipes_supplies/images/examples/all_possible_recipes_from_supplies_example_1.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/examples/all_possible_recipes_from_supplies_example_2.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_1.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_10.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_2.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_3.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_4.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_5.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_6.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_7.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_8.pngis excluded by!**/*.pngalgorithms/graphs/recipes_supplies/images/solutions/all_possible_recipes_from_supplies_solution_9.pngis excluded by!**/*.png
📒 Files selected for processing (4)
DIRECTORY.mdalgorithms/graphs/recipes_supplies/README.mdalgorithms/graphs/recipes_supplies/__init__.pyalgorithms/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)

🪛 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] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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>
Describe your change:
Algorithm to return a list of all possible recipes from supplies
Checklist:
Fixes: #{$ISSUE_NO}.Summary by CodeRabbit
New Features
Documentation
Tests
✏️ Tip: You can customize this high-level summary in your review settings.