daily pastebin goal
35%
SHARE
TWEET

version 3

a guest May 16th, 2018 88 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top