7 kyu

Loose Change!

779 of 1,771Caders
Description
Loading description...
Fundamentals
  • Please sign in or sign up to leave a comment.
  • danocode82 Avatar

    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!!

  • El-Loco-Pinguino Avatar

    Nice one.

    However, it misses a sample test where the answer is xx.00.

  • user8436785 Avatar

    PHP translation kumited 🙂

  • rowcased Avatar

    This comment has been hidden.

  • temen Avatar
    1. Swap arguments in basic ceses!
    2. Old problems still exist! Odd number of pennies cannot give "0" as last digit.
  • stauntonjr Avatar

    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

  • adrian.eyre Avatar

    Ruby translation, please check and accept :-)

  • mmalkavian Avatar

    example test cases have switched output between expected and actual.

  • lechevalier Avatar

    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.

    "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"
    

    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.

  • lechevalier Avatar

    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

    '$20.24' should equal '$20.2400000000000020'
    

    Enforce the rounding operation with builtin round or better with text formatting '{:.2f}'.format

  • lechevalier Avatar

    Description of CHANGE is wrong. It's not:

      penny: '$0.01'
      nickel: '$0.05'
      dime: '$0.10'
      quarter: '$0.25'
      dollar: '$1.00'
    

    but

      penny: 0.01
      nickel: 0.05
      dime: 0.10
      quarter: 0.25
      dollar: 1.00
      
    

    Definitely not the same

  • jerod84 Avatar

    Some strange error in python kata '$20.24' should equal '$20.2400000000000020'

  • Austin Haws Avatar

    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.

  • ZozoFouchtra Avatar

    JS translation kumited. If you wish to approve it.

  • zebulan Avatar

    @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.