Advertisement
Guest User

version 3

a guest
May 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.42 KB | None | 0 0
  1. def percent(bundled, not_bundled)
  2.   #  convert input to floats
  3.   bundled     = bundled.to_f
  4.   not_bundled = not_bundled.to_f
  5.   # verbose math
  6.   bundled_not_bundled_sum = bundled + not_bundled
  7.   # debugging
  8.   puts bundled_not_bundled_sum
  9.   # actual math
  10.   percent_not_bundled = not_bundled / bundled_not_bundled_sum
  11.   # limit to 2 points then get whole percent
  12.   puts (percent_not_bundled.round(2) * 100).to_i
  13. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement