Giter Site home page Giter Site logo

ria.denominationroutine's Introduction

๐Ÿ’ถ Denomination Routine

This projetc is part of Ria Money Transfer Software Engineer assignment.

Problem

Write a program which will calculate for each payout the possible combinations which the ATM can pay out. For example, for 100 EUR the available payout denominations would be:

  • 10 x 10 EUR
  • 1 x 50 EUR + 5 x 10 EUR
  • 2 x 50 EUR
  • 1 x 100 EUR

Technologies used

  • C# as programming language

Solution

This is a coin change problem, that can be solved in various ways.

Several solutions use recursive functions, but they do not work well for getting all payout possibilities due to hight memory consumption. This solution was created from scracth by Arthur Soares, using an iterative approach.

Steps

Calculate the first possibility using the highest denominations available, and then apply a limit usage for each denomination until only the lowest denomination is available.

The limit is applied by decrementing the lowest denomination used more than 0 times in the previous step. The lowest denomination of all denominations is never decremented to avoid unnecessary processing. After applying the limit, all denominations with values below the changed one can be used infinite times.

If the payout value cannot be reached with the applied limits, the limits are decremented again.

The initial limit allows infinite use of any denomination.

Scenario:

  • Payout: 100
  • Denominations: 10, 50, 100
Step 1 Limits Step 1 Result Step 2 Limits Step 2 Results Step 3 Limits Step 3 Results Step 4 Limits Step 4 Result
100: โˆž 100: 1 100: 0 100: 0 100: 0 100: 0 100: 0 100: 0
50: โˆž 50: 0 50: โˆž 50: 2 50: 1 50: 1 50: 0 50: 0
10: โˆž 10: 0 10: โˆž 10: 0 10: โˆž 10: 5 10: โˆž 10: 10

ria.denominationroutine's People

Watchers

Arthur Soares 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.