Ad
  • Custom User Avatar

    In fully half of the cases, the random tests expect the entire string quoted back because max >= string.length.

    Bit of a waste of tests. Better to have max < string.length more often.

  • Custom User Avatar

    There's still exclamation marks without spaces after them, and the reference solution still bugs out on that.

    I think my own solution is still buggy as well, but I'm getting a bit tired of having to check the reference answer first all the time.

    Please, please, please, fix your kata. (insert expletives sprinkled generously throughout. sigh.)

  • Custom User Avatar

    I think I've fixed this problem now...? I've also updated the description.

  • Custom User Avatar
    "? FrVxxAajpt; GNOSVrEqJX? omuzuo: vw, MDVGLjUKGB zZD? sRN, AZJvgKZTXp? xUDenNUoWi, uhQHIHE. Ilfv", max = 39
    Expected: '? FrVxxAajpt; GNOSVrEqJX? omuzuo...', instead got: '? FrVxxAajpt; GNOSVrEqJX? omuzuo: vw...'
    

    "..: vw..." fits in 39 characters exactly. The reference solution may still contain a bug.

  • Custom User Avatar

    In that case, I'd specify in the description that a punctuation character will always be followed by a space.

  • Custom User Avatar

    Very true. I think I've fixed this by using your first solution. Thanks again!

  • Custom User Avatar

    Yep, that's fixed.

  • Custom User Avatar

    Generally, punctuation separates words, doesn't it? If it doesn't, that's OK, but you should explicitly, and clearly, specify that I think.

    If you actually wanted spaces after punctuation anyway, one solution would be to run a String.replace( /punctuation/, "$& " ) on the generated random input ($& expands to the matched string). You'd have to trim any trailing space. Or you could generate separate words in an array (of random length), randomly append punctuationto the ends of some words, then Array.join(" ") then together. That prevents any trailing space in the first place.

  • Custom User Avatar

    Thanks again! I didn't know how to make the random strings always include a space after punctuation so for simplicity's sake I was considering the punctuation as part of the 'word'. Is this confusing? Do you have any advice on how to improve this? This is my first attempt at authoring a kata so really appreciate your help.

  • Custom User Avatar

    There should have been a space either side of the dash - that should be fixed now. Thanks for spotting.

  • Custom User Avatar

    From the random tests:

    input: "uWTewfsYWwphJndJxzDn YsXiWHWotwqbRT!VGOIzydmQh.oMfIHuWR..", max = 54
    Expected: 'uWTewfsYWwphJndJxzDn...', instead got: 'uWTewfsYWwphJndJxzDn YsXiWHWotwqbRT!VGOIzydmQh...'
    

    Does punctuation not separate words?

  • Custom User Avatar
    Test.assertEquals(shortQuote("1801—I have just returned from a visit to my landlord—the solitary neighbour that I shall be troubled with.", 9), "1801...")
    

    Why not "1801-I..." ?