GithubHelp home page GithubHelp logo

awwalm / minsterlingcoins Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 56 KB

The minimum coin problem... with a slight twist. The solution is programmed in Python, and runs as a console application.

License: GNU General Public License v3.0

Python 100.00%
minimum-coins

minsterlingcoins's Introduction

Minimum Sterling Coins and Pennies Evaluator

The minimum coin problem (with a twist!)

A simple repo for a program such that given a number of pennies, will calculate the minimum number of Sterling coins equivalent to that amount.

__        __   _                            _        
\ \      / /__| | ___ ___  _ __ ___   ___  | |_ ___  
 \ \ /\ / / _ \ |/ __/ _ \| '_ ` _ \ / _ \ | __/ _ \ 
  \ V  V /  __/ | (_| (_) | | | | | |  __/ | || (_) |
   \_/\_/ \___|_|\___\___/|_| |_| |_|\___|  \__\___/ 
                                                     
 __  __ _       _                           
|  \/  (_)_ __ (_)_ __ ___  _   _ _ __ ___  
| |\/| | | '_ \| | '_ ` _ \| | | | '_ ` _ \ 
| |  | | | | | | | | | | | | |_| | | | | | |
|_|  |_|_|_| |_|_|_| |_| |_|\__,_|_| |_| |_|
                                            
 ____  _            _ _                ____      _       
/ ___|| |_ ___ _ __| (_)_ __   __ _   / ___|___ (_)_ __  
\___ \| __/ _ \ '__| | | '_ \ / _` | | |   / _ \| | '_ \ 
 ___) | ||  __/ |  | | | | | | (_| | | |__| (_) | | | | |
|____/ \__\___|_|  |_|_|_| |_|\__, |  \____\___/|_|_| |_|
                              |___/                      
 _____            _             _             _ 
| ____|_   ____ _| |_   _  __ _| |_ ___  _ __| |
|  _| \ \ / / _` | | | | |/ _` | __/ _ \| '__| |
| |___ \ V / (_| | | |_| | (_| | || (_) | |  |_|
|_____| \_/ \__,_|_|\__,_|\__,_|\__\___/|_|  (_)

How it works

This version of the minimum coin problem processes the following Sterling coins and Pennies:

£2 £1 50p 20p
10p 5p 2p 1p

The evaluation process begins with basic filtering to account for input validation. This is subsequently followed by a bit of dynamic programming where the input is parsed through a top-down divisional minimization, starting with the highest coin.

The result is returned in a string (iterated and concatenated from a dictionary counter) describing the minimum number of coins used, based on the given input.

How to Run

  • The program utilizes the following dependencies (all obtaininable via pip) for Terminal rich text design:

  • With the dependencies installed, from the Terminal directory, execute the main_routine.py file.

  • The program should display the following (after the intial welcome message ASCII banner) in a console/terminal:

    • ENTER PENNIES (e.g. £2, £1, 50p, 20p, 10p, 5p, 2p and 1p):
      
  • Given the following input (£14.83), the corresponding output is produced:

    •   ENTER PENNIES (e.g. £2, £1, 50p, 20p, 10p, 5p, 2p and 1p):
        £14.83  
        >>> £14.83 =  7 x £2, 1 x 50p, 1 x 20p, 1 x 10p, 1 x 2p, 1 x 1p
      
  • Subsequent tabluation within the console is also added to mimic the feel and look of a web app:

    • Date & Time Received Amount Received Coin(s) Processed
      Tue Nov 9 17:58:56 2021 £14.83 12
    • 7 £2 Coins 1 50p Coin 1 20p Coin 1 10p Coin 1 2p Coin 1 1p Coin

Test Data

In the first column is a string of user input, and in the second the desired integer expressed as pence.

Input Pence Description
6 6 Single digit
75 75 Double digit
167p 167 Pence symbol
4p 4 Pence symbol single digit
1.97 197 Pounds decimal
£1.33 133 Pound symbol decimal
£2 200 Single digit pound symbol
£20 2000 Double digit pound symbol
£1.97p 197 Pound & pence symbol
£1p Decimal 100 missing pence
£1.p 100 Missing pence, Decimal point present
001.61p 161 Buffered zeroes
6.235p 624 Rounding with pence symbol
£1.256532677p 126 Rounding with pound and pence symbols.

Likewise, the application should not accept the following inputs

Input Pence Description
0 Empty string
1x 0 Non-numeric, non-symbol character
£1x.0p 0 Non-numeric, non-symbol character along with valid symbols
£p 0 Missing digits

minsterlingcoins's People

Contributors

awwalm avatar

Watchers

 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.