Beta

Print chains

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • bdupau Avatar

    Given initial array

    [
      'KJ', 'JK', 'wr', 'Dk', 'N6', 'oU', 'Uo', 'sX',
      'Kc', 'cK', '5A', 'A5', 'xT', 'Tx', 'RO', 'OR',
      'yV', 'Vy', '8Q', 'qq', 'KM', 'MK', 'kQ', 'Qk',
      'Hy', 'yH', 'BQ', 'QB', 'jP', 'Pj', 'ZN', 'wI',
      'Iw', 'Yo', 'oY', 'EO', 'Yx', 'xY', 'cJ', 'Jc',
      'yr', 'ry', 'fe', 'ef', 'll', 'll', 'Hq', 'U5',
      'g3', '3g', 'BB', 'yN', 'Ny', 'A0', '0A', 'Nv',
      'aR', 'Ra', 'Po', 'oP', 'ab', 'p2', '2p', 'wd',
      'dw', 'Ev', 'vE', 'pm', 'ir', 'ri'
    ]
    

    The first entry of the reference solution is {"wr":["wrriirryyVVyyHHyyNN6","wrriirryyVVyyHHyyNNvvEEOORRaab"]}. This doesn't satisfy the rule that chains in each of resulting array's element's value should respect initial array's elements order. You can't continue the chain after wrri because ri is the last element.

    Also, I would expect the solution to start with {"KJ":["KJJc",...]}. But that's another issue.

    Please fix the solution or describe the problem better.

  • Voile Avatar

    Random tests break if input is modified from user code.

  • Voile Avatar

    Reference solution is obviously wrong: it rejects any keys that contain the pattern AbbA if both Ab and bA are in the input list.

  • JohanWiltink Avatar

    I suspect your reference solution has a horrible bug. Note that you have no solutions.

    What would be the expected outcome for (["ab","ba"]) ? If it's not { ab:[abba], ba:[baab""] }, you should update the description. If it is, take a good look at your reference solution.

    Generating ridiculously long input arrays for the random tests isn't helping - it's almost imposible to debug because you're drowning in data. I'm not getting time-outs - I'm getting console overflows from printing all the actual and expected values. ( Also, use Test.assertDeepEquals. Yes, it's undocumented. )

  • Voile Avatar

    Sort of an issue:

    All the chains in the fixed tests have elements in sequential order in which they appear in the data array, but random tests apparently assumes the opposite. (And it's not clear in the descriptions that it's the case either.)

  • Voile Avatar

    PS1: Chains in each of resulting array's element's value should respect initial array's elements order.

    [ 'AB', 'AD', 'DB', 'BC', 'BS', 'CE' ]
    Expected: '[{"AB":["ABBS","ABBCCE"]},{"AD":["ADDBBS","ADDBBCCE"]},{"DB":["DBBS","DBBCCE"]},{"BC":["BCCE"]}]'
    

    In what order? First by length and then...?

  • docgunthrop Avatar

    There's something wrong with the tests. I didn't code anything and it just passes.