cub-sdt-104-2024 / tasks

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

Encoding and decoding an expense item to/from string #3

Open dbarashev-jetbrains opened 1 month ago

dbarashev-jetbrains commented 1 month ago

Suppose that we have a subset of the event participants who split an expense. To store this record persistently we want to be able to encode the participant ids, the expense amount and information on who paid the expense in a string, like this:

<EXPENSE_NUMBER>:<EXPENSE_AMOUNT>:<EXPENSE_CURRENCY>:<PARTICIPANT_LIST>

where is a comma-delimited list of participant usernames, and the paying participant is the first one in this list. An example of such record, that says that participants john,paul,mick are going to split the expense of 25USD, paid by john:

1:25:USD:john,paul,mick

Your task is to design a simple data structure ExpenseItem, built from tuples, lists and atomic types for storing this information and to write two functions:

encodeExpense(expense: ExpenseItem) -> str
decodeExpense(str) -> ExpenseItem

Please don't forget to write unit tests for these functions.

dbarashev-jetbrains commented 1 week ago

Hey @DanLyss the pull request is supposed to pass a code review:

A task is considered as completed if a pull request with the working task code and passing unit tests is submitted before the submission deadline, and the code review ends with "LGTM" (approval) from one of the teachers.

I will do the review post-factum, however, the next time please assign me as a reviewer before you merge the pull request,.

dbarashev-jetbrains commented 1 week ago

@DanLyss Also please don't close the issue because it is shared between the projects.