Skip to content
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

Merge pull request #597 from iKostanOrg/master #598

Merged
merged 26 commits into from
Dec 30, 2024
Merged

Merge pull request #597 from iKostanOrg/master #598

merged 26 commits into from
Dec 30, 2024

Conversation

ikostan
Copy link
Member

@ikostan ikostan commented Dec 30, 2024

Merge from master

Summary by Sourcery

Implement a solution for the "Pointless Farmer" kata.

New Features:

  • Add the "Pointless Farmer" kata solution, which determines the buy/sell actions needed to launder a harvested fruit on the market and end up with the same fruit.

Tests:

  • Add unit tests for the "Pointless Farmer" kata solution.

Copy link
Contributor

sourcery-ai bot commented Dec 30, 2024

Reviewer's Guide by Sourcery

This pull request implements a solution to the "Pointless Farmer" kata and adds it to the project. The solution involves determining a sequence of 'buy' or 'sell' actions based on given fruit pairs and the initially harvested fruit, ensuring the final fruit matches the initial one. If no valid sequence exists, it returns 'ERROR'. The implementation includes a core function buy_or_sell that iterates through the fruit pairs, making decisions and updating the currently held fruit. A helper function make_deal determines the action for each pair. Tests are included to verify the solution's correctness.

Sequence diagram for Pointless Farmer trading process

sequenceDiagram
    participant F as Farmer
    participant M as Market
    Note over F: Has harvested fruit
    loop For each trading pair
        F->>M: Check trading pair
        alt Can trade current fruit
            F->>M: Execute 'buy' or 'sell'
            M-->>F: Receive new fruit
        else Cannot trade
            M-->>F: Return ERROR
        end
    end
    Note over F: Verify final fruit matches initial
Loading

Class diagram for Pointless Farmer solution

classDiagram
    class Solution {
        +buy_or_sell(pairs: list, harvested_fruit: str) list|str
        +make_deal(results: list, pair: tuple, currently_holding: str) str
    }
    note for Solution "Main solution class for Pointless Farmer kata"

    class TradingPair {
        +fruit1: str
        +fruit2: str
    }

    Solution ..> TradingPair: uses
Loading

State diagram for fruit trading process

stateDiagram-v2
    [*] --> HarvestedFruit
    HarvestedFruit --> Trading: Start trading
    Trading --> Trading: Execute buy/sell
    Trading --> Success: Final fruit matches initial
    Trading --> Error: Cannot complete trades
    Success --> [*]
    Error --> [*]
Loading

File-Level Changes

Change Details Files
Implemented the solution for the Pointless Farmer kata and added corresponding tests.
  • Created the buy_or_sell function to determine the sequence of actions.
  • Implemented the make_deal helper function to handle individual fruit pair transactions.
  • Added comprehensive unit tests using the unittest and parameterized libraries.
  • Included a README file explaining the kata and the solution.
  • Updated project documentation to reflect the addition of the Pointless Farmer solution.
  • Added the solution files to the project structure.
  • Updated the main README file with information about the new kata and a link to its solution on GitHub.
kyu_7/pointless_farmer/solution.py
kyu_7/pointless_farmer/test_buy_or_sell.py
kyu_7/pointless_farmer/README.md
kyu_7/pointless_farmer/__init__.py
docs/kyu_7/kyu_7.pointless_farmer.module.rst
docs/kyu_7/kyu_7.pointless_farmer.readme.rst
docs/kyu_7/kyu_7.pointless_farmer.rst
kyu_7/README.md
docs/kyu_7/kyu_7.rst
Updated the formatting of the solution links in the README file.
  • Adjusted spacing and alignment of the solution links in the README file to improve readability.
  • Standardized the format of the links to maintain consistency across the project documentation.
kyu_7/README.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time. You can also use
    this command to specify where the summary should be inserted.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We have skipped reviewing this pull request. Here's why:

  • We don't review packaging changes - Let us know if you'd like us to change this.
  • All of the files are larger than we can process. We're working on it!

Copy link

codeclimate bot commented Dec 30, 2024

Code Climate has analyzed commit c25cc6c and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (50% is the threshold).

This pull request will bring the total coverage in the repository to 90.4% (0.0% change).

View more on Code Climate.

@ikostan
Copy link
Member Author

ikostan commented Dec 30, 2024

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @ikostan - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

kyu_7/pointless_farmer/solution.py Show resolved Hide resolved
kyu_7/README.md Show resolved Hide resolved
@ikostan ikostan merged commit 0c28bdb into master Dec 30, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant