Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
projects:split-bill [2024/07/28 11:42] – created pfmprojects:split-bill [2024/07/28 20:56] (current) – add Itertools::permutations pfm
Line 1: Line 1:
 ====== Split-Bill ====== ====== Split-Bill ======
  
-This is a command-line expense-sharing utility written in [[rust-lang.org/|Rust]]. It takes ''NAME=AMOUNT'' pairs and produces a very simple output about how much each person should return or get back for the expenses to be settled.+This is a command-line expense-sharing utility written in [[rust-lang.org/|Rust]]. It takes ''NAME=AMOUNT'' pairs (or just ''NAME'' if a person had no expenses) and produces a very simple output about how much each person should return or get back for the expenses to be settled.
  
 Repository: [[https://git.sr.ht/~pfm/split-bill|split-bill]] Repository: [[https://git.sr.ht/~pfm/split-bill|split-bill]]
 +
 +===== Example =====
 +
 +<code>
 +$ ./target/debug/split-bill john=10 jane=15 luke margaret dude=5
 +Expenses:
 +- john: 10
 +- jane: 15
 +- luke: 0
 +- margaret: 0
 +- dude: 5
 +john Gets(4.0)
 +jane Gets(9.0)
 +luke Pays(6.0)
 +margaret Pays(6.0)
 +dude Pays(1.0)
 +</code>
  
 ===== Ideas ===== ===== Ideas =====
Line 10: Line 27:
   * Use a reasonable type to represent amounts --- ''f32'' will break calculations sooner or later.   * Use a reasonable type to represent amounts --- ''f32'' will break calculations sooner or later.
   * Extract expense calculation code to a Rust library and then use it in the CLI tool, to be able to then write other applications (GUI maybe?).   * Extract expense calculation code to a Rust library and then use it in the CLI tool, to be able to then write other applications (GUI maybe?).
 +  * Use [[https://docs.rs/itertools/latest/itertools/trait.Itertools.html#method.permutations|Itertools.permutations]] to generate a sequence of permutations of debts to try them until a  transaction plan is identified that ensures minimum number transactions.