• Custom User Avatar
  • Custom User Avatar

    It looks like some twopair are tagged as pair. Try this:
    expected.add(new PokerHand("7S 5H 7H 4S 4C")); // two pair, 7's and 4's
    expected.add(new PokerHand("7S 7H 2H 2S 6C")); // two pair, 7's and 2's
    expected.add(new PokerHand("2S 2H 3H 3S 9C")); // two pair, 3's and 2's
    expected.add(new PokerHand("8S 9H 8H KS 4C")); // pair of 8's, K high

  • Custom User Avatar

    IGNORE - I figured out where my logic went awry:)

    In the final test this is at 2469: "100001111111110000111100011111111101111100001". Since a letter is made up of a maximum 4 dot-dash-combo, if you look at any 5 consecutive "0"-segments, one of them has to represent "000" (a letter break). Therefore this section at 2469 says that "0000" represents a letter break, and thus "000...0" represents a letter or word break. That just doesn't work. What's wrong with my logic?

  • Custom User Avatar

    Lengths are consistent in one test case, but can differ between test cases.

    It is possible that 1111 is a dash, and 111111 is a dot in another invocation of your function in different input, but not in one input string.

  • Custom User Avatar

    Is it possible for '1111' to be a dash, while '111111' is a dot? Or, once a length of 1's is found to be a dash, all length's of 1 greater than this would also be a dash? i.e. If '1111' is a dash, then '11111' and '111111' would also be dashes.

  • Custom User Avatar

    Note that some extra 0's may naturally occur at the beginning and the end of a message, make sure to ignore them.

    You're in this case. After discarding the 0s, you're left with 111 and you're in this other case:

    Also if you have trouble discerning if the particular sequence of 1's is a dot or a dash, assume it's a dot.

  • Custom User Avatar

    Why would '01110' have a time unit other than 1? '0' is the maximum pause time unit in the test case, which implies pause, dash, pause. If '111' was a dot of 3 time units, then what is '0'? A third of a time unit pause??

  • Custom User Avatar

    I finally re-read the instructions and worked out how to handle null :) Thank you for all your help.

  • Custom User Avatar

    :+1:

    ok, it's actually pretty simple: in the test cases part, that method contains another test. It's a classic stuff/problem, in java... x)

    You should just... either read the error message or print the actual input to the console. Then you'll pretty quickly be done with it.

    Note: printing stuff to the console should be your number one reflex ;p

  • Custom User Avatar

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

  • Custom User Avatar

    could you post your complete/working current code, plz? (with imports and all: last time it didn't work on cw)

  • Custom User Avatar

    I understand!! My code works for all sample tests and test cases EXCEPT for the testEmpty test case. This is weird because the sample tests have a testEmpty also, and I passed that one. In both tests, the buffer parameter was "" and its length 0. The test case just says it failed so I have no idea what to correct. Are you able to give me a clue or is that cheating?

  • Custom User Avatar

    cw==codewars ;)

    Nope, I looked at the Java version too. so it's definitely... wait... Ah ok... you're looking at the sample tests while I was looking at the test cases part... :/ For some reason the 1 became a 2 in the former...

    about what I said: at the very end of the contructor, if you System.out.println(hasNext()), you'll see it returns false, hence your iterator is already consumed, and that's the reason you get an empty array in the tests.

  • Custom User Avatar

    Thank you. It will take me some time to fully understand what you've written. In the meanwhile, what is 'cw'?
    Also, I'm doing this in Java, maybe that's why our tests are different? (testStatement uses "return x + 1" for me.)

  • Custom User Avatar

    plz use correct markdowns formatting (otherwise it's a bit of a pain to read the code. Hopefully, it's not critical in java...)

    I cannot run the sample tests with your code, actually (even after adding the imports). But for what I can see in the constructor, it seems you're consuming the iterator right into it (because of the last while loop), meaning you're not actually implementing an iterator (that should be consumed "from outside"). Hence, if you tried your code locally, I guess you didn't reproduce the sample tests correctly.

  • Loading more items...