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

Stats:

CreatedSep 27, 2016
PublishedSep 27, 2016
Warriors Trained1700
Total Skips25
Total Code Submissions5497
Total Times Completed1061
JavaScript Completions503
Python Completions468
Ruby Completions99
Crystal Completions13
Haskell Completions39
Total Stars16
% of votes with a positive feedback rating82% of 235
Total "Very Satisfied" Votes169
Total "Somewhat Satisfied" Votes48
Total "Not Satisfied" Votes18
Total Rank Assessments8
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • myjinxin2015 Avatar
  • jhoffner Avatar
  • GiacomoSorbi Avatar
  • gabbek Avatar
  • Voile Avatar
  • user9644768 Avatar
  • cliffstamp Avatar
  • solitude Avatar
  • Just4FunCoder Avatar
  • saudiGuy Avatar
Ad