Ad
  • Default User Avatar

    We seem to be talking past each other. The logic is, you find a triple, check if a double exists. If not, look for another triple, see if a double exists, rinse repeat. Having multiple triples shouldn't trip up your code. I'm not sure why your code would short circuit by looking at just one triple/double (i.e the first one you find) pair and not consider the rest of the numbers after it?

  • Default User Avatar

    Very nice! This solution eats my solution before breakfast :´-)

  • Default User Avatar

    Yes. I understand this.

    The thing is: In my example you check only for "33" in num2 if you do not understand there could more than one triple in num1.

    So I suggest show such a case in the Kata description...

    Just my 2cents...

    Have a nice one!

  • Default User Avatar

    Hey mate. It doesnt matter how many triples show up, there will always be just one double i.e matching up with one triple. So num1 could consist of just triples, num2 will have just one double and vice versa

  • Default User Avatar

    Hi. Thx for your reply!

    In my example, the first triple would we "333" (plus we have "888" and "666"; so "multiple" triples in num1).

    In the Kata-description, in all examples provided, you only see max. one triple in each num1.

    One could argue that in a random number multiple triples are of course a possibility but I think it may be easier to grasp the challenge if you actually show this possbility.

    I, for example, assumed there could be only one triple in num1 so I needed to research why some tests failed.

    Best wishes!

  • Default User Avatar

    Hi. In your example 888 and 88 are the only pair, not sure what you mean by multiple doubles/triples?

  • Default User Avatar

    I suggest to enhance the instructions to make more clear that multiple tripples/doubles are possible per number

    E.g.:
    num1: 8611223333888666 num2: 495281788

  • Default User Avatar

    Don't use a for...in loop.
    You can read why here

    EDIT:
    Also, you can format code by using three backticks: ```. It makes it much easier to read.

    function add(a, b) {
      return a + b;
    }
    
  • Custom User Avatar

    Post your code, mark the post as having spoiler content. Probably the problem is in your code given 3399 other warriors passed this kata in javascript.

  • Default User Avatar
  • Default User Avatar

    Something weird is happening with the javascript random tests - all 40 are failed with the same error:
    "It should work on random inputs too! - Expected: '[24, 31, 20, 14, 31, 14, 14, 31, 48, 2, 24, 41, 31, 48, 31, 14, 14, 14, 13, 2, 33, 20, 31, 24, 20, 24, 33, 2, 48, 33, 33, 33, 2, 13, 48, 13]', instead got: '[24, 31, 20, 14, 31, 14, 14, 31, 48, 2, 24, 41, 31, 48, 31, 14, 14, 14, 13, 2, 33, 20, 31, 24, 20, 24, 33, 2, 48, 33, 33, 33, 2, 13, 48, 13, undefined]'".
    Used console.log to check the tests input and run the same input in console - everything works, no 'undefined' at the end. Can anyone please tell what's wrong?

  • Default User Avatar

    there is a typo(?): "given the list >Ist<" ?