Code Monkey home page Code Monkey logo

coin-problem's Introduction

Coin Problem

Copyright 2019-2022 Caleb Evans
Released under the MIT license

Inspiration

This project was inspired by a math problem posed to Parade magazine's Marilyn Vos Savant in November 2019:

In a contest, a friend guessed the exact number of coins in a jar: 1,692. She won all of the coins, which totaled $100.54. They consisted of pennies, nickels, dimes and quarters. How many coins of each kind were in the jar?

Source: https://parade.com/951440/marilynvossavant/can-you-solve-this-coin-riddle/

This project serves as a generalized solver program given any number of coins and any dollar amount.

Usage

Set up virtualenv

virtualenv --python=python3 .virtualenv
source .virtualenv/bin/activate
pip install -r requirements.txt

Run solver program

python -m coinproblem -c 1692 -a 100.54

Options

  • --total-coin-count / -c: The total number of coins (i.e. the coin count)
  • --total-coin-amount / -a: the total dollar value of all coins combined (i.e. the coin amount)

Run duel program

The referee program accepts a variable number of executables that will be pit against each other. The referee program must be run as a module via the python -m command.

Please refer to the Player Program Specification to learn how to write your own player programs.

python -m coinproblem.referee ./coinproblem/my-player.py

Options

  • --timeout / -t (default: 10): The number of seconds each player will run before timing out
  • --min-count / --min (default: 0): The minimum number of coins per coin type to be generated
  • --max-count/ --max (default: 100): The maximum number of coins per coin type to be generated

Run tests

nose2 --quiet

To add additional test cases, please append an array of [penny, nickel, dime, quarter] counts to the JSON array in test_cases.json.

coin-problem's People

Contributors

caleb531 avatar

Watchers

 avatar  avatar  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.