Ad
  • Custom User Avatar

    This took me 3 days. I had to get a better understanding of O(n) and prime calculations. I was on the right path on my first attempt by reducing the number of calculations in half, but I found out you can reduce the number of calculations exponentially, and that got me a working solution.

  • Custom User Avatar

    FYI - I have modified the description:

    • FROM

    At night the only "safe" chickens are in their cages...

    • TO

    At night the only guaranteed "safe" chickens are in their cages...

  • Custom User Avatar

    So why list rules at all?

    And I think you can figure out what the expecteds that I listed are showing. You're a smart guy.

  • Custom User Avatar

    The real problem is: what makes you think that these rules are not applied? Because you didn't see them in the example tests?? These represent at most 2% of the full batch of tests. Don't worry, DM is thurough with his tests.

    Moreover, your point is not understandable because you give only the expected part. But the expected result of what?

  • Custom User Avatar

    Well, I tried. Guess you got it all figured out.

    Also, holy verbosity!!

  • Custom User Avatar

    You have imagined problems that just don't exist:

    If Fox(es) are only in cages then Chicken(s) outside of cages are safe

    Cages are cages. Why would you imagine foxes can break out of a cage they cannot not break into?

    If no Fox(es) are present then all Chicken(s) are safe

    This Kata only has foxes and chickens! What else do you imagine the chickens are in danger from?

  • Custom User Avatar

    Seesm these two following rules were just left out:

    • If Fox(es) are only in cages then Chicken(s) outside of cages are safe
    • If no Fox(es) are present then all Chicken(s) are safe

    Examples:

    • Expected: '.C.[.............F...]'
    • Expected: '.C..[C.]..C....[C]..[C..]'
    • Expected: '...C...[C.CC.C....].C.CC'
    • Expected: 'C...CCCC[..............F............]CC.C[.].C..'

    Seems odd you would just leave these very pertinent rules out.

  • Custom User Avatar

    Agreed. Mostly gibberish.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Yep, that worked. Thank you.

  • Custom User Avatar

    There should be a test that checks whether the last character is a newline, in order to prevent presentational issues. For example test.assertEquals("1\n1*2\n", "1\n1*2") will fail, but it won't show any meaningful result:

    Expected: 1
    1*2, instead got: 1
    1*2
    

    A simple check that var ans = pattern(n); ans[ans.length - 1] isn't \n would help. Alternatively, add something in the description. (Note: the pending Haskell translation modifies the description slightly to include that hint)

  • Custom User Avatar

    You probably have a trailing newline.

  • Custom User Avatar

    You have a trailing newline. Look at the last character in your string, and at the last character in the expected values in the example tests.

  • Custom User Avatar

    How do you explain this?

    Expected: 1
    12
    1**3, instead got: 1
    1
    2
    13
    Expected: 1
    1*2
    1
    3
    14
    1
    5
    16
    1
    7, instead got: 1
    12
    13
    1
    4
    15
    16
    1
    7
    Expected: 1
    1
    2
    13
    1
    4
    1
    5
    16
    1
    7
    1
    8
    19
    1
    10
    1
    11
    112
    1
    13
    1
    14
    115
    1
    16
    1
    17
    118
    1
    19
    1
    20, instead got: 1
    1
    2
    13
    1
    4
    1
    5
    16
    1
    7
    1
    8
    19
    1
    10
    1
    11
    112
    1
    13
    1
    14
    115
    1
    16
    1
    17
    118
    1
    19
    1
    *********20