7 kyu
So Easy: Charge time calculation
468 of 1,061myjinxin2015
Description:
Task
To charge your mobile phone battery, do you know how much time it takes from 0% to 100%? It depends on your cell phone battery capacity and the power of the charger. A rough calculation method is:
0% --> 85% (fast charge)
(battery capacity(mAh) * 85%) / power of the charger(mA)
85% --> 95% (decreasing charge)
(battery capacity(mAh) * 10%) / (power of the charger(mA) * 50%)
95% --> 100% (trickle charge)
(battery capacity(mAh) * 5%) / (power of the charger(mA) * 20%)
For example: Your battery capacity is 1000 mAh and you use a charger 500 mA, to charge your mobile phone battery from 0% to 100% needs time:
0% --> 85% (fast charge) 1.7 (hour)
85% --> 95% (decreasing charge) 0.4 (hour)
95% --> 100% (trickle charge) 0.5 (hour)
total times = 1.7 + 0.4 + 0.5 = 2.6 (hour)
Complete function calculateTime
that accepts two arguments battery
and charger
, return how many hours can charge the battery from 0% to 100%. The result should be a number, round to 2 decimal places (In Haskell, no need to round it).
Puzzles
Similar Kata:
Stats:
Created | Sep 27, 2016 |
Published | Sep 27, 2016 |
Warriors Trained | 1700 |
Total Skips | 25 |
Total Code Submissions | 5497 |
Total Times Completed | 1061 |
JavaScript Completions | 503 |
Python Completions | 468 |
Ruby Completions | 99 |
Crystal Completions | 13 |
Haskell Completions | 39 |
Total Stars | 16 |
% of votes with a positive feedback rating | 82% of 235 |
Total "Very Satisfied" Votes | 169 |
Total "Somewhat Satisfied" Votes | 48 |
Total "Not Satisfied" Votes | 18 |
Total Rank Assessments | 8 |
Average Assessed Rank | 7 kyu |
Highest Assessed Rank | 7 kyu |
Lowest Assessed Rank | 8 kyu |