Skip to content

Commit

Permalink
Clarify bills in currency exchange exercise
Browse files Browse the repository at this point in the history
The exchange booth in this exercise only deals in
cash of specific increments. That is to say, you can
bring any combination of bills and coins to exchange,
but you get a collection of bills of a single denomination
in the target currency in return.

The explanation was quite clear on this, but the parameter names
and docstrings in the methods dealing with this part of the
task used the term 'budget', which could lead readers to
assume that the bills had to do with the original currency.

This reworks the methods related to bills to be more generic,
not referring to the exchange process at all, hopefully avoiding
this misinterpretation.

See forum thread here for details of the discussion leading to
this change:

https://forum.exercism.org/t/currency-exchange-exercise-suggested-naming-tweaks/7790
  • Loading branch information
LittleMangoSeed committed Oct 20, 2023
1 parent 95f25cf commit fc8dbdf
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions exercises/concept/currency-exchange/.docs/hints.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

## 4. Calculate number of bills

- You need to divide `budget` into `denomination`.
- You need to divide `amount` into `denomination`.
- You need to use type casting to _int_ to get the exact number of bills.
- To remove decimal places from a `float`, you can convert it to `int`.

**Note:** The `//` operator also does floor division. But, if the operand has `float`, the result is still `float`.

## 5. Calculate leftover after exchanging into bills

- You need to find the remainder of `budget` that does not equal a whole `denomination`.
- You need to find the remainder of `amount` that does not equal a whole `denomination`.
- The Modulo operator `%` can help find the remainder.

## 6. Calculate value after exchange
Expand Down
12 changes: 6 additions & 6 deletions exercises/concept/currency-exchange/.docs/instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This function should return the amount of money that *is left* from the budget.
Create the `get_value_of_bills()` function, taking 2 parameters:

1. `denomination` : The value of a single bill.
2. `number_of_bills` : Number of bills you received.
2. `number_of_bills` : The total number of bills.

This exchanging booth only deals in cash of certain increments.
The total you receive must be divisible by the value of one "bill" or unit, which can leave behind a fraction or remainder.
Expand All @@ -50,10 +50,10 @@ Unfortunately, the booth gets to keep the remainder/change as an added bonus.

## 4. Calculate number of bills

Create the `get_number_of_bills()` function, taking `budget` and `denomination`.
Create the `get_number_of_bills()` function, taking `amount` and `denomination`.

This function should return the _number of currency bills_ that you can receive within the given _budget_.
In other words: How many _whole bills_ of currency fit into the amount of currency you have in your budget?
This function should return the _number of currency bills_ that you can receive within the given _amount_.
In other words: How many _whole bills_ of currency fit into the starting amount?
Remember -- you can only receive _whole bills_, not fractions of bills, so remember to divide accordingly.
Effectively, you are rounding _down_ to the nearest whole bill/denomination.

Expand All @@ -64,9 +64,9 @@ Effectively, you are rounding _down_ to the nearest whole bill/denomination.

## 5. Calculate leftover after exchanging into bills

Create the `get_leftover_of_bills()` function, taking `budget` and `denomination`.
Create the `get_leftover_of_bills()` function, taking `amount` and `denomination`.

This function should return the _leftover amount_ that cannot be exchanged from your _budget_ given the denomination of bills.
This function should return the _leftover amount_ that cannot be returned from your starting _amount_ given the denomination of bills.
It is very important to know exactly how much the booth gets to keep.

```python
Expand Down
16 changes: 8 additions & 8 deletions exercises/concept/currency-exchange/.meta/exemplar.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ def get_value_of_bills(denomination, number_of_bills):
"""
:param denomination: int - the value of a bill.
:param number_of_bills: int - number of bills you received.
:return: int - total value of bills you now have.
:param number_of_bills: int - total number of bills.
:return: int - calculated value of the bills.
"""

return denomination * number_of_bills


def get_number_of_bills(budget, denomination):
def get_number_of_bills(amount, denomination):
"""
:param budget: float - the amount of money you are planning to exchange.
:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: int - number of bills after exchanging all your money.
:return: int - number of bills that can be obtained from the amount.
"""

return int(budget) // denomination


def get_leftover_of_bills(budget, denomination):
def get_leftover_of_bills(amount, denomination):
"""
:param budget: float - the amount of money you are planning to exchange.
:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: float - the leftover amount that cannot be exchanged given the current denomination.
:return: float - the amount that is "leftover", given the current denomination.
"""

return budget % denomination
Expand Down
16 changes: 8 additions & 8 deletions exercises/concept/currency-exchange/exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,30 +24,30 @@ def get_value_of_bills(denomination, number_of_bills):
"""
:param denomination: int - the value of a bill.
:param number_of_bills: int - number of bills you received.
:return: int - total value of bills you now have.
:param number_of_bills: int - total number of bills.
:return: int - calculated value of the bills.
"""

pass


def get_number_of_bills(budget, denomination):
def get_number_of_bills(amount, denomination):
"""
:param budget: float - the amount of money you are planning to exchange.
:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: int - number of bills after exchanging all your money.
:return: int - number of bills that can be obtained from the amount.
"""

pass


def get_leftover_of_bills(budget, denomination):
def get_leftover_of_bills(amount, denomination):
"""
:param budget: float - the amount of money you are planning to exchange.
:param amount: float - the total starting value.
:param denomination: int - the value of a single bill.
:return: float - the leftover amount that cannot be exchanged given the current denomination.
:return: float - the amount that is "leftover", given the current denomination.
"""

pass
Expand Down

0 comments on commit fc8dbdf

Please sign in to comment.