Skip to content

Instantly share code, notes, and snippets.

@tubbo tubbo/pert.rb
Last active Feb 13, 2017

Embed
What would you like to do?
PERT estimation calculator
#!/usr/bin/env ruby
#
# PERT Calculator v1.0.0
#
# To install, place this file in a directory that is in your $PATH. On
# my machine, I have ~/bin in my $PATH, so that's where `pert` lives.
#
# Example:
#
# $ pert 0.35 0.75 1
#
# optimistic: 0.35
# likely: 0.75
# pessimistic: 1.0
# + QA: 0.11 (15%)
# FINAL: 0.83
if ARGV.empty?
puts "Usage: pert OPTIMISTIC_HOURS LIKELY_HOURS PESSIMISTIC_HOURS"
exit 1
end
QA_TAX = 0.15
BOOST = 4
QUANTITY = 6
optimistic, likely, pessimistic = ARGV.map(&:to_f)
estimate = (optimistic + (BOOST * likely) + pessimistic) / QUANTITY
qa_time = estimate * QA_TAX
estimate += qa_time
[optimistic, likely, pessimistic, estimate, qa_time].map { |num| num.round(2) }
puts " optimistic: #{optimistic}"
puts " likely: #{likely}"
puts "pessimistic: #{pessimistic}"
puts " + QA: #{qa_time.round(2)} (#{(QA_TAX * 100).to_i}%)"
puts " FINAL: #{estimate.round(2)}"
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.