cub-sdt-104-2024 / tasks

This repository hosts a task tracker for all projects.
1 stars 0 forks source link

Settle the debts #8

Open dbarashev-jetbrains opened 1 week ago

dbarashev-jetbrains commented 1 week ago

Suppose we have a list of DebtSummary objects from issue #7. The event participants may use this information to pay the sum they owe to their friends. However, it is often possible to simplify the graph of debts. For instance, if paul owes 30 USD to john, and 10 USD to jose, and john owes 20 USD to jose, it is possible to settle down it so that paul returns 10 USD to john and 30 to jose.

The task is:

  1. Design an algorithm to settle the debts.
  2. Write a function settleDebts(debts: list[DebtSummary]): list[DebtSummary] that simplifies the debt graph.

Please write unit tests, make sure that they are passing (it is also a good idea to see them failing at least once), create a pull request with the changes, assign @dbarashev-jetbrains as a reviewer and wait until the end of the code review.

dbarashev-jetbrains commented 1 week ago

@whylot @DanLyss this is the third task for the first phase of the project.