7 kyu
Converting integer to currency format
686 of 4,060kimh
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.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/225.
Please join the discussion to help us identify duplicate kata and retire them.
Surprisingly hard if you don't use any formatting.
python new test framework is required. updated in this fork
Approved
This comment has been hidden.
JS Node 18. should be enabled
Ruby 3.0 should be enabled
In the Python version of the kata, I would like to report the first test. It should be 123456 instead of 213456 I guess.
Cannot see the issue.
CoffeeScript translation Kumited! Please Accept :D
Approved
There are not enough tests included with this. I got through with an algorithm I know was incorrect and got through to 7 kyu. I feel dirty :(
why must seocond test return "1,234" ? I think it has to return "123,4"
I'm getting this error every time I try to submit my solution:
"Submission timed out while communicating with our servers. This may infrequently happen if our servers are extremly busy. Please try again. If issues persist you can check status.codewars.com to see if server issues are being investigated."
Has anyone have the same issue?
This comment has been hidden.
I think, insertting commas every 3 numbers is a method, but not a good one. format(price, ',d'), or something like that is clever but not a suitable one. It is the feature of finance respect of every 3 numbers a comma. format(price, ',d') solves it by chance.
In my opinion, I used the recursion method. If you like it, you can check my code. Enjoy...
My answer works in dev tools but not when I test in codewars, has anyone else had a problem?
I'm having a timeout with the server every time I send it, do you have the same error?
Is there any test for numbers similar to 1234567 so that it would equal 1,234,567 as my solution passed even though it was incorrect for 7 digit numbers.
This comment has been hidden.
Can Anyone explain me the best solution, I mean with "format"? thanks a lot.
It's usually better to comment the solution instead of the kata. The best solution might change over time, and then the explanation won't fit the solution anymore.
This comment has been hidden.
Hmmm... I have right answers, but still I can`t pass test:
Expected: 123,456, instead got: 123,456, Expected: 1,234, instead got: 1,234, Expected: 123, instead got: 123, Expected: 123,456,789,012, instead got: 123,456,789,012,
I can`t get what is wrong with the output
I found what is wrong with my code=) I interpreted the last comma after "currency" as a part of the answer(and I made a code for it), but it is only separator between the expected and real answer ^_^ I leave this post here for somebody else who can have problems with commas.
Why not define two or more decimal values and include it in the format?
The kata could include the following, as parameters of the function:
example prototype: def to_currency(price, precision=0, decimal_sep=".", thousand_sep=",")
results: to_currency(1234, 0, ".", ",") => 1,234 to_currency(123456, 2, ".", ",") => 1,234.56 to_currency(1234, 3, ",", ".") => 1,123
This Kata has already been done: "Grouped by commas" http://www.codewars.com/kata/5274e122fc75c0943d000148
HEXecutive showed the way with a simple solution.
Hey, GiacomoSorbi.
Thank you for your work! Let me have a look tonight and I'll get back to you.
Thanks
Oh, I wasn't notified on this one; my pleasure being of help and honing my skills with the interesting kata you created :)
I translated it into both Python and JS, taking the liberty to add some more test case; once you integrate them in your kata, with two more languages the beta process should flow faster :)
Let me know if you think I can improve of fix anything in my translations :)
Your test cases are wrong. Right now, everything that returns something truthy will pass.
Please change them to the form:
Thanks for telling me this. I changed the tests.