My knowledge of statistics is a bit rusty (yet I didn't use rust for this challenge), but I think that an increase from 0 to anything is basically an infinite rate and a decrease from anything to 0 is a negative 100% rate, so I disagree with the examples 3 and 4 and have written my solution accordingly.
Haskell, of course
get_rate::Double->Double->Stringget_ratebeforeafter|before==after="No evolution."|before==0="Infinite evolution."|evolution<0="A negative evolution of "++(show'.abs)evolution++"%."|otherwise="A positive evolution of "++show'evolution++"%."whereevolution=(after-before)*100/beforeshow'=show.round-- show_abs = show' . abs -- Hmm, maybe not the best name ever, let's leave it out.
Output
get_rate11.2945.79-- "A positive evolution of 306%."get_rate95.1266.84-- "A negative evolution of 30%."get_rate027.35-- "Infinite evolution."get_rate41.260-- "A negative evolution of 100%."get_rate1.261.26-- "No evolution."
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My knowledge of statistics is a bit rusty (yet I didn't use rust for this challenge), but I think that an increase from 0 to anything is basically an infinite rate and a decrease from anything to 0 is a negative 100% rate, so I disagree with the examples 3 and 4 and have written my solution accordingly.
Haskell, of course
Output