6 kyu

Deep and universal search by object

Description
Loading description...
Trees
Algorithms
Data Structures
  • Please sign in or sign up to leave a comment.
  • aland97 Avatar

    not specified that 'obj' don't have any circular references, or maybe i misread)

  • dfhwze Avatar

    Fixed tests have undefined, random tests do not.

  • EntityPlantt Avatar

    I solved the Kata. Were there any NaNs?

  • Voile Avatar

    Array path being recorded as .2 is not standard JSON path notation: it should be [2] instead of .2.

  • Blind4Basics Avatar

    Hi again,

    Raising the problem below as issue (you can ignore the message below): here are the hidden specs:

    the correct expected solution assumes an object/array can never be a "match". That's why my code, when receiving Boolean as predicate, was extracting more values than yours.

    So (all these should be present in the sample tests and the full test suite):

    • missing fixed tests with null as value in the tree
    • missing fixed tests searching for null, also
    • missing fixed test with Boolean as predicate
    • missing a clear specification about what kind of data the predicate should be applied to or not
    • missing fixed test like searching 2 while "2" is present in the tree (this should also be cleared out by the description)
    • you can remove the bullet point about Order of the items in the output do not matter: it's implicit, considering the output type (so it's sort of a "non information")

    Cheers

  • Blind4Basics Avatar
    • you have hidden specs in the tests. Good luck with that: x)

       { 'tree.s4592': 70, 'tree.yk3xkr': 'nfyum9', 'tree.jpkad9': { i52qze: false }, 'tree.1jw5a': { w1gpso: { '93ndmb': false, '0r5odl': 'ff5avb', msa5n: { ifukcs: 'scoefh' }, r9pi5x: { v0f3f: 76, p2f6kf: 25, '8oofpk': 84, '8uesun': 'ikisle' } }, jqz9pc: 'kce79r', '08uy9i': 98, b82e9s: { dgpqlg: { xclswg: { gewb5c: '0om9d', '14zeq': '9lccef', bw1gok: 'qmobbu', fxx0yy: '9sa45', ii8fjc: 56 }, bbr75: true, ec54qt: 'n2xp5', pnqtk4q: '5qxn4j' }, is14wk: true, w27ouo: 48 }, ryuvf: false }, 'tree.1jw5a.w1gpso': { '93ndmb': false, '0r5odl': 'ff5avb', msa5n: { ifukcs: 'scoefh' }, r9pi5x: { v0f3f: 76, p2f6kf: 25, '8oofpk': 84, '8uesun': 'ikisle' } }, 'tree.1jw5a.w1gpso.0r5odl': 'ff5avb', 'tree.1jw5a.w1gpso.msa5n': { ifukcs: 'scoefh' }, 'tree.1jw5a.w1gpso.msa5n.ifukcs': 'scoefh', 'tree.1jw5a.w1gpso.r9pi5x': { v0f3f: 76, p2f6kf: 25, '8oofpk': 84, '8uesun': 'ikisle' }, 'tree.1jw5a.w1gpso.r9pi5x.v0f3f': 76, 'tree.1jw5a.w1gpso.r9pi5x.p2f6kf': 25, 'tree.1jw5a.w1gpso.r9pi5x.8oofpk': 84, 'tree.1jw5a.w1gpso.r9pi5x.8uesun': 'ikisle', 'tree.1jw5a.jqz9pc': 'kce79r', 'tree.1jw5a.08uy9i': 98, 'tree.1jw5a.b82e9s': { dgpqlg: { xclswg: { gewb5c: '0om9d', '14zeq': '9lccef', bw1gok: 'qmobbu', fxx0yy: '9sa45', ii8fjc: 56 }, bbr75: true, ec54qt: 'n2xp5', pnqtk4q: '5qxn4j' }, is14wk: true, w27ouo: 48 }, 'tree.1jw5a.b82e9s.dgpqlg': { xclswg: { gewb5c: '0om9d', '14zeq': '9lccef', bw1gok: 'qmobbu', fxx0yy: '9sa45', ii8fjc: 56 }, bbr75: true, ec54qt: 'n2xp5', pnqtk4q: '5qxn4j' }, 'tree.1jw5a.b82e9s.dgpqlg.xclswg': { gewb5c: '0om9d', '14zeq': '9lccef', bw1gok: 'qmobbu', fxx0yy: '9sa45', ii8fjc: 56 }, 'tree.1jw5a.b82e9s.dgpqlg.xclswg.gewb5c': '0om9d', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.14zeq': '9lccef', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.bw1gok': 'qmobbu', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.fxx0yy': '9sa45', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.ii8fjc': 56, 'tree.1jw5a.b82e9s.dgpqlg.bbr75': true, 'tree.1jw5a.b82e9s.dgpqlg.ec54qt': 'n2xp5', 'tree.1jw5a.b82e9s.dgpqlg.pnqtk4q': '5qxn4j', 'tree.1jw5a.b82e9s.is14wk': true, 'tree.1jw5a.b82e9s.w27ouo': 48 } 
       should deeply equal
       { 'tree.s4592': 70, 'tree.yk3xkr': 'nfyum9', 'tree.1jw5a.w1gpso.0r5odl': 'ff5avb', 'tree.1jw5a.w1gpso.msa5n.ifukcs': 'scoefh', 'tree.1jw5a.w1gpso.r9pi5x.v0f3f': 76, 'tree.1jw5a.w1gpso.r9pi5x.p2f6kf': 25, 'tree.1jw5a.w1gpso.r9pi5x.8oofpk': 84, 'tree.1jw5a.w1gpso.r9pi5x.8uesun': 'ikisle', 'tree.1jw5a.jqz9pc': 'kce79r', 'tree.1jw5a.08uy9i': 98, 'tree.1jw5a.b82e9s.dgpqlg.xclswg.gewb5c': '0om9d', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.14zeq': '9lccef', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.bw1gok': 'qmobbu', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.fxx0yy': '9sa45', 'tree.1jw5a.b82e9s.dgpqlg.xclswg.ii8fjc': 56, 'tree.1jw5a.b82e9s.dgpqlg.bbr75': true, 'tree.1jw5a.b82e9s.dgpqlg.ec54qt': 'n2xp5', 'tree.1jw5a.b82e9s.dgpqlg.pnqtk4q': '5qxn4j', 'tree.1jw5a.b82e9s.is14wk': true, 'tree.1jw5a.b82e9s.w27ouo': 48 }
      
    • missing fixed tests with null as value

  • Blind4Basics Avatar

    I think your random generator is somehow broken: the very first random test always gives me somthing like:

    Log
    [null] function
    
    expected { tree: { b9rbhm: 43 }, 'tree.b9rbhm': 43 } to deeply equal { 'tree.b9rbhm': 43 }
    

    So I think you systematically generate a function, and that function seems to always return true on the root object (not entirely sure...)


    btw, you didn't specify what the expectations are about nested objects in arrays, as far as I can see (but I just made a quick sweep in the description, maybe I missed it)

  • Blind4Basics Avatar
    • all the sample tests should be present as well in the full test suite

    • I think this is a duplicate, actually (only difference being that you provide several arguments to search for, but that's not different enough)

  • Blind4Basics Avatar

    random tests seems to be broken (I'd bet on your function calling mine through recursion):

    ReferenceError: getValues is not defined
        at /workspace/node/test.js:121:12
        at Array.reduce (<anonymous>)
        at solution (test.js:99:36)
        at Context.<anonymous> (test.js:186:9)
        at process.processImmediate (node:internal/timers:471:21)
    
  • Blind4Basics Avatar

    Hi,

    • no sample tests with a predicate -> the last sample tests should be renamed predicate instead of helper.
    • the order in the output isn't specified (and so far, it doesn't look like it makes any sense)
    • it's not sepcified if the arrays can contain other nested objects

    Cheers

  • rowcased Avatar

    no random tests

  • rowcased Avatar
    ReferenceError: findItems is not defined
        at Context.<anonymous> (test.js:34:12)
        at process.processImmediate (node:internal/timers:471:21)