6 kyu

Seventh JSON of a seventh JSON

117 of 190kingcobra
Description
Loading description...
JSON
Recursion
Fundamentals
  • Please sign in or sign up to leave a comment.
  • natan Avatar

    I don't think it's ok that some test cases exceed 1MB (while still allowing plenty of incorrect solutions) .. and it's kind of silly that thousands of people use only a couple handfulls of names as well.

  • natan Avatar

    Question: Is O a ssoss?

    Issue1: this is not tested (python), specifically that a daughter comes before the seven sons

    Issue2: description is vague on what the result should be

    {
        "name": "A",
        "gender": "male",
        "children": [
            {"name": "BBBB", "gender": "female", "children": []},  # <- a first female child followed by 7 male. allowed?
            {"name": "B", "gender": "male", "children": []},
            {"name": "C", "gender": "male", "children": []},
            {"name": "D", "gender": "male", "children": []},
            {"name": "E", "gender": "male", "children": []},
            {"name": "F", "gender": "male", "children": []},
            {"name": "G", "gender": "male", "children": []},
            {
                "name": "H",
                "gender": "male",
                "children": [
                    {"name": "I", "gender": "male", "children": []},
                    {"name": "J", "gender": "male", "children": []},
                    {"name": "K", "gender": "male", "children": []},
                    {"name": "L", "gender": "male", "children": []},
                    {"name": "M", "gender": "male", "children": []},
                    {"name": "N", "gender": "male", "children": []},
                    {
                        "name": "O",
                        "gender": "male",
                        "children": [],
                    },
                ],
            },
        ],
    }
    
  • kazus Avatar

    It's been so hard for 6kyu =)

  • ahmet_popaj Avatar

    Great kata to learn dynamic programming, especially to exercise recursion with.

  • natan Avatar

    python version has code in preloaded for no reason

  • natan Avatar

    (python)

    These two solutions, both of which pass:

    https://www.codewars.com/kata/reviews/5a15fed357f0af5e19001946/groups/6146095c0d73b6000140e7d0 https://www.codewars.com/kata/reviews/5a15fed357f0af5e19001946/groups/6145f501427c9d0001d75559

    produce different answers for this pretty basic input:

    eighth_daughter_has_a_ssoss = {
        "name": "A",
        "gender": "male",
        "children": [
            {"name": "a", "gender": "female", "children": []},
            {"name": "b", "gender": "female", "children": []},
            {"name": "c", "gender": "female", "children": []},
            {"name": "d", "gender": "female", "children": []},
            {"name": "e", "gender": "female", "children": []},
            {"name": "f", "gender": "female", "children": []},
            {"name": "g", "gender": "female", "children": []},
            {
                "name": "h",
                "gender": "female",
                "children": [
                    {"name": "B", "gender": "male", "children": []},
                    {"name": "C", "gender": "male", "children": []},
                    {"name": "D", "gender": "male", "children": []},
                    {"name": "E", "gender": "male", "children": []},
                    {"name": "F", "gender": "male", "children": []},
                    {"name": "G", "gender": "male", "children": []},
                    {
                        "name": "H",
                        "gender": "male",
                        "children": [
                            {"name": "I", "gender": "male", "children": []},
                            {"name": "J", "gender": "male", "children": []},
                            {"name": "K", "gender": "male", "children": []},
                            {"name": "L", "gender": "male", "children": []},
                            {"name": "M", "gender": "male", "children": []},
                            {"name": "N", "gender": "male", "children": []},
                            {"name": "O", "gender": "male", "children": []},
                        ],
                    },
                ],
            },
        ],
    }
    
    find_seventh_sons_of_seventh_sons(json.dumps(eighth_daughter_has_a_ssoss))
    
  • user8751232 Avatar

    It would be extremely useful to have sample tests which cover more than just base cases, because debugging random tests is a pain in the ass.

  • widelec9 Avatar

    I keep failing the test cases where, after adding two sons to the set, the lastly added son has no more children. It seems I am missing 12 more sons in the result. Where am I wrong in understanding the task?

  • VLAZ Avatar

    This comment has been hidden.

  • pmarshall1993 Avatar

    This comment has been hidden.

  • Blind4Basics Avatar

    Hi,

    In pyhton: I'm passing the fixed tests, but failing at the random tests. The big problem is that I currently cannot print anything to the console (I bet the input is too long?) in order to debug my code and understand what I missed.

    1. with print statment: Network Error This error was caused due to an issue processing the web request, not because of an issue executing your code. You can retry the request.
    2. wihtout: {'Lord Crewe'} should equal {'Ronald', 'Borin', 'Destrian', 'Carac', 'Tristan', 'Merek', 'Doran', 'Sir John Fenwick of Wallington', 'Janshai', 'Fendrel', 'Lord Cornwallis', 'Rulf', 'Lord Crewe'}

    I bet that it's a problem of depth of the tree... So you should add at least one fixed test of depth 3 or 4, s that it will be possible to debug more easily.

    EDIT: It was interesting either way. :) But you really have to has some fixed tests. Spoiler below with what my code was lacking.

  • Voile Avatar

    Approved

  • siebenschlaefer Avatar

    JavaScript and Coffeescript translations kumited. Have fun!

  • siebenschlaefer Avatar

    From the description it's unclear if the seventh son may have sisters who are older than all of the brothers (['female', 'male', 'male', 'male', 'male', 'male', 'male', 'male (seventh son?)']). You could also add a test where a seventh son has a younger sister (['male', 'male', 'male', 'male', 'male', 'male', 'male (seventh son)', 'female']).