Ruby CLI for knapsack problem
gem install thor
git clone <URL>
cd knap
thor knap load <FILE_NAME>
options:
-v
|| --verbose
(default: false)
--combinations
(default: false)
--counts
(default: false)
--to_s
(default: true)
thor knap test
options:
-v
|| --verbose
(default: false)
thor knap help
Includes CLI for generating test menus
cd spec
thor menu_gen
||thor menu_gen help
All test files are saved in spec/test_menus
In knapsack.rb:
k = Knapsack.new('path/to/file.txt')
k.combinations # returns all combinations of items whose prices add up to target price
k.counts # returns array of hashes with items as keys and count as values
puts k # string representation