daily pastebin goal
5%
SHARE
TWEET

version 3

a guest May 16th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
Top