added .gitignore
This commit is contained in:
parent
62cd303298
commit
3828115395
2
.gitignore
vendored
2
.gitignore
vendored
@ -0,0 +1,2 @@
|
||||
tally/target/
|
||||
tally/Cargo.lock
|
@ -1,15 +1,18 @@
|
||||
// https://www.reddit.com/r/dailyprogrammer/comments/8jcffg/20180514_challenge_361_easy_tally_program/
|
||||
// this is pretty much my first rust program
|
||||
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let input = "EbAAdbBEaBaaBBdAccbeebaec";
|
||||
println!("Tallying {}", input);
|
||||
let player_list = String::from(init_player_list(input.to_string()));
|
||||
println!("{}", player_list);
|
||||
println!("These people are playing: {}", player_list);
|
||||
|
||||
let tally = tally(player_list, input.to_string());
|
||||
print!("{:?}", tally);
|
||||
println!("These are their scores:");
|
||||
println!("{:?}", tally);
|
||||
}
|
||||
|
||||
// get all distinct characters
|
||||
fn init_player_list(input: String) -> String{
|
||||
let mut result = String::new();
|
||||
let ch = input.chars();
|
||||
@ -23,6 +26,9 @@ fn init_player_list(input: String) -> String{
|
||||
return result
|
||||
}
|
||||
|
||||
// tally each players scores
|
||||
// lowercase => +1 point
|
||||
// uppercase => -1 point
|
||||
fn tally(player_list: String, tally: String) -> Vec<(char, i32)>{
|
||||
let mut v: Vec<(char, i32)> = Vec::new();
|
||||
for (_i, player) in player_list.chars().enumerate() {
|
||||
|
Loading…
Reference in New Issue
Block a user