Giter Club home page Giter Club logo

good-friends's Introduction

Good friends

You are going on a road trip with your friends. There are 4 of you in a rental car : Alice, Bob, Claire and David. You are touring Ireland mainly because you all like stout.

You don't really know how long you will stay there, nor the price of gas or affordable BnB availabilities... so you just can't draft a budget for this trip.

You decided with your friends that it would be easier if each one would pay some stuff everyday, then sort out who owes money to who once you are back home.

Features

Examples are given in pseudo-code.

Registering a payment

  • Alice paid an irish coffee for herself, Bob and Claire (but not David). The bill amount was 15 €.
payment_history.register_payment(15, 'Alice', ['Alice', 'Bob', 'Claire'])
  • David paid a pint of guinness for Alice and Claire (but not to himself and not to Bob). The bill amount was 8 €.
payment_history.register_payment(8, 'David', ['Alice', 'Claire'])
  • Bob paid lunch for everyone (pub's food is the best here). The bill amount was 32 €.
payment_history.register_payment(32, 'Bob', ['Alice', 'Bob', 'Claire', 'David'])

Balancing debts

Rather than a very detailed list of debts, the simplified balance is computed by the software and printed out.

>>> payment_history.balance_debts()
>>>
  Alice owes 2to Bob
  Bob has no debts.
  Claire owes 17to Bob
  David has no debts.

Design constraints

payment_history may be a module, class or namespace. register_payment and balance_debts are just examples of functions / methods you could use as an entry point for your software. You are free to stick to them or use different entry points.

References

This kata is a challenge brought by Abel André (https://twitter.com/_blndr).

good-friends's People

Contributors

jcraftsman avatar adi-bolb avatar

Watchers

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