Prison Architect, ASCII version Here is a diagram of a prison using ASCII characters:

+------------------------------+
|                              |
|   X               X          |
|                              |
|                              D
D                              |
|                              |
|                              |
|        X           X   X     |
|                              |
+------------------------------+


Walls are made out of pipe characters |, dashes -, and pillars + for corners and intersections. There are also two doors marked with D (which will always be on the left and right walls). The prison is filled with scary people marked with X.

The goal is to build walls to satisfy the following:


Each person is in solitary confinement;
There is a corridor running between the two doors;
Each cell contains exactly one door, which is directly connected to the main corridor;
All space in the prison is used by the cells and the corridor;
Each cell contains a person (that is, there are no empty cells).


The corridor is a single path, doesn't branch off, and is always one character wide. Here's a solution for the prison above:

+---------+--------------------+
|         |                    |
|   X     |         X          |
|         |           +--------+
+------D--+-----D-----+        D
D                       +---D--+
+----D--------+---D-----+      |
|             |         |      |
|        X    |      X  |X     |
|             |         |      |
+-------------+---------+------+


You can assume that any input prison will always have a valid output. Here are some more input prisons, along with possible outputs:

+------------------------------+
|X X X X X X X X X X X X X X X |
|                              |
D                              D
|                              |
|              X               |
+------------------------------+

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+--+
|X|X|X|X|X|X|X|X|X|X|X|X|X|X|X |
+D+D+D+D+D+D+D+D+D+D+D+D+D+D+D-+
D                              D
+----------------------D-------+
|              X               |
+------------------------------+

+-----------+
|X          |
|           |
|           |
|X         X|
|           |
|          X|
|           |
D           D
+-----------+

+-+-------+-+
|X|       D |
| D +---+ | |
+-+ |     | |
|X| | +---+X|
| | | |   +-+
| D | |    X|
+-+ | +-D---+
D   |       D
+---+-------+

+----------------+
|X    X    X    X|
|                |
D                |
|                |
|X    X    X     |
|                |
|                |
|                |
|     X    X     D
|                |
|                |
+----------------+

+---+---+----+---+
|X  | X |  X |  X|
+--D+--D+---D+--D+
D                |
+---+---+------+ |
|X  | X |  X   | |
+--D+--D+---D--+ |
|                |
| +-----+------+-+
| |   X |  X   | D
| +----D+---D--+ |
|                |
+----------------+
Python 2, 2986 2881 2949 2135 2075 2071 1996 bytes


Saved 105 bytes, implemented the program as a function to comply with standard rules. Implemented Wheat Wizard's tab and space suggestion.
Added 68 bytes due to fixing a bug.
Saved 814+51 bytes thanks to Halvard Hummel.
Saved 9+4 bytes.
Saved 4 bytes thanks to Erik the Outgolfer.
Saved 71 bytes thanks to ppperry's suggestion.




exec r"""def Z(P):
 H,n,I,o,O,i,d,D,W=[type,range]+list(" dD#xX*");R=(1,0),(-1,0),(0,1),(0,-1)
 def F(j,k,l):P[j][k]=l
 def E(j,k,v,w):
&#9;if G(j,k,v):F(k,j,w)
 def q(b,c,d):[[E(j+J,k+K,b,c)for J,K in M]&amp;L if G(j,k,d)]
 def A(e,r,l,o,q):
&#9;S,E,P[q][o],Q,X=P[q][o],e,0,[(o,q)],0
&#9;for a,b in Q:
&#9; &amp;R:
&#9;&#9;x,y=a+j,b+k
&#9;&#9;if(0&lt;=x&lt;w!=0&lt;=y&lt;h)&lt;1:continue
&#9;&#9;if e in((x,y),P[y][x]):X=1;e=x,y;break
&#9;&#9;if I!=P[y][x]:continue
&#9;&#9;F(y,x,P[b][a]+1);Q+=[(x,y)]
&#9; if X:break
&#9;p,i=e,0
&#9;while(o,q)!=p:
&#9; a,b=p;P[b][a],m=[r,l][l and i==1],0
&#9; &amp;R:
&#9;&#9;x,y=a+j,b+k
&#9;&#9;if(0&lt;=x&lt;w!=0&lt;=y&lt;h)-1:continue
&#9;&#9;if(H(P[y][x])==H(0))*(m==0 or P[y][x]&lt;P[m[1]][m[0]]):m=x,y
&#9; p=m;i+=1
&#9;P[q][o],P[e[1]][e[0]]=S,E;[F(k,j,I)&amp;L if H(P[k][j])==H(0)]
 def B(N):
&#9;[[E(j,k,"x*",I),0&lt;j&lt;w-1 and E(j,k,O,I)]&amp;L]
&#9;&amp;L:
&#9; if G(j,k,D):[E(j+J,k+K,I,d)for J,K in M]
&#9; if G(j,k,O)and j==0:T=0,k
&#9;if N:A(O,o,0,*T)
&#9;U,V=M[-1];[[[F(k+K,j+J,I)for J,K in M if(P[k+K][j+J]!=i)*((0&lt;=j+J+U&lt;w!=0&lt;=k+K+V&lt;h and G(j+J+U,k+K+V,D))&lt;1)],F(k,j,W),A(o,W,O,j,k),q(I,d,W),F(k,j,D)]&amp;L if G(j,k,D)];q("xX*# @+-|",i,o)
 for j in"|+-":P=P.replace(j,i)
 P=list(map(list,P.split("\n")));h=len(P);w=len(P[0]);b,L,M,G="#+-|D",[(k,j)for k in n(w)for j in n(h)],[(k-1,j-1)for k in n(3)for j in n(3)if(j,k)!=(1,1)],lambda j,k,v:P[k][j]in v
 B(1);Y=lambda:0&lt;j&lt;w-1!=0&lt;k&lt;h-1and G(j,k,i);[[[F(k,j,o),F(k+g,j+N,i)]for N,g in((-1,-1),(-1,1),(1,-1),(1,1))if P[k][j+g]+P[k][j-g]==P[k+N][j+g]+P[k-N][j]==P[k+N][j]+i==o+i]&amp;L if(j in(1,w-2)or k in(1,h-2))*Y()for N in n(w*h)];[F(k,j,I)&amp;L if Y()];B(0)
 def c(x,y,b,l,d,f,Q):
&#9;F(y,x,b)
&#9;for J,K in M:Q+=[[],[(x+J,y+K)]][G(x+J,y+K,l)];E(x+J,y+K,d,f)
 &amp;L:
&#9;if G(j,k,D):Q=[(j,k)];[c(x,y,"@",W,d,I,Q)for x,y in Q if G(x,y,"X*")];[G(u,v,"X*")and[E(u+U,v+V,I,d)for U,V in M]or E(u,v,"@",I)for u,v in L];Q=Q[:1];[c(x,y,"$",I,"x*",i,Q)for x,y in Q];F(k,j,D)
 &amp;L:E(j,k,"@$d",I);X=(k&gt;0and G(j,k-1,b))+(k&lt;h-1and G(j,k+1,b))-(j&gt;0and G(j-1,k,b))-(j&lt;w-1and G(j+1,k,b));E(j,k,i,{2:"+",X:"|",-X:"-"}[2])
 print"\n".join("".join(p)for p in P)""".replace("&amp;","for j,k in ")


Try it online!

It was golfed down significantly; yet there may still be room for improvement. This piece of code, however, solves all test cases. Does not run very efficiently; for large prisons the architect may take their time to figure it out.
Uses a simple pathfinding algorithm to connect both doors and the prisoners to the corridor. Then it encapsulates all prisoners and their walls and pushes said walls in empty space until all of it is filled. As a final step, the ASCII art appearance is implemented.

Took me for sure several hours to write. I hope it also works on other prisons than the test cases. (You cannot test them all, can you?)