DECLARE @ varchar(8000)= '#################### # ...

0

Please login or register to vote for this query.

(click on this box to dismiss)

Ask Ubuntu

Q&A for Ubuntu users and developers

DECLARE @ varchar(8000)=
'####################
#                # #
#                ###
#    o            ##
#      ##         ##
#                ###
####################';

WITH s as(SELECT @ m,3c,0i
UNION ALL
SELECT
stuff(stuff(m,a+x/3*2-1-~x%2*s*(x-3),1,'o'),a,1,
char(59+x+~x%2*11*~x))m,x,i-1FROM(SELECT
charindex(' ',replicate(stuff(substring(m,a-1,3),2,1,substring(m,a+~s,1))+
substring(m,a-~s,1)+'x',2),c-1+1/c*4)%5x,*FROM(SELECT*,charindex('o',m)a,charindex('
',M)S FROM S)Q)L
WHERE x>0)SELECT top 1m FROM s
ORDER BY i
OPTION(MAXRECURSION 0)
--SELECT x^2 from (values(1),(2),(3),(4)) x(x)

Enter Parameters

Options:
Switch sites:
loading Hold tight while we fetch your results