Skip to content

Commit

Permalink
Added problem "6. Calculate unexchangeable value" (exercism#19)
Browse files Browse the repository at this point in the history
* Added new problem "Calculate unexchangeable value"

Added modular arithmetic problem Calculate unexchangeable value

* Added new problem "Calculate unexchangeable value" (example.py, exchange.py)

Modified example.py, exchange.py

* Modified Calculated unexchangeable value

Modified `unexchangeable_value()` function's expected return type to be `int`

* added new lines at the end of file

* applied prettier on instructions.md

Co-authored-by: Limm-jk <201602057@cs-cnu.org>
Co-authored-by: Junkyu Lim <57378834+Limm-jk@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 12, 2020
1 parent 784bc71 commit b5785d6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,23 @@ This function should return the maximum value you can get considering the `budge
>>> exchangeable_value(127.25, 1.20, 10, 5)
95
```

## 6. Calculate unexchangeable value

Create the `unexchangeable_value()` function, with parameter `budget`, `exchange_rate`, `spread`, & `denomination`.

1. `budget` : amount of your money you are planning to exchange.
2. `exchange_rate` : unit value of the foreign currency.
3. `spread` : percentage taken as exchange fee.
4. `denomination` : the value of a single bill.

This function should return the unexchangeable value considering the `budget`, `exchange_rate`, `spread`, & `denomination`.

**Note:** Returned value should be `int` type.

```python
>>> unexchangeable_value(127.25, 1.20, 10, 20)
16
>>> unexchangeable_value(127.25, 1.20, 10, 5)
1
```
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ def exchangeable_value(budget, exchange_rate, spread, denomination):
actual_rate = exchange_rate + exchange_fee
exchangeable_amount = int((budget / actual_rate) / denomination)
return exchangeable_amount * denomination


def unexchangeable_value(budget, exchange_rate, spread, denomination):
exchange_fee = (exchange_rate / 100) * spread
actual_rate = exchange_rate + exchange_fee
unexchangeable_amount = int((budget / actual_rate) % denomination)
return unexchangeable_amount

Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
def estimate_value(budget, exchange_rate):
pass


def get_change(budget, exchanging_value):
pass


def get_value(denomination_value, number_of_bills):
pass


def get_number_of_bills(budget, denomination):
pass


def exchangeable_value(budget, exchange_rate, spread, minimum_denomination):
pass


def unexchangeable_value(budget, exchange_rate, spread, denomination):
pass

0 comments on commit b5785d6

Please sign in to comment.