Ad
  • Custom User Avatar

    Yeah, it fails the 'Larger Tests' when I try running it. Maybe it was submitted prior to harder test cases being edited in?

  • Custom User Avatar

    @bestwebua - you've actually also disabled sub/gsub and sub!/gsub! as string functions in Ruby. This is super annoying, those functions are so critical to string manipulation and they don't necessarily involve regex, so you've thrown the baby out with the bath water... :/

  • Custom User Avatar

    This is a beautifully elegant solution, but it fails for "I can't see you". It can't shuffle that sentence. The only valid answer should be "I cna't see you" but this solution treats apostrophes as word-breaking. Luckily the kata doesn't test for apostrophes, but the "All punctuation should remain in place" rule is unclear about how apostrophes should be handled. This puzzle is much harder if testing for this extra layer.

  • Custom User Avatar

    I thought that apostrophes would be tested, so I did a much more brute-force solution. I now realise that apostrophes aren't tested and all punctuation can be treated as 'outside of' the words being shuffled.

    "Won't" in my code would be shuffled to "Wno't" but most code submissions here would do "Won't" because "Won" is treated as the word and "t" as a separate word. Wish I'd known that, I would have used RegEx.

  • Custom User Avatar

    Hi,

    I tried to fork this to fix the terrible description of the original Kata, but my fork failed the tests for some reason despite me not editing anything but the description. (Getting 'no method error' on Test:Module for Test.it for some reason). Could you please update the description?

  • Custom User Avatar

    This solution doesn't add the gold pieces within each block. For "asfhg2g9g9; ao g12l. oasG2G0;G18" it outputs "G18" instead of "asfhg2g9g9" which totals to 20.

    It's a shame the test cases didn't actually prevent this.

  • Custom User Avatar

    Underscores would have foiled this solution if they were tested, since \w includes them but they are a form of punctuation. Great solution otherwise.

  • Custom User Avatar

    Yeah, same. This is such a fun site to practice RegExp on... I had run out of RegEx challenges on most other sites! xD

  • Custom User Avatar

    The Ruby description is currently missing the last line that is essential to solving this:

    Write a function compare(section1, section2) that returns -1, 0, or 1 depending on whether section1 is before, same as, or after section2 respectively.
    

    Without that, the question isn't defined. I have submitted a fork of the Ruby translation but it may take some time to be accepted.

  • Custom User Avatar

    Thanks for this answer, I was stuck. Got 100% on the tests, but failed a bunch of the random tests. Had no idea why, I still don't understand why duplicating the input was necessary but it solved the problem...

  • Custom User Avatar

    Very nice, very Ruby. Great solution, will have to remember .default_proc in future!

  • Custom User Avatar

    I don't understand how this is only 6 kyu... this is incredibly complex for me.
    I am using Ruby and want to solve this, but it requires me to bypass the normal "element reference" method for a hash.

    I tried monkey patching the method, but this fails. I have tried creating a sub-module of Hash that allows me to redefine the "[]" method, but this is also failing. I've spent a long time on this and am nowhere near solving it... This is 30 times harder than any 6 kyu I've solved... might be easy once you know how, but it's very hard to figure out from scratch.

  • Custom User Avatar

    Yeah, very disappointing to see this top-rated with such an obvious error.

  • Custom User Avatar

    This is quite a lazy answer for top-rated. The comments below mention it will accept numbers etc, which I think isn't even that bad compared to the fact it will accept spaces and slashes, etc.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Loading more items...