Statistics

Problem Statement for "Doorknobs"

Problem Statement

Tim and Tom are playing a game called Super-Doorknobs. From a starting position inside Tim's house, they each have to try to be the first one to touch a given number of doorknobs in any order. Tom, being aware of his disadvantage of not knowing Tim's house, decides to code up a quick algorithm to tell him which doorknobs to go after.

Given the configuration of the house and the number of doorknobs they need to hit, return the length of the shortest path that includes touching the necessary number of doorknobs.

The house configuration will be a String[] birds-eye view. The game will start in the top-left corner. The following characters will represent the house:

'.' - empty square.

'o' - square with a doorknob (they touch the doorknob the moment they enter this square).

'#' - a wall that neither of them can run through.

For example, if Tim and Tom were racing to touch 3 doorknobs in the following house configuration (quotes added for clarity):

{".....",
 "o....",
 "o....",
 "o....",
 "...o."}

The shortest path is straight down, and has a total length of 3. Therefore the method would return 3.

Definition

Class:
Doorknobs
Method:
shortest
Parameters:
String[], int
Returns:
int
Method signature:
int shortest(String[] house, int doorknobs)
(be sure your method is public)

Notes

  • If there is no way to reach <doorknobs> doorknobs from the starting location at the top-left of the house, return -1.
  • Tim and Tom can only move up, down, left, or right. Diagonals are not allowed.

Constraints

  • house will contain between 5 and 50 elements, inclusive.
  • each element of house will be of length 5 to 50, inclusive.
  • each element of house will be the same length as every other element of house.
  • each element of house will contain only the characters '.', '#', and/or 'o'.
  • the first character of the first element of house (the top-left square) will be a '.'.
  • doorknobs will be between 1 and 4, inclusive.
  • the number of 'o' characters in house is between and 6, inclusive.

Examples

  1. {"....." ,"o...." ,"o...." ,"o...." ,"...o."}

    3

    Returns: 3

  2. {"....." ,"o...." ,"o...." ,"o...." ,"...o."}

    4

    Returns: 7

  3. {".#..." ,"#...." ,"...oo" ,"...oo" ,"...oo"}

    1

    Returns: -1

    Tim and Tom can't move from the starting location (what an odd house).

  4. {"...o." ,"o..o." ,"....." ,"..oo." ,"....."}

    4

    Returns: 7

  5. {"....#" ,".##o#" ,".##oo" ,"o##.#" ,"....#"}

    4

    Returns: 12

  6. {"....#" ,"o##o#" ,".##oo" ,".##.#" ,"....#"}

    4

    Returns: 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#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#..",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##.",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#..",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#..",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.##.",".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#oo","...#...#...#...#...#...#...#...#...#...#...#...#oo"}

    4

    Returns: 1298

  8. {".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"...................o.............................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"........................................o........." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"..........o......................................." ,".................................................." ,".................................................." ,".................................................." ,".....................................o............" ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................."}

    4

    Returns: 106

  9. {"..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","...................o..............................","..................................................","..................................................","..................................................","........................................#.........",".......................................#o#........","........................................#.........","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..........#.......................................",".........#o#......................................","..........#.......................................","..................................................",".....................................#............","....................................#o#...........",".....................................#............","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................","..................................................",".......................o.........................o"}

    4

    Returns: -1

  10. {".#.#.......#.#......................#..#..#.....",".#..#......##.............#.###......#..#..#..#.","#.......#...#...#....#..#.##...###....##.#......","....#....#.#......#..#....#..#......#....#......",".......#..#.#.#...............#..#...#..###....#","#...##.#...##...##.........#.......#........#...","........................#.##...#....##.........#","...##................##....#........#....##..#..","#...#.....#...............#....##.....#......#..","...#......#.#......#...#........##.#.....#......","#..#..#..#....###..........#..#...#..#....#.....","......#...#........#....#......#..#...#....##.#.","............#...#.....#...#...#........##....#..","....#...#.#.........#.#......#............#.....",".#.#....#....#.....#............#........#.#....","....#...#...##..........#.#..#..................",".#.....#.##.......#....#.......##.....#.....#...",".......#............#.............##....#.##.#..",".#..#........####.#..#.............##...o.#.##..",".##..........#..#..#....#..#..o....#........#...","......o..#......##..#.......#.....##.....#......"}

    3

    Returns: -1

  11. {".#....#......#...#.....#..#...##.....#..#","....##..#.....##.##.....##...#.#....#..##","#.......#..#....#....#..##.....#.........","...#..............#...o......##..##......",".....#..............#.........#.#.....#..","........#...............................#",".............#..##.....####....#......#..","....#.....#......#.........#.............",".......#.....#.#.................#......#","#.............#...##...........#....#...#","....#.#..#......#.......#..##............","#......#.....#...#.....#.#......###..#...","###..........o#..##....##......#..##.....","..............#......o..............#.#..","..###....................##.#.....#..#.#.","...#....#......#........#...###.........#","#....#.#...#.#.#..o..#.......#...........","...###..#.......#..............#....#....","#...#......#...........#.#......#.....#..","......#.##............#.....#.......#....","#..#....#...##.#......#.....##...#.......","...#...#.#..............##..###...#....#.",".#...##.....#.....###...#.#......#...#...","...........#.......#.#....#.....#....#.#.","#.......#.........#.#.#..#...#..#.#..#...","..............#.#.#.#..#.#......#........","#.......##...#..........##.....#...#.....","..#.....##....#..###..............#......",".....#...#......#...o........#.#.....##..","#......#.##...#...#.............#........","............#.....#......##...#.#......#.","..#..#..........................#.....#..","##.....##.#..#................#..#.....#.",".......#....#............#.#........#....","........#....##....#.......#.....#....#..","##.#....#....#.....#...#...#..#.....#....",".........#..#........#.#..#........#.#...","#..#.....#..#......#..#..............#...","...#...#...##....##..#.#.##.....#..#.##.."}

    4

    Returns: 51

  12. {"...................#..#.....#.",".#...........###.#..#.......##","..#...#.#..#.........o#..##...","........#...#....#..........#.","......#....#.........##.#..#..",".....#..#..#.......##.#....o..","..#........###.........#.#.#..","........#.#..#.....#......#...",".#.....#..##.....#......#....#","...#..#......#.#..#...........",".#...#.#...#....#...........#.","....###....#....#.........#...","##...............#...#....#..#","....#.#....#.#....#....#......","....#.............#.........#.","#.####....#.#........##....##.","...#......#..........#......##","#....#.........#........##..#.","#......##..#...##....###.....#","...##....#........#...........",".#..........##.........##.....",".................#....#.#.#..#","......#....#..#.o##...#.....##",".....###..#..#..#......#....##","..#..........................#",".##....#..............#.....#.",".......................#....#.","#.......#...#.....#.........##","..#..#..#......#...#..#.#....#","..#...##....##...##.##.##..##.","......#..o....#.........##...#","...#...##.....................",".....#..#.......#.....#....#.."}

    4

    Returns: 75

  13. {"...o........#...#......#.#......................#",".#..#.....#.#..#..#.#.#..............#....#.#....",".....#..#......#................................#",".#...#..#......#.......#......#............#.....","............#........#..#.....#.#...##.#.....#.#.",".....##.#....#..........#.......##......#........","......##...#.......#.##....#.#.#....#............","##..#...............##..#..#.#.........#....#..#.",".....#.............#.........#.........#.......#.",".......#.....#......###..#..............#..##....",".#...##.......#..#..#.............#.##..o..#.#...","....#.............#.....#......#..............#..","#.......#.............#.o##.#..#.#.#............#","............##..##..#.#..#.....#.....#....#.....#",".#....#...............#..........#...#.##.#......",".....#.#..#..#......#..#..#.....#........#...#...","..#.......#..#..#............##...#.........#....",".....#..#.......#..........##.....#....#.........","..........#.....#.#.o.......##.........###.......","..#......#........##.....#..###......###.#.....##","......#..#.#..............#....##...#..#.....#..."}

    2

    Returns: 36

  14. {".......",".......","...###.",".......","..##...",".......","..o#..#",".......","#......",".......",".......","#..o...","...#...",".......",".#o...#","...#.#.",".......","....o.#","..#..#.","##.....",".......","#...#..",".......",".##....","#...o#.","..#.#..","...#...",".##....","..#..o."}

    3

    Returns: 18

  15. {".#.............#....","..#....#............","#.......##.#......#.",".##.......#.......#.","..#.o##..#.#........",".....#...#..#....#.#",".........#...#......",".#.................#",".#.#........#.#....#","......##........#...",".........####.......",".#.......#....#....."}

    1

    Returns: 8

  16. {".........#.........#",".#......#....###....",".......#..........#.","..........#.........","#........#..........",".....#..#...#.##....",".#..................","#.....#...o........#","#..#.....#..#.#...#.","...#........#.##...#"}

    1

    Returns: 17

  17. {".#.....#...#..###.##..#.......#.###.#","...###........###....#.#.............","#..#.#.........#........#..........##",".#.#......##........#.#.#.#..#....#..","#..##o#..#..........#...###.....##...",".###....#....#.###.#.##...#.......##.","................o........##.#.....#..",".#..#..#..#.#...#.#.....#..#....#..#.",".....##.#..#.#.......#....#...#.###..","...#........#...#.......#...#.....#..","#..............#..........#...#..#.##","......##..........#....#..##...#...##",".......#..#......#....#..#....#......","#.....#..##............#...#....#....",".#...o..................#...##.......","....#....#..#.............#......#...",".#..#.....#..#....#..#..............#","........#..#.#....#..#..#.......#.#..",".......#.#..##.......##........##....","..#...#.#...#.......#...#..#....#....","..#.#.#..#.#.##..#.#.....#...#.....#.","#.#.....o....#....#.#....#.....#...#.","....#.#...........###.#.#..#....#....",".........#...........###....#....#.#."}

    2

    Returns: 26

  18. {".#..###............#.#.#...#........","..#......#....###........#..#...#...","#...#........#............#.........",".....#.##....o...#..........#...#.#.","...#.........#......#.......##.##...","....#.......#.#.#...#..#............",".#........o.........#..#.###.#...#..","..#.#...#...#....#.##.........#..##.","...........#...#.........#.....#..##","#.##....#....#.......#.....#.#.#..#.","...#.....o..............###.......#.","...#...#.......#..............#.#...","..#....#..#.#...##...#..#......#..#.",".....#.#.....#..#...#.#....#.#..##..","..............#...........##......#.",".........#...#......#.###.#..#.#...#","#.#..#...#....#.........#....#......","#..........#o...#...#.###...#...#...","....#..#...............#........#.#.","#.##.....#..#...........#.......#...",".#.......#.......#...###.....#......",".....#....#.........##......#o......","#.....##....#..###..##..##......#...","..#...#...#...........#.........#..#","...#.....#........#.#....#....#.....","....##.........#.....##........#.###","...#......##.#.#........#...#......#","##..#..........#.....#......#..#.#.#",".........#.#..#.#.#....##...##......",".......#...#..#...#......#..........",".................###....#...........",".....##.....##.#..##.#............#.","...#...#.....#...........#...#...#.#",".......#.#......#...#..#..#...#.....","...#....#.#......##.#.....#.#.#....."}

    4

    Returns: 39

  19. {"...#.........##....#.....","....#.....#..............","#.......####.......#.##..",".##.......#.#....#..#.#..","........#..#...#.##..o...",".........................","##....#...##..#...#......",".#........#........#..##.","##..#.#............#..#..",".#.o.###...##.......#....","#.........#...#...#.##..#","....##....#.##..#....#.##",".#.....#.#..#..#.#..#....","...........#.....#.......",".#..#........##.....#....",".....#......o..........#.","..#...#.#.#.#.#..#.##..#.","#........#.....#...#...#.",".#..............#.......#","..#..##.......#.........#","##..#..#......#......#...","......#...........#.#.#..","....###.....#...#.....#..",".......##.o....#..#....#.",".#..##.......##.#........",".#.##.....#...#..........",".....#..#.#.....##......#","...#.........##....#..##.","......#......#...###.....","#.#.....#..#.##.#..####.#","......o.#.##..#........##","#..#..........##...#.#...","....#.#.......#..........","..........#.......#......","#.##......#...#..#....###","#..#......#..#...........",".#...#..#..........##.#..","..#...##..........#...#..",".........#...............",".....#.#......#.#........","...#...#..o.............."}

    3

    Returns: 37

  20. {"........###.###...#...#...#....##.....#..#.","..................o..#.##............#.....","...###...#.#....#....#.......#.....#.#.....","..#...............#..#.....#..#..#..#....#.",".....#..#....#...........#.....#..##......#","......#....###.............#........##.#...","#..#...........#.##.#..........#......#..#.","..##.....#..#......#....#........#.......#.","#...###...##..#.....##...........#.......##","....#..##....#..#...#....#..#...#....##....","..#.....................#.##...........#...","#..##..#.#..#.#...#..#.......##...#.....###","..#........#.#..#....#...#..#..........####","........###...#............................","..#..#.#...............#....#.##.......#.#.","#...............##...#............#.#......",".......##....#.........#..#...#............","#..#...#...#.......#.#...#..............#..","......#...#...#..........###..#............",".#......#...##.......#.#..........#........","...##.###.#.#..#...#....#.........#.......#","...#......#...#.#...#......#...............","....#............#...#.....#......#........","#.#.##..##..#.......##........#.#.#........","..........####.......#.....#...#.o...o#.#..","##....#.............o.#......#.#..........#",".#..##...##.#...#...##........#........##.#",".....#........#..#...........#..........#..","......###.#..#.##....##..##..##............","...........#.#.##.#....#.....#.....#.#..###","..#.....##.#.#........#....##.##........#.#","..#.............#...#.#...#..........##...#","...#.#..#.....#.....#.....#..#..#..#.......","...#...........###..#..#................#.#",".....#........#....#..#####.....##.......o.","......#.#..#......#...#...##.........#.#..#","...#.####..##.............##....#..#.#.....","#......#.#..#...##...#.......##...#...#....",".......#.#........#...............#..#...#.","...#...#..#...#.....#..................#.#."}

    4

    Returns: 75

  21. {"..##.##......##....#.....#.##.#.","......#..#...#....#...#.....#...",".....o............#......o...#..","....#......#...#.#.#...#.##.#...",".....#...#......#......#.....#..","...#.....#....#..#...#.#..#..#..","o.........#...........#.#.#.#..#",".##..#..............o...#.......",".......##........#...#.#.#...#..","........#....o..#o.#.........#.."}

    4

    Returns: 36

  22. {"...#.#...#.#......#....#...#.............",".........#..#.......##...............#...",".....#.#......#.......#.o##...........##.","##..#..#..#....#.#.....#.#.#.#..#.#.#..#.",".#.#.............#..............#.....#..","....#.#...#......#.......................",".#...#.#.......#......#...#...#.....#.##.",".#...##........#.............#.#.....#.##","..#...#.....##........#...#.....#..#.....","..........#...##....#..#....#.#..........","#......##...##.....#........#.#..........","......##..........#..#.#.##....#.........","...#......##.#.............##......#.#.#.","#......##........#..##..###...#.#...##..#","...#..#..#..#.#.............#.....#......","#.............#...#......#....#.#........","...#.#......#.#.......o..#.#.....#.#.....","..#.#.#....#.....#.#......#...##.#.....#.",".......#...#.....#...##..#...............","#.#...##..o....##.#...##...#....#........","....#....#............................#.."}

    3

    Returns: 60

  23. {"..#.#.....o....#...................#.#.","#.#.#.#.....##.......#.#........#.....#","....#..o.###.##..#.....#..#..#..###..##","....#.#........###.#.#........#....#...",".#..........##.....................#...","#......#...#......##.........#....#.#..","#....#......#...#...##.......#.#.......",".#.##..##...#..#........#.....#........","..#...#...#...#.#.#....#.###...#..#.#..",".......#...####......#...#.........#.#.","..#..........#.#..#.#.##..##.#........#","......#........#..#.##......#..#..#...#",".....##.......#..###.##............#...","...#.#....#.#....#........#..#..##.....","...#..............#.#........##........","##...###.....#............##.#..##.....",".#..####...........#.#..#.##......#....",".#..#..#............##........#.#..##.#",".#..#.............#..........o...#..#..","..#.#.#.....#.#...#....#......#..#....#","##....#............#.....#..##.........","...#....##.........##...#.......o#....#","........#.......#.....#...#.....##.....","..........#.#...........##..#.#........",".....#.#...#..##...#............#....#.","........#......#.....#.................","#........#.##............##............","..#........#.......#.......#....#......","#.......#......##...#..#.#..#.........#","#...#....#.#........#....#.........#...","...........##.....#.#....#.##.##.#...#.","#......##..##...............##....#....",".#.##.....#........#......###.....#.#.#","..#.##.......##..#.......#........#.#..","..........#.....#.......##.#.#..#......","####..........#....#...#...#..........#","...#..###..#..........#...###...#......",".....#...........#..##...##o....#......",".........#...........#.##..#.......#.#.","...#...#.....#.#.#.......#......#......","#......##..##.#....#...................","...#.....#...#...#..#..#..............#",".#.#..........##...............#...##.#","............#..#.....####..#.....#..#.#","....#....#.......#.#..#..#............#"}

    4

    Returns: 61

  24. {".#....",".#..#.","#....#",".....#","#...#.","#.....","......","...#..","......","......","..#..#","......","o...#.","......","..#...","#.#...","......","#.....","..#...",".#....",".o.#..","#...#.",".....#","...#.#","..#...","##..#.","..#...","o.....","......",".....#","......","......","#.#.#.","#..#o.","o.....","#.....","#..#..","......","......"}

    1

    Returns: -1

  25. {"....#",".#..#","...#.",".....","..##.","..#..",".....","..o..","....#","###..",".....",".....","##..#","..#..",".##o.",".....",".....",".....","#.#.#",".....","..#..",".#...",".#..#","..#..","#.#..","...#.","#.##.","#..#.",".o.o.","....#",".....",".....","#....",".....","#.#.."}

    3

    Returns: 33

  26. {"........o......#.#.........","....#.#....#.#....#.##.#...",".....o....................#","....#...........#.....#....",".#.#....o.o..#.#....#......"}

    4

    Returns: 18

  27. {".........#...........#....o.#..#o.#.","#......#......#.#............##.....","..#.#..#....#......##.#......#.##...","...#.#......###...##.#.....#........","..#...#.#....o...##.....o...#.o..#.."}

    4

    Returns: 48

  28. {"..o...#.",".##..#..",".#....##","..o...#.",".......o",".#...#o#","#..#....","##......","#.......",".....#..","....#...","........",".#......","...#....","oo.....#","..#.....","....#..."}

    4

    Returns: 15

  29. {".##...#.......#..o.........#...##...#.#.#.#.","#..##.....#..#.#.#..#.......##.#....##...#..",".#..##.........#....#..#....#.#...........#.","#..#..#..........#..........#..#..#..#..#...","............#.#.##.##..#.##...#.....#..#....",".....##..#.#.#..#........#..................","..#........#....##....#............#......#.","#.....#.....#........#.#......##......##....","..##.#....########..#.##..o#..#.#.....##....","...#...#........#....................#.....#","#......#.##.......................#.#.#.#..#",".............#.#..#.....#..o..............##",".......###.......###.#...#..#........#..##.#","...#.#.#.......#..o.#....#.......#........#.",".....#..#....#.#....o#...........#.....#.#.#",".#...#..#.#......##................#........",".#...#.#.##....##.......#..##....#...##..#.#","####.#........................#....#..#..#..",".......##.#......##....#.#.......##.........","....#................#.......#..............","##................#...##.#......##....#..#.#",".........##...#....#.#.#.#..#...........#.#.","..#.......#.#..#...###.#..#.....#.#...#.....","..#.................................#....#..","o.......#......#.#.#...#...##........#......","...#..............#.....#..#......#.........",".#....#.#.#.......#.......###.#.....#.......","....#......#...#.#.#.#...............#...#.."}

    2

    Returns: -1

  30. {".#.......#...#...#........#.","..#........o#..#....###.....",".......###.#...#.##.........",".....#.............#...#....",".....##.....#............#..","....##....#.o..#...#........","...##..#....#.##..##........","..#....###.#..#.....#.#..#.#",".........#......#........#..","..#..o....#.........#.##....",".#..##...##............#..#.","..#...#....#.#.##......#..#.","...#..#.#....#......#.##....","#........#......###.#.....#.","...........##..#......#.#...","#...#...#..........#..##....",".#.#.#.#....##..............","..##........#...#....#.....#","..#.#......#...#.......#.#..","....#.......##..#...##...###",".#..##..#...................","..#...#.....###............#",".......#.#.#..#.......##.#.#","...#....#..................#",".#.#.....#.#..#.#..#...###..","##..#............#.....o....","...........##..#.........##.","..#.....#..#...#....#.....#.",".#...#...#....#........#.#..","...#...........#.#......#...","####...#.....###............",".......#.........#..#.......","...#...#.#...#.......##...##","...#.#..#...#.##.#.o..##...#",".....#..##....#...#...#.....","..#...##..#.#.....#..#.###.#","......#.#........##.....#...",".....#.........#............","...##.....#..#....#.#....#..","..#..#.......#..##...#.#...#"}

    3

    Returns: 34

  31. {".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"...................o.............................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"........................................o........." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,"..........o......................................." ,".................................................." ,".................................................." ,".................................................." ,".....................................o............" ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".................................................." ,".......................o.........................o"}

    4

    Returns: 104

  32. {"..o.." ,"...#o" ,".#..#" ,"#..#." ,".#..#" ,"#o..." ,".#.#."}

    3

    Returns: 14

  33. {"............#.#..#...##..#.", "..........#..#...#.#...#..#", "...#o..#.#......###...##..#", "..#.#.#.##.#.#.##..#.#.#...", "#.#......#.#.##..#.....#...", ".............##..#..##.....", "....#....#..##............#", "...###..##.##...##....#.#..", "........#......##.#..##....", "..#.#.###.#................", "..##........#.#....#..#..##", "..#.#...##..#......#.##....", "###.###..#.#.#.......#.#.#.", "##.###..#.........#.#.#...#", "....#.....#................", "#....##..#..#.......#.#....", "...oo...#...#.#..#......##.", ".#.###......##.##.####o.#..", "..#....##.#....##.#.....##."}

    4

    Returns: 55

  34. { "....#", "o##o#", ".##oo", ".##.#", "....#" }

    4

    Returns: 8

  35. { ".....", "o....", "o....", "o....", "...o." }

    3

    Returns: 3

  36. { "........................................", "........................................", "........................................", "........................................", "...............................o........", "........................................", "........................................", "........................................", "........................................", "........................................", ".............o..........................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", ".........................o..............", ".......................................#", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", ".......................................o", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "........................................", "....o...................................", "........................................", "........................................", "........................................", "........................................" }

    4

    Returns: 96

  37. { ".##..", ".....", ".....", ".....", "o....", "o...." }

    2

    Returns: 5

  38. { "..#....", "..#.##o", "#.#.#..", "#.#o#.#", "..#.#.#", "#...#.o", "o.#.#.." }

    4

    Returns: 27

  39. { ".#...#...#...#...#...#...#...#...#...#...#o", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.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.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", ".#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.", "...#...#...#...#...#...#...#...#...#...#..." }

    1

    Returns: 1098

  40. { ".....", "##...", "o#...", "o#...", "....." }

    2

    Returns: 10


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: