7 kyu

Converting integer to currency format

686 of 4,060kimh
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • hobovsky Avatar

    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.

  • shekelboi Avatar

    Surprisingly hard if you don't use any formatting.

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • HedgehogInTheMist Avatar

    This comment has been hidden.

  • ejini战神 Avatar
    • JS Node 18. should be enabled

    • Ruby 3.0 should be enabled

  • yamatogun Avatar

    In the Python version of the kata, I would like to report the first test. It should be 123456 instead of 213456 I guess.

  • Javatlacati Avatar

    CoffeeScript translation Kumited! Please Accept :D

  • raavin Avatar

    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 :(

  • Riselm Avatar

    why must seocond test return "1,234" ? I think it has to return "123,4"

  • codeandrop Avatar

    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?

  • kayimbo Avatar

    This comment has been hidden.

  • muddybarefeet Avatar

    My answer works in dev tools but not when I test in codewars, has anyone else had a problem?

  • volkandkaya Avatar

    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.

  • broomstick73 Avatar

    This comment has been hidden.

  • levium Avatar

    Can Anyone explain me the best solution, I mean with "format"? thanks a lot.

  • Paradoks Avatar

    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

  • mjsr Avatar

    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:

    • precision, right now it would be 0 as you don't have decimal values
    • decimal separator
    • thousand separator

    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

  • daddepledge Avatar

    This Kata has already been done: "Grouped by commas" http://www.codewars.com/kata/5274e122fc75c0943d000148

    HEXecutive showed the way with a simple solution.

  • kimh Avatar

    Hey, GiacomoSorbi.

    Thank you for your work! Let me have a look tonight and I'll get back to you.

    Thanks

  • GiacomoSorbi Avatar

    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 :)

  • Abbe Avatar

    Your test cases are wrong. Right now, everything that returns something truthy will pass.

    Please change them to the form:

    Test.assert_equals(to_currency(price1), "123,456")