4 kyu

Area of House from Path of Mouse

92 of 140docgunthrop
Description
Loading description...
Strings
Puzzles
Algorithms
  • Please sign in or sign up to leave a comment.
  • agavagav Avatar

    Calculating the area was the "easy" part, compared to covering all the invalid path scenarios, especially properly handling the mousehole.

  • dfhwze Avatar

    In the test example:

    mousePath('4R2L1R5R9R4R4L3') // 49
    

    Looking at the picture, there is no consistency in moving forward. It appears, sometimes making a turn counts as moving forward, and sometimes not. What is this format?

  • Vulpes_Inculta Avatar

    When trying to run a full test suite I keep getting "DeprecationWarning: Sampling from a set deprecated". I'm not even using any sets in my solution, only lists and a dictionary.

  • Vulpes_Inculta Avatar

    I find it near impossible to check for invalid paths of the "C" type. One thing i tried to do is to document the coordinates of EVERY point I visit (not just corners), but it takes a while to process. Also, it looks like this website intentionally slows things down. Even the bruteforce solution runs pretty fast on my system, but here it times out after just 1 test.

  • Blind4Basics Avatar

    Hi again,

    Would be cool to have this in the fixed tests (both in test cases and sample tests): "2R4R4R4R2". There are no fixed tests for now that checks that a mouse hole on a straight line of a valid path is considered invalid.

    Cheers

    EDIT: btw, why this restriction??

  • Blind4Basics Avatar

    Hi doc,

    I just stumbled on this, in python:

    Traceback (most recent call last):
      File "main.py", line 502, in <module>
        run_full_test() or test.fail('Please revise your code and try again.')
      File "main.py", line 467, in run_full_test
        rng_tests1 = tuple(path2str(v2 if RR(12) else disjointv2(v2)) if RR(8) else path2str(taint(v2)) for v2 in (points2path(rng_start_pt(v)) for v in rng_tests1))
      File "main.py", line 467, in <genexpr>
        rng_tests1 = tuple(path2str(v2 if RR(12) else disjointv2(v2)) if RR(8) else path2str(taint(v2)) for v2 in (points2path(rng_start_pt(v)) for v in rng_tests1))
      File "main.py", line 467, in <genexpr>
        rng_tests1 = tuple(path2str(v2 if RR(12) else disjointv2(v2)) if RR(8) else path2str(taint(v2)) for v2 in (points2path(rng_start_pt(v)) for v in rng_tests1))
      File "main.py", line 209, in points2path
        raise Exception('Move is not a left/right turn')
    Exception: Move is not a left/right turn
    

    Seems like your generator is failing in some situations?

    EDIT: it happens that the random tests go into an infinite loop too, from time to time (or at least, they cause a time out)

  • atirage Avatar

    This is quite a nice Kata, capable of surprising you just when you think you've nailed it. :) Congrats to the author!

  • landaudiogo Avatar

    I am having a problem runnning my result... The execution runs out, and I think it's because of the exmaple_test('1000000R1000000R1000000R1000000',1000000000000) Anything yoiu suggest I do? I am aware my algorithm isn't optimized, but it was calculating everything perfectly

  • Nton Avatar

    Hey, guys and especially the author, case 2R4R4R4R2 - is normal case, so please review it , so it must be 16, but test says - null.

  • fedeberge Avatar

    Ash Tree Lane, poor mouse

  • Alexdenova Avatar

    pretty hard kata for 4kyu isn't it or I am just a noob?

  • danielsedoff Avatar

    Thank you for this tough problem. I've been stuck with it for some time, and it's interesting to tackle this. At last I've done it. It's been the trickiest one so far.

  • MastaB Avatar

    This comment has been hidden.

  • MastaB Avatar

    Issue: 500 Turns?

    First off, a real fun challenge. Good Job. I'm new to codewars so still a noob.

    Description says "K's path will always consist of fewer than 500 turns"

    I failed a test with a token list of 2179, so over 1000 turns, but it wanted a length not None.

    Am I missing something?

  • Blind4Basics Avatar

    @doc: you have PMsssss on the gitter channel. Plz check! ;)

  • docgunthrop Avatar

    Update to random tests: there will be a few more random invalid tests provided. And thanks to folks for your helpful comments 👍

  • monadius Avatar

    Approved

  • monadius Avatar

    This solution is incorrect but it passes all tests without any problems. It does not check if the path is closed if the number of path segments is even (e.g., 10L10). Please add tests to invalidate this solution.

  • ZED.CWT Avatar

    the path doesn't complete the loop back to the mousehole

    No fixed tests related

    the mousehole is located along the straight path of a wall (K's mousehole must be located at a convex/concave corner position to be valid)

    You may consider add cases like 2R4R4R4R2, where the reference solution will fail

  • siebenschlaefer Avatar

    A nice challenge and a very nice description! Kudos, @docgunthrop

  • user8436785 Avatar

    Looks like you got another hard one :smiley:

  • ZED.CWT Avatar

    What's the difination of overlap? Like, are these valid? _ _

  • docgunthrop Avatar

    JavaScript translation to come.