Created
August 10, 2016 03:01
-
-
Save idlehands/860a785d8b6fde7b0e0bb9dd2f3d0422 to your computer and use it in GitHub Desktop.
Ruby starter file for for Algorithm Toolbox on Coursera
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# by Jeffrey Matthias | |
def get_optimal_value(capacity, weights, values) | |
value = 0.0 | |
# your code here | |
value | |
end | |
if __FILE__ == $0 | |
number_of_items, capacity = gets.split().map(&:to_i) | |
values = [] | |
weights = [] | |
number_of_items.times do | |
value, weight = gets.split().map(&:to_i) | |
values << value | |
weights << weight | |
end | |
answer = get_optimal_value(capacity, weights, values) | |
puts "#{'%.4f' % answer}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment