4 kyu

Minimum Number of Coins

274 of 280GiacomoSorbi
Description
Loading description...
Parsing
Strings
Fundamentals
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    Expected handling by random tests are utterly nonsensical:

    Testing for 0.19p
    It should work with random inputs too - Expected: '1 10p coin, 1 5p coin and 2 2p coins', instead got: 'Invalid input - enter a positive amount of money'
    
    Testing for £13p
    It should work with random inputs too - Expected: '6 £2 coins and 1 £1 coin', instead got: 'Invalid input - enter a positive amount of money'
    
    Testing for £1.57p
    It should work with random inputs too - Expected: '1 £1 coin, 1 50p coin, 1 5p coin and 1 2p coin', instead got: 'Invalid input - enter a positive amount of money'
    

    The whole point of the kata is to parse input from a "dumb" user, so cases are meant to be confusing - edge cases are meant to be messed up

    You simply tell "dumb" users the input was wrong, not forcefully gobble up the value and produce completely insane results. The premise of this kata's """edge case handling""" is unconvincing.

  • glynester Avatar

    Fun kata! :) My initial solution would occasionally fail some of the random tests although I could have submitted it. But of course it's hard to design testing to cover every eventuality especially where the test input can be as varied as this.

  • KenKamau Avatar

    Very annoying Kata, but very entertaining. Thanks.

  • scoobyed Avatar

    Certainly made me think on edge cases this, passing all but one test "Testing for .5 Expected: 'Invalid input - enter a positive amount of money', instead got: '1 50p coin'" given "if the number is a float, the value is in pounds, otherwise consider it as pennies" not sure this sits right with me, the value is a float given the decimal point, but with no decimal part, the pennies portion I'd see as valid?

  • FArekkusu Avatar

    do not count fractions of pennies: 1.257422457p == 1.26p

    According to your tests 1.257422457p == £1.26.

  • titelhalter Avatar

    Great kata overall! However, I believe that input like £1p should return 'Invalid input - enter a positive amount of money'. Since £ at the beggining means we are dealing with pounds and "p" at the and means pennies, this input become really tricky because we don`t know which sign is more important in this particular case. I would suggest considering as valid only "£1", "£1.0p" or "1p" as far as here will be no space for misunderstanding.

  • cyril-lemaire Avatar

    Testing for £1.87p

    Expected: '1 £1 coin, 1 50p coin, 1 20p coin, 1 10p coin, 1 5p coin and 1 2p coin', instead got: 'Invalid input - enter a positive amount of money'
    

    I may have missed something in the description, but all I found about this was

    the "£" symbol may come first (and in this case assume that the value is in pounds), the "p" symbol may come last - any other position for them is just wrong
    

    How can it be okay to have BOTH in the same description? They're litterally contradictory! If what's intended there is to show that the description does not clearly state that if p is a the end of the amount the value is in pence) then good job, you've just ruined your kata trying to be funny.

    And then you contradict even your own rules:

    minCoins("001.41p")
    Expected: '1 £1 coin, 2 20p coins and 1 1p coin', instead got: '1 1p coin'
    

    The rules state if a float with no symbol is given, assume it is a value in pounds and round it to the second decimal
    WITH NO SYMBOL! What is it now, 'p' is no longer a symbol? It's not even subtle, the rules themselves said it was two lines above u_u
    And that part is followed by do not count fractions of pennies: 1.257422457p==1.26p which is self-contradictory as well, if we don't count fractions of pence then 1.257422457p == 1p unless, once again 'p' is actually meaningless and should be read "pounds" when after a float.

    Difficulty from voluntarily misleading statements is the worst you could do. If I'm misunderstanding what you meant to do or if there's an actual mistake in the tests then please enlight me (Sorry if I sound frustrated ; I am, because your kata are usually good so I take it for granted... Ok my bad, I shouldn't get carried away).

    Note: I did it in Javascript, but I don't think it matters because I'm just talking about the description and Fixed test cases here

  • B1ts Avatar

    Great mind-bending kata with all those edge cases and what not. Quite tough to get an optimal and good-looking solution ;-)

    Thanks for making it!

  • argonprogramming Avatar

    Why is "L200" invalid? Is it not just 200 pounds?

  • Firefly2002 Avatar

    Overall a fun Kata. My solution's a complete mess at the moment as a result of all those edge cases lol although obviously that's my fault for doing it piecemeal. I did find the floats in pence to be a bit odd. Overall fun though. Not sure why it has so few completions/votes.

  • craigaaroncampbell Avatar

    This comment has been hidden.

  • wthit56 Avatar

    This comment has been hidden.

  • MMMAAANNN Avatar

    CoffeeScript translation added, description modified. Please accept.

  • MMMAAANNN Avatar

    What about '23.1p', will it be considered a valid input, and if so, should it be evaluated as 23 pennies? I think the test cases are missing this corner case.

    Also, for me input like "£2p" doesn't look valid, it rather looks ambiguous. I can hardly imagine somebody writing money amount like that in real life. I can understand a format "£2.00p" (with a dot), but integer pounds with 'p' suffix looks strange to me.

  • GiacomoSorbi Avatar

    Python and Ruby translation should follow shortly; translation in other languages as well as any feed are welcome as always :)