파이썬 3 428 408 385 378 바이트
작동하지만 골프를 치기에는 엄청난 잠재력이 있습니다. 나는 조금 녹슬었다.
사각형을 만들기 위해 공백이 채워져 있다고 가정합니다.
편집 : 23 바이트 절약을위한 @Artyer 덕분에!
EDIT2 : 와우 6 바이트 절약을 완전히 놓쳤습니다. 등호 검사의 측면을 바꾸어 1 개 더 절약했습니다.
*i,=map(list,input().split('\n'))
r=c=s=q=e=w=0
o=lambda y,x:len(i[0])>x>=0<=y<len(i)
d='\/_|'
for l in i:
if'x'in l:r=i.index(l);c=l.index('x')
for a,b in(1,0),(0,1),(-1,0),(0,-1):
y,x=r+a,c+b;f=o(y,x)and i[y][x]
if f in d:s=f;w=d.index(f);q,e=y,x
k=lambda y,x,g=[1,1,0,1][w],v=[1,-1,1,0][w]:o(y,x)and s==i[y][x]and(exec('i[y][x]=0')or 1+k(y+g,x+v)+k(y-g,x-v))
print(k(q,e))
설명이있는 확장 버전 :
inputtt=''' ______________.
/ ____________ \
|/ __________ \|
||/ ________ \||
|||/ ______ \|||
||||/ \||||
|||||/ x |||||
|||||\_____/||||
||||\_______/|||
|||\_________/||
||\___________/|
\_____________/'''
# First, we get the input from STDIN and make it
# into a doubly-nested array
*input_text,=map(list,inputtt.split('\n'))
# A pretty cool Python trick to assign 0 to
# mulitple variables at once.
row=col=line_letter=line_row=line_col=line_char_index=0
# A function to check if a certian row and col is
# in bounds or not. Uses python's comparator chaining
in_bounds=lambda y,x:len(input_text[0])>x>=0<=y<len(input_text)
# A string to store all the line characters.
chars='\/_|'
# Search for the x
for line in input_text:
# If this line contains the x...
if'x'in line:
# Mark the row and column
row=input_text.index(line);col=line.index('x')
# For each direction...
for down,right in(1,0),(0,1),(-1,0),(0,-1):
# Move in that direction
y,x=row+down,col+right
# If the position is in bounds, mark the char at that position
line_found=in_bounds(y,x)and input_text[y][x]
# If the char is a line char, set all the variables saying we found it
if line_found in chars:
line_letter=line_found
line_char_index=chars.index(line_found)
line_row,line_col=y,x
recur=lambda y,x,\
# Find which directions we are supposed to recur in based on the line char
g=[1,1,0,1][line_char_index],v=[1,-1,1,0][line_char_index]:\
# If the char is in bounds and we are still on the line...
in_bounds(y,x)and input_text[y][x]==line_letter and\
# Set the spot to a 0, so we won't go back, increment,
# and recur in both directions
(exec('i[y][x]=0')or 1+recur(y+g,x+v)+recur(y-g,x-v))
# Finally, print the answer
print(recur(line_row,line_col))