stephancom/xkcd-287

View on GitHub
README.md

Summary

Maintainability
Test Coverage
# xkcd-287 [![Build Status](https://travis-ci.org/stephancom/xkcd-287.svg?branch=master)](https://travis-ci.org/stephancom/xkcd-287) [![Maintainability](https://api.codeclimate.com/v1/badges/df24c7191ee15f50aae4/maintainability)](https://codeclimate.com/github/stephancom/xkcd-287/maintainability) [![Test Coverage](https://api.codeclimate.com/v1/badges/df24c7191ee15f50aae4/test_coverage)](https://codeclimate.com/github/stephancom/xkcd-287/test_coverage)

in fulfillment of a code challenge

![General solutions get you a 50% tip.](https://imgs.xkcd.com/comics/np_complete.png)

* [xkcd 287](https://xkcd.com/287/)
* [explanation](https://www.explainxkcd.com/wiki/index.php/287:_NP-Complete)

# Spec

> With apologies to xkcd, please provide a solution to the following programming exercise:
 
> You will be given a data file (sample file is attached). The first line of the data file will have a target price. The following lines contain a menu of dishes.
 
> Write a program to read in the data file and find all combinations of dishes that add up exactly to the target price specified on the first line of the data file. If there is no solution, your program should specify that there is no combination of dishes that will be equal in cost to the target price. Keep in mind that each dish can be used more than one time!
 
> Your program will be tested on multiple data sets so please provide documentation on how to invoke your program with the correct data file. Please code your solution in Ruby.

## example dataset provided

|target total|$15.05|
|---|---:|
|mixed fruit|$2.15|
|french fries|$2.75|
|side salad|$3.35|
|hot wings|$3.55|
|mozzarella sticks|$4.20|
|sampler plate|$5.80|

## Usage

* install gem
* `exord menu.txt`

`exord -h` is available, and explains additional configurable options, such as a name for the menu, overriding the total, or selecting a method of finding orders.

the file `menu.txt` represents the given problem; additional menus may be found in `spec/fixtures`

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).