Go to file
Zykino cea137fd0a fix pig latin with empty string 2018-11-26 22:12:26 +01:00
src fix pig latin with empty string 2018-11-26 22:12:26 +01:00
.gitignore Initial commit with my view on how to answer the exercices 2018-11-24 21:12:16 +01:00
Cargo.lock Initial commit with my view on how to answer the exercices 2018-11-24 21:12:16 +01:00
Cargo.toml Initial commit with my view on how to answer the exercices 2018-11-24 21:12:16 +01:00
README.md Initial commit with my view on how to answer the exercices 2018-11-24 21:12:16 +01:00

README.md

My take Rust second edition chapter 8 exercices

Given a list of integers, use a vector and return the mean (the average value), median (when sorted, the value in the middle position), and mode (the value that occurs most often; a hash map will be helpful here) of the list.

Convert strings to pig latin. The first consonant of each word is moved to the end of the word and “ay” is added, so “first” becomes “irst-fay.” Words that start with a vowel have “hay” added to the end instead (“apple” becomes “apple-hay”). Keep in mind the details about UTF-8 encoding!

Using a hash map and vectors, create a text interface to allow a user to add employee names to a department in a company. For example, “Add Sally to Engineering” or “Add Amir to Sales.” Then let the user retrieve a list of all people in a department or all people in the company by department, sorted alphabetically.

Any feedback to make it more idiomatic Rust and/or have better API is welcome.
I sometimes use the showroom functions to keep all the code (lib + tests) in the same file.