7 kyu
Loose Change!
779 of 1,771Caders
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Haskell translation
I'm sorry but I have no idea what this CHANGE "dictionary" is???? Can someone please explain what it is?? I don't think there was any mention of it in the directions either... But it seems like a lot of the solutions used it... Please enlighten me!!
from the description on the details page:
Yea... I need to learn how to read directions better FML... Thanks for the reply though !!
Nice one.
However, it misses a sample test where the answer is xx.00.
(in JavaScript & Python)
PHP translation kumited 🙂
This comment has been hidden.
I wouldn't have expected that from you, rowcased... ;o
Not an issue, the approach is just wrong. (Sounds like you didn't even investigate the reasons, while it'ss pretty obvious as soon as you search for some info.... :p )
edit: I hope you're not asking for specific tests to discriminate that? (because it's not reasonnable: based on floating point errors)
I've maybe only posted one issue previously, and I hesitated in this case. I did find the floating point imprecision; where it was happening in my code and how the variable assignments failed to catch it. My reasoning for the issue? A wrong piece of code SHALL NOT PASS! anyway, thanks
True, but that's only a theoretical statement. ;) For instance, when it comes to forbid wrong approaches with floating point errors involved, desgining edge cases requires to think about any kind of approaches warriors could imagine. Pretty impossible. The only "reasonnable" (well... :/ ) way would be to increase the number of random tests, I guess.
This comment has been hidden.
sure, that will work for your specific way of doing the computations. But as soon as another user changes a bit the order of the computations or the way they are done, that's not that test that you'll need to filter out his solution ;) (that's exactly what happened before with the original python solution, which was pretty counterintuivite and generated random fails just like yours (well, more often, because the formula was way further of the classic way to tackle the problem)).
The problem could have been avoided if the dictionary included integers instead of floats, for example.
This comment has been hidden.
You forgot to mention those issues are for Python. AFAIK Javascript version is ok.
You'r right. Problem exist in Python version. Sorry for not mention this.
issue confirmed
corrected
Issue still present in Python - 1 random test case is wrong due to truncation vs. (correctly) adding up in terms of pennies and then converting to dollars
I agree.
Ruby translation, please check and accept :-)
example test cases have switched output between expected and actual.
done
Issue is still present: by looking your test cases, you are truncating, not rounding.
I'm getting $20.51 with the following, which is the right result.
or
{'dollar': 17, 'quarter': 8, 'dime': 10, 'nickel': 9, 'penny': 6}
In the current tests, truncating causes issues with upper half decimals. That's why you have to use '{:.2f}'.format instead of manually cutting a not viable string representation.
corrected
oops... x)
Python test cases are wrong in 3.4 due to floating point issue. The validator function splits at decimal separator and joins integer and decimal parts, but due to decimal representation in binary, it leads to strange errors like
Enforce the rounding operation with builtin
round
or better with text formatting'{:.2f}'.format
I've visited the Python 3 version and fixed the issue! :D
Still not working
'$23.26' should equal '$23.25'
Test data: "dollar dollar nickel quarter nickel dime dime dollar penny dime dime nickel dollar nickel dime dollar penny nickel dollar nickel dollar penny nickel penny quarter quarter dollar quarter penny quarter quarter dime dollar dollar dollar dime dime nickel dollar quarter dime quarter penny dollar dollar dollar nickel dime dollar dollar"
That's even not the amount I'm getting.
I'm consistently getting
'$20.50'
in both versions.Issue is still present: by looking your test cases, you are truncating, not rounding. I'm getting $20.51 with the above test, which is the right result: truncating induces issues with upper half decimals.
That's why you have to use
'{:.2f}'.format
instead of manually cutting a not viable string representation.Description of CHANGE is wrong. It's not:
but
Definitely not the same
I've updated it to avoid confusion. :D
Some strange error in python kata '$20.24' should equal '$20.2400000000000020'
the instructions seem to allude that the CHANGE dictionary has string values, for example "$0.01" for penny. But it really has floats like 0.01. Loved the Kata. Thanks.
These amounts are already preloaded as
floats
into the CHANGE dictionary for you to use!Glad you enjoyed! :D
Agreed, this is confusing. Suggestion: rewrite the description so that the code block following "Valid types of change include:" shows what the actual preloaded CHANGE dictionary will look like.
JS translation kumited. If you wish to approve it.
It has been approved!
Thanks for the translation.
@Caders
,This kata might be a good example for using a preloaded dictionary. Currently, 3 out of 5 solutions are using a dictionary with the values of each coin. For my solution, I used integers instead of floats so there weren't any issues with floating point accuracy.
If you add a dictionary to the preloaded section, just make sure to tell people the name of it in the description (and even a comment above the
Initial Solution
can be helpful):CHANGE = {'penny': 1, 'nickel': 5, 'dime': 10, 'quarter': 25, 'dollar': 100}
That way everyone doesn't have to put the exact same dictionary in all of their solutions!
I'm not saying you have to do this (it's up to you), I was just thinking about it after our discussion on your other kata.
Thanks for bringing it up.
Looking at the new solutions, I will definitely add it for convienence of anyone who takes the dictionary route!