1.2 KiB
Vote-rs
This is a simple Rust program that reads a file of voting records and counts the votes for each nominee.
goael
Implement a stv vote counting system in rust. Could be based on rules and information found here: https://www.opavote.com/methods/single-transferable-vote probably implement the scottish method https://www.legislation.gov.uk/ssi/2007/42/contents/made because it is simpler and seems to be ok middle ground between complexity and fairness.
Usage
To run the program, use the following command:
cargo run -- sample.csv --amount 3
Replace sample.csv with the path to your file of voting records. amount is the number of nominees to select from the records.
Functionality
The program reads the voting records from the specified file into a Vec. Each Record contains a Vec, where each Vote has a name and a value.
The get_unique_names function is used to get a Vec of the unique names in the records.
The count_votes function is used to count the votes for each name. It returns a Vec where each Vote has a name and a value that is the total of the votes for that name. The Vec is sorted in descending order by vote value.