[Currency Exchange] Inconsistent change value type (`float`/`int`)
See original GitHub issueExchanged value is of type float
:
Remaining value is of type float
as well:
Value exchangeable in bills of a certain denomination is of type int
, but that is justifiable because denominations are integers:
However, non-exchangeable value is of type int
as well, which I believe is inconsistent:
Given the established structure, I see no reason why the non-exchangeable value should be integer. I mean, it clearly is not integer, but has to be rounded artificially to pass the tests.
Overall, I was surprised how convoluted this seemingly simple exercise was.
For one, there are few opportunities to reuse code in exchangeable_value
(task 5) and non_exchangeable_value
(task 6).
The essence of both of these functions is to calculate the exchangeable amount given the spread, which could’ve been implemented in exchange_money
(task 1).
Then exchangeable_value
could potentially reuse get_value_of_bills
(task 3), whereas non_exchangeable_value
could potentially reuse get_change
(task 2) – except for the fact that it expects an integer, therefore this issue.
As a side note, if we’re really looking to encourage the usage of the modulo operator %
, we could introduce a task to convert amounts using different denominations (and e.g. calculate the remainder that cannot be converted).
Happy to discuss & potentially submit a PR.
Issue Analytics
- State:
- Created a year ago
- Comments:7 (7 by maintainers)
Top GitHub Comments
Hello and thanks for your thoughtful (as always) response @BethanyG.
Since I’m still an infrequent visitor, not really comfortable to do a deep strategic dive. I will iterate the current exercise to hopefully make things more consistent and friendly to further changes.
PR incoming!
Sorry, I still intend to circle back to this @BethanyG. I opened this issue just before my vacation thinking I might have some spare time while traveling, but I was wrong 😃