Skip to content

Splitwise-Python is a compact Python utility for fairly splitting group expenses and calculating the minimal set of settlement transactions required so that everyone is even. Input: List of (name, paid amount) for each person. Output: Minimal settlement transactions (who pays whom and how much).

Notifications You must be signed in to change notification settings

twopranav/Splitwise-Expense-Sharing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

SplitWise: Group Expense Splitter

This is a backend implementation of a group expense splitting application, written in Python 3. It utilizes object-oriented programming (OOP) principles to efficiently manage and settle debts among a group of people. The program calculates individual balances and provides the simplest way to settle all debts with the minimum number of transactions.

✨ Features

  • OOP Design: The system is built with a Person class to represent each member and a Splitwise class to handle the core logic of expense calculation and settlement.
  • Minimal Transactions: It uses a greedy algorithm to minimize the number of payments required to settle all debts. This ensures an efficient and straightforward settlement process.
  • Clear Output: The program outputs a clear list of who needs to pay whom and how much, simplifying the process of settling up.
  • Robust Calculations: Handles floating-point numbers and rounds balances to two decimal places, ensuring accurate financial calculations.

🚀 How to Run

  1. Clone the repository:
    git clone [your-repo-url]
  2. Navigate to the project directory:
    cd splitwise
  3. Run the Python script:
    python splitwise.py

▶️ How to Use

To use the program, you need to provide a list of payments, where each item is a tuple containing a person's name and the amount they paid.

Example:

payments = [
    ("Alice", 100),
    ("Bob", 50),
    ("Charlie", 70),
    ("David", 20)
]

splitter = Splitwise(payments)
settlements = splitter.settle()
for s in settlements:
    print(s)

The output will be a list of payments to settle all debts. For the above example, a possible output would be:

David pays Alice: ₹20.00
Charlie pays Bob: ₹10.00

(Note: The exact output depends on the settlement algorithm's path but will always result in a full settlement.)

👨‍💻 Author

  • Pranav - B.E. in Computer Science with Business Systems student.

About

Splitwise-Python is a compact Python utility for fairly splitting group expenses and calculating the minimal set of settlement transactions required so that everyone is even. Input: List of (name, paid amount) for each person. Output: Minimal settlement transactions (who pays whom and how much).

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages