Problem Statement
There is a factory.
The floor of the factory is a rectangle divided into unit squares.
Some unit squares are walls, others are empty.
You are given the plan of the factory: a
There are two robots in the factory: robot A and robot B. Their current locations are denoted 'A' and 'B' in the plan.
Both robots move synchronously at one step per second. In each step the robot must move from its current square to one of the squares that share a side with its current square. The robots cannot leave the factory, they cannot move to a wall, they cannot both move to the same square, and they also cannot trade spaces.
Robot A wants to reach location marked 'a' in the plan, and robot B wants to reach location marked 'b' at the same time. (The starting locations of both robots and their destinations also count as empty squares. The robots may enter them arbitrarily many times.)
Compute and return the minimum time in which both robots can reach their desired destinations at the same time. If that is impossible, return -1 instead.
Definition
- Class:
- TwoRobots
- Method:
- move
- Parameters:
- String[]
- Returns:
- int
- Method signature:
- int move(String[] plan)
- (be sure your method is public)
Constraints
- plan will contain between 1 and 40 elements, inclusive.
- Each element of plan will contain between 1 and 40 characters, inclusive.
- Each element of plan will contain the same number of characters.
- plan will contain exactly one 'A', exactly one 'B', exactly one 'a', and exactly one 'b'.
- Each other character in plan will be either '#' or '.'.
Examples
{"Ab.a", "...B"}
Returns: 3
Robot A will make three steps right while robot B will step left, left, and up.
{"#a#", "A.b", "#B#"}
Returns: -1
The two robots are unable to take the very first step: each of them has to go into the middle, but they cannot both go to the same square.
{"#b#", "A.a", "#B#", "#.#"}
Returns: -1
Still no solution. Now robot B can start by going down, but there is no way to reach the two destination cells at the same time: one second before that happens they would both need to be in the same empty square.
{"...", "#a#", "A.b", "#B#", "#.#"}
Returns: 4
A can go right, up, up, down while B goes down, up, up, right.
{"AB......ab"}
Returns: 8
Both robots simply go right. Note that one robot may enter a cell the other robot left during the same second.
{"bA......Ba"}
Returns: -1
The robots cannot swap spaces, so on this map they can never reach their goals.
{"bA.......Ba"}
Returns: -1
This example is one square longer than the previous one. Again, robot A cannot move past robot B. On this map, this would involve both of them stepping onto the same square at some moment.
{"AB.........", "...........", "...........", "........b.a"}
Returns: -1
Plenty of room for maneuvers, but it's still impossible for the robots to reach 'a' and 'b' at the same time.
{"...A...", ".#####.", ".#####b", "B#####.", ".#####.", ".#####.", "..a...."}
Returns: 13
The two robots must essentially go around the walls in the same direction. (If each robot selfishly tries to follow the shortest path to their destination, they will collide in the top left corner.)
{"baA.B...................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................"}
Returns: -1
{"baAB....................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", "...#####################################"}
Returns: 1631
{"ba#AB...................................", "##......................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................"}
Returns: -1
{"baA.....................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", "B..#####################################"}
Returns: 1631
{"baA.....................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".#######################################", "........................................", "#######################################.", "........................................", ".B.#####################################"}
Returns: -1
{"A","a","#","b","B"}
Returns: 1
{"A","b","#","a","B"}
Returns: -1
{"A","b",".","a","B"}
Returns: -1
{"..", "ab", "BA", ".."}
Returns: 2
{".Ba.", "#bA."}
Returns: 1
{"b###.", "a...#", "BA#.#"}
Returns: 2
{"a.", "..", ".A", "Bb"}
Returns: 3
{"...#a", "b.BA."}
Returns: 2
{"..Bb.", "a..A#"}
Returns: 3
{"..", "b#", "A.", "aB"}
Returns: 3
{"..B...", "a#bA.#"}
Returns: 5
{"###.", "ba#.", ".##.", ".#..", "B##A", "...."}
Returns: 17
{"....", "..aA", "..bB"}
Returns: 1
{".#...", ".ABa#", ".b#.#", "....."}
Returns: 4
{"....", "...A", "....", "..a.", "b...", "B..."}
Returns: 3
{"AB", "..", "a.", "b."}
Returns: 4
{"A.B", "b#a"}
Returns: -1
{"...B", ".baA"}
Returns: 3
{"b...", "..Aa", "#B..", "....", "....", "...."}
Returns: 3
{"....#", ".....", "A.B#.", ".#...", ".b.a."}
Returns: 5
{".....", "b.a..", "..A..", ".....", "B...."}
Returns: 3
{".b.", "..a", "B.A"}
Returns: 3
{"...", "a..", "#..", "..A", "...", "B.b"}
Returns: 4
{"....#..", ".#..B..", "..#...a", ".Ab..#."}
Returns: 6
{"#.#.#.a", "A...#..", "...bB..", ".......", "#..##.."}
Returns: 9
{"..#.#", ".b.B.", "#.A..", "....#", "....#", ".a...", "....."}
Returns: 4
{".B..a", "#b...", "#A..."}
Returns: 5
{"....", "....", ".#.a", "..B.", "#bA."}
Returns: -1
{"..a.", "..b.", "AB.#"}
Returns: 4
{".#b..", ".....", ".B.aA"}
Returns: 3
{"...b#.", "...#.#", "#.A#..", "B.#..a", "#....#", "...#..", "#....."}
Returns: 8
{".bA.", ".Ba.", "...."}
Returns: 1
{"b.....", "A#....", "#####.", "#B.#a.", "..##..", "..#.#."}
Returns: -1
{"...#a..", "...#b#.", "#AB....", "#......"}
Returns: 5
{".....B", ".A....", ".#.#a#", "#.....", "#b#.#.", "...#.."}
Returns: 8
{"...", "...", "..a", "..b", ".A.", "...", "#.B"}
Returns: 3
{".....", "...B.", ".....", ".#...", "....#", "a..Ab", "...#."}
Returns: 5
{"....", "aA..", "..B.", "....", "....", "b..."}
Returns: 5
{".#..", ".#bB", "#A..", ".a.."}
Returns: 1
{"#..", "aB.", "#Ab"}
Returns: 2
{"..A.#..", ".......", ".....#.", "....a..", "#.B#...", ".......", ".#...b."}
Returns: 5
{"a.B", "A..", ".b."}
Returns: 3
{"Aa.b.#", ".#.#.B", "......", "......", "#.....", "#.....", "##..##"}
Returns: 3
{".b..", "....", "....", "....", "...a", ".A.B"}
Returns: 7
{"...", ".a.", "...", "B..", "...", "bA.", "..."}
Returns: 4
{".bB", ".A.", "...", "a#."}
Returns: 3
{"...", "B..", "a..", "...", ".A.", ".b."}
Returns: 5
{"#..", "..b", "B..", ".aA", "#.."}
Returns: 3
{"...", "...", ".#.", "..a", "B#b", "A#."}
Returns: 4
{"...", "A..", ".b.", ".B.", "..a"}
Returns: 5
{"..#..B", "....#.", "..A...", ".b.#..", ".....a"}
Returns: 7
{".b.", ".B.", "...", "..A", "#..", ".#.", "..a"}
Returns: 3
{".B....", "......", "#..b..", "#....a", "..##..", ".....A"}
Returns: 4
{"..................#.......A...#.......", "...................#.#.#..............", ".........#......#......#..............", ".....#................................", ".....#................................", "..##....#.#..........#................", "...................#....##..#.........", ".............................#.#......", "...........................#..........", "..........#........#..............#...", "...#........#....#....................", ".#.........................#.....##...", "........#............................#", ".......#....#.........................", "...#...........#....##................", ".............#.#......................", "..................#..........#........", "#.#.......#.....#..#.................#", ".....................a................", "...............#..#.......#.#.#....#..", "............#.....................##..", "..................#..........#........", "........##....#.......................", "....#....#....................#.......", ".....#....#....................##.....", ".....#........##......................", ".........#...#........................", ".....#...#..................#.........", "#.#.........#..#.........#............", "......................................", "......#.........#....#................", "...#B......#..........................", ".......#.........#....................", "..........#b.....#....................", ".......#........................#....."}
Returns: 23
{"............##......#", "A#..#................", "...................#.", ".........#...#....B..", ".#...#......#.....a..", "..##....#.....#......", ".......#...#.........", ".....................", "..#...............#.#", "............#........", "..#..................", "...............b.....", "..#.......##......#..", "....#.......#..#..#.."}
Returns: 21
{"...........#....#....................", "#......b.............................", "........................#............", ".....................................", ".....#.#....................#........", "............#......................#.", ".......#.............................", ".......#.............#...............", "....................#...#...#.....#..", "........#.................#...#......", "......................#...#..........", ".........#....#..##...#.#..B.........", ".........#.......................#...", ".....#...............................", "..................................#..", "............#......#.................", ".....##...#................#.........", "...........................#.........", ".......#........#....................", "......#..................#..#........", ".............##..#.................#.", "...........#...#.....................", ".......#.....#.......................", ".........#...........................", "............a....................#...", "..#..#...............................", "...#.......................#...#.....", "....#..................#...........#.", ".#...................A...............", "...........................#.........", "..................#....#..#..........", "..........#......#..#.#..............", "#.....#.....#...............#........", "........#............................", "#.................#......#...........", "..#.....#...........#.....##.......#.", ".#........#...................#......", ".................#...................", ".........................#...........", ".#.................#................."}
Returns: -1
{".......#.............#.......", ".............................", ".#.............A...#a........", "#............................", "......#.........#.....#...#..", ".............................", ".............#......##.......", ".............................", "............#....#...........", ".........#...#......#........", "................#........#...", ".....................#.......", ".................#...........", "..................#.....#....", "............................#", ".#..........................#", ".................b......B....", ".#.......##...#.#............", "..................#.........#"}
Returns: 7
{"#.#.##.....##....", "...#..#.#.#......", "....#..#..#.....#", "#.....#..........", "....#....###.....", "...#.....B.#.....", ".#.....#...#...#.", "....#.......###..", ".#.......#..#.#..", "...##..#.....##.#", "####..a..........", "#........#.....##", "#...#..........#.", "..#.#..#....#.#.#", "....#.b#.....###.", "..#.....#..#.....", "......#....#...#A", "...#.............", ".......#.....#...", "...#..#....##.#..", "........#..#....#", "...#.#....#.#....", "...#.............", "#....#.#...#....#", "#.#.....#......##", ".#.......#.#....#", "............#....", "..#.#.##....#....", "#..#.#........#.#", "..........##....#", "....#.......#....", "....##...##.....#", "...#.#...##..#.#.", "##......#.#..#.#.", ".....#.....#.....", "##..........##...", "........#......#."}
Returns: 16
{".....#........##....#......b.A.........", "...##..a.......B....#.#..#...#.......#."}
Returns: -1
{".......................", "...........#..........#", "...........#.....a.....", "......#.......#....#...", ".......................", "#....#...........#...#.", "...................#...", ".....#.................", ".......................", ".A.....................", "............b..........", ".............#.......#.", ".......................", ".......................", ".......................", "..................#.#..", ".#.....................", "...#...................", ".......#.....#.....B..#", "...................#...", ".................#....."}
Returns: 23
{"........#.#..#..#...b..", "..........#.##.#..##...", "....#.....####....#####", ".....#.......#.#......#", "..#..#.#####..##.#..##.", "#...#.#.##......#....#.", ".....#.#........##....#", "##.#....#......##...a..", "..#.#...A.#.#..#..#...#", "..#...#.....##.........", ".##...#...#......#.....", ".#.....##......#...#...", "#........B###..#...#...", "........##.#........#.."}
Returns: 25
{".....#..#...........#.....#..#......#", "....#.#.#...##..###........#.........", "#...##.#...##.............#.......##.", "##.....#..#.#.#...#......#..#..#...#.", "...#.....#..#.##.#......#..#..#.#...a", ".##..###..#.##..#.........#......#.##", ".#.#......#..#.##.#.....#...#.#..#...", "#.#...#..##.#...#..#....b....#..#...#", "#.#.##....#.......#..##.....#.#..#..#", "..#.............#...##......#........", ".#....#...#.##...##.B.#....#.#...####", ".........#.......#....#.#........#A..", "#.###....##..#.#....###..#.###......#", ".#.......#.#...#....#...#........#...", "#..#..#..##...##.#.####....####.##...", "..#...#....##.#.#...#.###..##.#.##...", "#..#......#..#...#..####.......#..#.#", "..#.#.....#....#..#..#.......#...##..", "....###...##...##....#....#......#...", ".#....##...#.##.#....#.#.#.#.........", "......#...##..#......#..#.....#.##..#", "#.#.#.#....#.....#....#...##.........", "#......#....#..##......#..##.......#."}
Returns: 15
{"...#....###...", "..#..#.....#..", "........#...#.", "#.............", ".#.###....#.#.", "....##...#.#..", "..........##.#", ".##...#..#.#..", "....#.#.##...#", ".......#..#...", "....##.......A", "##...#.#..#.#.", "#.....#.....#b", "......#.#....#", "#..##.....#..#", ".##......##.##", ".#......##...#", "............a.", "....#.###.#...", "...##...###...", "...##......#.B", "..#..#.#....#.", "..#..#......#.", "#..#..#..#..#.", ".#.......#....", ".........##...", "..#.#..##..#.."}
Returns: 16
{"................................", "................................", "................................", "................................", "................................", "................................", "...........a....................", "................................", "................................", "................................", "....................b...........", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "................................", "......................A.........", "................................", "................................", "................................", "................................", ".B..............................", "................................", "................................", "................................"}
Returns: -1
{"##.#a....b", "....AB....", "......#..."}
Returns: 5
{"...#....................#....#...#......", ".#...#...........#...............##....#", "............#..#.#.....#....#..#...#..##", "..#.#.##.......#.........#..#..#.....#..", ".#....#.##.###.......#.###.#..##..#...#.", "#.......#....#...............#.#.....###", "#........#.#....#.#.a.#....#..#.#.b.....", "#.#......##.#.#.#..#............#....#.#", "#........#...#...........###..#..#.#.#..", "...#.#.........#..####.##..........#....", ".###......#........##.##..A....#..##...#", "##..#......#...##.#.........##..#.#..#.#", "B....#..#.....#...#.......#....#.#..##..", "..#..#..........#...............#.##.#..", "#........#........#....###...#..#......#", "....#......#.#..#.##..#...#.#.#.###..#.#"}
Returns: 46
{"...###....#.....#..##...#.######.", "#.#.#.#.....#.##...#.....#...#...", "...#b..#............#....###....#", "...#.#........#....#....##.......", "..#...#..#.#.#.#....#..##......#.", ".....#....##.#...#....#.A.#......", "...#..........#..........#......#", ".##......#.#...#..#.......#.##...", "#..#......#.............#..B....#", ".......#...###.#..##......#.....#", "......#......#..###..#........#.#", ".....#.#...#.....#....#..##......", "...##..#a..#....#.#.#.##..#....#.", "#.......#.#....#...#....###..##..", "....###.............###.#.#....#."}
Returns: 31
{"a..##...", "#...##.#", "B#..b...", "..##....", "...###..", "#A#.....", ".##.#.##", "##......", "...#....", ".#..##.#", "....#...", "...#....", "#......#", "...##...", "..#.#..#", ".....#.#", "......#."}
Returns: -1
{"...#..##.#", "...#...#B.", "##.#......", "....##....", "#...#.#.##", "....b.....", "..####....", "......#...", "#..##...#.", ".....#....", ".#........", "......#...", "...#....##", "..........", "..#...#...", "..#.##.##.", ".....##..#", "##...#....", "##....#...", "###...#.##", "#........#", "......#.#.", "..A.#.....", "..#...#.#.", ".#..#.....", "...#......", ".#........", ".###..#...", "........a.", ".........#", ".#...#..#.", ".....##...", ".........#"}
Returns: 12
{"..........#..", "......#.....B", "............b", "......##...##", ".........A#..", ".............", "............a"}
Returns: 5
{"............##..#....##..........#", "........#....................#...#", "...#.............#..#........#....", "................#...#.........#...", ".....#...............#......#...#.", "..#..###..#....#......#...##......", "..............#....#..............", ".......#........................#.", ".....#................#.........#.", "..#...#...........................", "...................#..#....a......", "..................................", "....#..#.......##.......#.....#...", "...#....#.........................", "##.......#....#.........#.....#...", ".............#............#.#A....", ".......#..............#....##....#", "..#............#..................", "........#..................#......", "......#.#...............#....#.#..", "..............#.#..#......#b...#..", "............#............#...#....", ".......#...........#......#.......", "...#...#.............#...##.......", ".....#...#.#...#......#..#........", "................#............#....", "..#.......#.....#..........#......", "...#....#..#......................", "..............##....#........##...", "......#.#.........#....#.#.#..#..#", "#.#.........#.............#.......", "....#......#...#....#............#", "...#............#..#........#...##", ".............##............#......", "..#......#.....#............#.....", "......B...........................", "#................#.#..............", "...............#.......#.........#", "............................#.#.#.", ".....#...............#............"}
Returns: -1
{"..#....", ".b.....", ".......", ".......", "...a...", ".......", "#......", ".......", ".....B.", "#......", ".......", ".......", ".......", ".......", ".......", ".......", "A......", ".......", ".#.....", ".......", ".......", "..#..#.", ".......", "...#...", ".......", "......."}
Returns: 15
{"....................................#.", "...............................B......", "......................................", ".........b.....................#......", "........A..........................a.."}
Returns: -1
{"......A.........#...##........", "......#......#...#...#...#..#.", "........#......#..##..#.....#.", "..#...#....#...............#..", "...#.....................#....", "#.##.....#.#...#..#.....#.....", "......#....#.....#...........#", "#....#............#B..a....#..", "......#..#...#........#.......", ".#.#.#.....#...##...#..#......", "...##.......#....#...###.#....", ".#..............#.............", ".......b......#........#.#....", ".............#...#.#.......#..", ".............#.......#..#....#", "..#........#..#.....#....#....", "...#.................#...#....", "......#.....#.#...........#..#"}
Returns: 23
{"#.......................", "........................", "........................", "................b.......", "...#.#.....#............", "........................", "................#.......", "........................", "........................", ".....#.................a", ".........#......#..B....", "....#...................", ".#......................", ".....................#..", "........................", "........#...........#...", "#..............#.....#..", ".#......................", "......#.........#.......", "........................", "........................", "....#...................", ".....#..............#...", "........................", "........................", "........................", ".......................#", "........................", "...........#............", "...........A..#........#", "...................#....", ".......................#", "..................#.....", "........................", ".........#..............", "........................", "........................", "........................", "................##......"}
Returns: 32
{".#..#......#..#.#.......#...##.", "....#...##.#...##..##.....A..#.", "a.#..#...#....#.#..#...##.....#", "...#...###.#.#.#..#..#.....##.#", "...#....##...#....#.#.#.....###", "..##..#.......##..#..#...#.#..#", "..#...#..#...##...............#", "...#..##...#....#......###..###", "..#...........bB......#.#...#..", "#...###....#.....#.#...#.#....#", "#...#....#...#...#..#.........."}
Returns: 39
{".#.##...#....#", ".....#........", "......##..##..", "#...#.#....#..", "...#..#.#...A.", "......#...#...", ".#...........#", "..#.........#.", "#.....#...#...", "...#.#.##.#...", "...........#..", "..a...........", "..#.##....##..", "..#..##.#...#.", "#............#", "..##.......##.", ".##.B..##..#..", "..#......#...#", "...###..##....", "........##....", "......#....##.", "#........#....", "#.#........##.", ".#...#.##.....", "....##..#.#.#.", ".....#...#....", "........#.#.#.", ".##.b#..#.##..", "..#....#...#..", ".......#..#.#."}
Returns: 17
{"...........", "....##.....", "#.#..#....#", ".##..A.#...", "...#.....#.", ".......#...", "#.#........", ".#........#", ".#.#..#....", "...#..##...", ".........#.", "#......#...", ".#...b.....", ".......#...", "..#........", "..#........", "####.......", "....##.#..#", "#...#......", ".#...#.##..", "......##...", ".#...#.#...", "..#..#..##.", ".....#.####", "..#.#......", "...#..#.a..", ".##........", "........##.", "..........#", ".#..#...#..", ".##....#...", "#.......#..", "....##.....", ".#.#....#B.", "....#.#...."}
Returns: -1
{"...#......A...#...#................", "..........#....#..#................", "..B..................b.............", "...............#......#.........##.", "......#............................", "......a......#.........##...#......", "....#..#.......................#...", ".#........#........#...##.........."}
Returns: 19
{"....#.....#", "...##.#.#..", "........#..", "...#....#..", ".....#....#", ".#.........", "#..#B....#.", ".##..#.....", ".......#..#", "...#....#..", "...#.......", "..a..b..#..", "......#....", "...........", "..#..#....A", "#..........", "...........", "#..........", "...........", "......#....", "........#.."}
Returns: -1
{".####..........", "##..#.....##...", "...###.#....#..", ".......a....#.#", ".#.#.....###...", ".#..b...#.#...#", ".......#.......", "#..B..##.......", "...#.#.#.#....#", "#......#.......", ".........#..#..", ".....#..#....#.", "....#.#..##.#..", "...............", ".#...##.#......", "##....#.....#..", ".....###.......", "........#.A..#."}
Returns: 23
{".........#..#..#............", ".#.#........................", "...................##.......", ".....#..#....#.##.........##", "...#.........#.#.##.....#...", "........#..............#...#", ".....#...........#..........", "...........##..#............", "....##.............###......", "...#.............#.........#", "#.#..#.........#...##.......", "..............#......#..#.#.", ".....#..#..b...##...........", "...............#...##.......", "..#...............#.........", "............#.......#.......", "............#...#...........", "#.#....#.......###..#.##....", "..............##.....#....#.", "...........#.......#.A......", ".....B.........#...#........", "........#.........#.#..#....", "...##.....#......#.#..#.....", "............#.....#.......#.", "....#.......................", ".#.........#.......##.....#.", ".....#.....................#", ".........#.......#.......#..", ".....##....................#", "...........#........#....#..", "..#...#..#..................", ".......#...a...#.....#......", ".....#.....#................", "..#........#.#....#.#....#.."}
Returns: 22
{"........#..#", "#....#..ba..", ".#.AB.##...."}
Returns: 9
{"#...#...a..#.", "#.....A#.....", "#...##B......", "....b...#....", ".........##.#"}
Returns: 3
{"........................B.............", "..................................A...", "......................................", ".a..b................................."}
Returns: 35
{"a#.#..#......", "..#####......", "#.#.#....###.", "......#......", "...#.#.......", "...#.B..#....", ".............", "...###..#....", "#..#.A....#..", "#............", "#........b#.#", "#.#........#.", "###.#.#..#.#.", "......#.....#", ".......#.#...", "..#..........", "#..#.#..#...#"}
Returns: 15
{".##.........A.#..#.B..###", "#.##...b.a...#..#......#.", "####.#.##........##......"}
Returns: -1
{".#..#....#..#......#..####.", ".##.#.....#..####.##.......", "............#.##......#....", ".......#.....#.........#.#.", ".#.#.....#..........B..#...", "...#.#.....#....#..........", "##.##............#.........", "#.....#.....#....###.#.....", "...........#.......###....#", "..........#.......##.......", "..#..#......#.........#...#", ".....#....#...##....###...#", "......#...#....#...........", ".......#............##..#..", "#..#.........#.#...#.......", ".#.#..#.#..#...............", ".........#..##...#...#.....", "#....#..................#..", ".#.....#....#.#.#.....##.#.", "......#..#........#..#...#.", ".....#.....#..#...#..#.#...", "..#......#......#..#.....#.", "..##..#...#...#b...#.##.#..", "...............#..#........", "...#......#............#...", "...........#..#............", "....#..........#.........##", "...#......#................", ".#.....#...##....#.....#...", ".....#...#.#.......##......", "#....##...............#....", "...#..#.a...........###.#..", "....#..##...#...#..........", ".#.#......#...#..A.#.......", ".#........##......#.#....#.", "...........................", "...##..#..#......#...#.....", "#......................#...", ".....#..##..#..###........."}
Returns: 25
{"....##.#.#..", ".#....##...#", ".......#.#..", ".......#.#..", "##........B.", "#...........", ".#..#...#...", "..##........", ".#..........", "..#...#.....", ".#.#...##...", ".......#...#", "............", "#..#........", "...#.#..#.#.", "#...........", "#.#.#...a#..", ".b.#....#...", "............", "...........#", "...........#", "..#.#.......", "##...##.....", "....#.......", "....#.......", "#.##........", "........#...", "............", "..#......#..", "...........#", "..A...#....#", "........##..", "...##.......", "....#..####.", ".....#......", "....#..#..#.", ".........#..", "............", ".....##.#...", ".........#.."}
Returns: 22
{"A..", "...", "#..", "...", "...", "...", "...", ".#.", "...", ".#.", ".ab", "...", ".#.", "B.."}
Returns: 13
{"....#............#.B...", "..#..##..........#.#...", ".........#.#.#....#...#", ".....#..#....#....#..#.", "#.......#.#...a.#..b..#", "##.............##......", ".#........#...#...#.#.A", "..##.#.........####.#..", ".#....#....#...#......."}
Returns: 12
{"#............#..", "........#.#.....", ".#.#.....#...##.", "................", "#.#............A", "#..............#", ".......#....#...", "..............#.", "##..........#.##", ".........#.....#", ".#.............#", ".......##....#..", "..##........#...", ".........#..#...", "....#......#...#", "....a.#.##......", "..............#.", "..............#.", "......B.........", ".....#..#..##...", "..#.#......#b..#", "#..#.#.........."}
Returns: 22
{".............#..B....", "......##...........#.", "..#........#.........", "......#......#.......", "..........#....#.....", ".......#...........#.", "............##.......", "#......#............#", "............#.##.....", "#..........##........", "...................#.", "...#..#.........#....", "...........#.......#.", "...#.#....#......#...", "b...#................", "......#.......#.##...", ".........#...........", "............#........", ".#..#.#....#.#....#..", ".....................", ".......A.............", "a..........#.......#.", "....#................", "...#.##..........#.#.", "..........#.......###", "...........#....#.#..", ".....................", "...............#.....", "...#..........##....."}
Returns: 30
{"..AB...................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".......................................", ".................................#.....", "...............#.......................", "..................#....................", ".....................#...............#.", "...............................#..b..a." }
Returns: 73
{"ab......................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "......................................BA" }
Returns: 78
{"........................................", ".A......................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "............................#...........", "...........................#a#..........", "..........##...............#.#..........", "..........#b...............#.#..........", "..........#.################.#..........", "..........#..................#..........", "..........##########.#########..........", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", ".......................................B", "........................................" }
Returns: 51
{"Ab.a", "...B" }
Returns: 3
{"A..a", "####", "Bb##", ".###" }
Returns: 3
{"AB......ab" }
Returns: 8
{"A.......................................", "b.......................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "......................................aB" }
Returns: 77