Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
irb
allocation = {
events: 3_131_647.7,
fanout: 1_234_271.5,
default: 17_179_872,
detonation: 705_552.8,
assets: 4_664_397
}

sum = allocation.values.reduce(&:+)

allocation.each do |k, v|
 puts "#{k}: #{((v/sum)*100).round(0)}"
end
=> {:events=>3131647.7, :fanout=>1234271.5, :default=>17179872, :detonation=>705552.8, :assets=>4664397}
=> 26915741.0
=> {:events=>3131647.7, :fanout=>1234271.5, :default=>17179872, :detonation=>705552.8, :assets=>4664397}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.