GithubHelp home page GithubHelp logo

zharphyn / min-calorie-knapsack-problem Goto Github PK

View Code? Open in Web Editor NEW

This project forked from codynault/min-calorie-knapsack-problem

0.0 1.0 0.0 136 KB

C++ implementation of minimum-calorie knapsack problem. (Dynamic programming algorithm demonstration)

Makefile 12.63% C++ 4.51% C 82.85%

min-calorie-knapsack-problem's Introduction

Minimum-Calorie Knapsack Problem

Author: Cody Nault

Date: 5/29/2015

This is a C++ implementation of a classic Knapsack problem with a restaurant twist. The goal here is to take in a list of food items, with their corresponding cost and calorie count, and find the minimum number of calories that we can but with exactly X amount of money. This program demonstrates both memoized and iterative dynamic programming techniques of finding a solution efficiently. It then displays a solution that will lead to the optimal result.

Installation

To Install the application simple run make from the current project directory. make compiles files to the bin directory

Running

To run simply call ./chipotle from the project directory. Graph data input files are supplied in the application using standard input.

Additional Notes

My code exists in 2 different files src/chipotle.C include/chipotle.h Both are required for successful compilation

Results

The following commands where run from the root directory and produced these results which match the expected output.

$ ./chipotle < bin/inSample2.txt Iterative: Not possible to spend exactly: 950

Memoized: Not possible to spend exactly: 950

$./chipotle < bin/inSample3.txt Iterative: Possible to spend exactly: 1000000 Minimum calories: 725166 B 2 C 3620 D 2

Memoized: Possible to spend exactly: 1000000 Minimum calories: 725166 B 2 C 3620 D 2

$./chipotle < bin/inSample4.txt Iterative: Possible to spend exactly: 1978624 Minimum calories: 1758977 C 1 D 1 H 1 K 4394

Memoized: Possible to spend exactly: 1978624 Minimum calories: 1758977 C 1 D 1 H 1 K 4394

min-calorie-knapsack-problem's People

Contributors

codynault avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.