Ad
  • Custom User Avatar
  • Custom User Avatar

    Fun :-) Is there a part 2?

  • Custom User Avatar

    You are thinking as of [row][column] and the solution is [column][row]

  • Custom User Avatar

    For this kata, coordinates in the maze are 0-based. First coordinate is horizontal (x), increasing left to right, and the second one is vertical (y) increasing from top to bottom.
    Such coordinate system is somewhat "customary" and I believe that's why it's not explained in details, but I've seen remarks in the comments that it's not sufficiently clarified in the description.

  • Custom User Avatar

    I am still confused, here is how i look to this:

    Example 1:
         1 ##############      1 ############## 
         2 #        \   #      2 +--------\   # (2, 0)? or (1,0) if starts with 0
         3 *   \        #  =>  3 *---\    |   #
         4 #            #      4 #   |    |   #
         5 #   \    /   #      5 #   \----/   #
         6 ##############      6 ##############
           12345678901234 = 14 
    Example 2:
          1###*###      ###*### 
          2#/ /  #      #/-/  # 
          3#     #  =>  #|    #
          4#     #      #|    #
          5#\    #      #\----+ (5,7) or (4,6) if starts with 0
          6#######      #######
           1234567 = 7
    

    Am I misunderstanding something here?

  • Custom User Avatar

    You have to be careful when reading the mazes, because in C++, backslashes are escaped what makes them tricky to read. Without escaped characters, mazes look like this:

    Example 1:
          ##############       ##############
          #        \   #       +--------\   #
          *   \        #  =>   *---\    |   #
          #            #       #   |    |   #
          #   \    /   #       #   \----/   #
          ##############       ##############
    
    Example 2:
          ###*###      ###*### 
          #/ /  #      #/-/  #
          #     #  =>  #|    #
          #     #      #|    #
          #\    #      #\----+
          #######      #######
    

    I marked places where beam exits the maze with +, and they are located at (0,1) for the first maze, and (6,4) for the second maze.

  • Custom User Avatar

    How first answer of is equal to (0,1)? Isn't it (1,0)?

    Describe(exit_from_maze_tests) {
      It (passes_example) {
        Board m {
          "##############",
          "#        \\   #",
          "*   \\        #",
          "#            #",
          "#   \\    /   #",
          "##############"
        };
        Assert::That(exit_from_maze(m), Equals(Result({0, 1}, 22)));
      }
    

    The same second example: it should end on (5, 7)! how it is (6,4)?

     It (passes_second_tests) {
        Board m {
          "###*###",
          "#/ /  #",
          "#     #",
          "#     #",
          "#\\    #",
          "#######",
        };
        Assert::That(exit_from_maze(m), Equals(Result({6, 4}, 10)));
      }
    };
    

    I am totally confused, with how answers have gotten? Can you explain me, please!

  • Custom User Avatar

    Fixed C compiler warnings ;-)

  • Custom User Avatar
  • Custom User Avatar

    You're not serious...? See, you're typically unreasonnable, here.

  • Custom User Avatar

    That's not explaining anything. How am I supposed to interpret (0,1)? Is it position or direction? Against what on the board? And which one is which dimension?

  • Custom User Avatar

    it's in there:

    "##############",
    "o--------\   #",
    "*---\    |   #",
    "#   |    |   #",
    "#   \----/   #",
    "##############"
    

    o marks the exit point of the beam. Given the maze in the example, the solution would be a pair of position and distance: ( (0,1) , 22)

  • Custom User Avatar

    I don't see any mentions of the order of the position property: which one is the x direction and which one is the y direction?

  • Custom User Avatar
  • Custom User Avatar

    C++ version: Signature is C-style, which discourages use of modern C++, int ** is something you never ever should have to write in C++.
    Suggestion:

    std::array<std::array<int, 4>, 4> solve(const std::array<int, 16>& clues)

  • Loading more items...