#!/usr/bin/pypy
# -*- coding: utf-8 -*-

import knapsack


def solve_it(input_data):
    k = knapsack.input_data_to_knapsack(input_data)
    # r = knapsack.solve_knapsack_dynamic(k)
    r = knapsack.solve_knapsack_depth_first_search(k)
    return knapsack.result_to_output_data(r)


if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        file_location = sys.argv[1].strip()
        with open(file_location, 'r') as input_data_file:
            input_data = input_data_file.read()
        print(solve_it(input_data))
    else:
        print("This test requires an input file.  "
              "Please select one from the data directory. "
              "(i.e. python solver.py ./data/ks_4_0)")
