Your job is to write a program that finds the optimal number of moves it takes to get from the lower-left corner of a rectangle to the upper-right corner directly opposite.
Your program will accept input as an ordered pair (width, height)
. These will be the dimensions of the rectangle you will work with. Your program will create an ASCII-art of the solution (use .
for empty square and #
for part of the solution, X
for starting square) and count the number of moves it takes to reach the endpoint. Diagonal moves are not allowed. If there are multiple solutions, choose one to output.
The shortest program in bytes wins.
Example
Input: (4, 5)
Output:
..##
..#.
.##.
.#..
X#..
Move count: 7
#
in "the optimal solution" (which is any solution that never moves left or down) as well? \$\endgroup\$#
because it's illogical to go left or down. \$\endgroup\$