Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'pp'
- # Storing all variables in a Hash so they can be printed in
- # a way that shows everything related to the calculation.
- x = {}
- x[:task_count] = 1_000
- x[:$task] = 0.01
- x[:task_redundancy] = 2 # How many different users must do task
- x[:rate_of_mediation] = 1.0 / 40
- x[:rate_failed_mediation] = 1.0 / 20
- # I use $'s in the Symbols to denote a cost value.
- x[:$minimum] = x[:$task] * x[:task_redundancy] # Minimum cost of a task
- x[:$base] = x[:$minimum] * x[:task_count]
- x[:mediations] = x[:task_count] * x[:rate_of_mediation]
- x[:$mediations] = x[:mediations] * x[:$task]
- x[:failed_medations] = x[:mediations] * x[:rate_failed_mediation]
- x[:$failed_medations] = (x[:failed_medations] * x[:$minimum]) + (x[:failed_medations] * x[:$task])
- x[:$$] = x[:$base] + x[:$mediations] + x[:$failed_medations]
- puts "TOTAL COST: $%.2f" % x[:$$]
- puts
- pp x
Add Comment
Please, Sign In to add comment