How many lights are on?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Linguistics Meta

Q&A about the site for professional linguists and others with an interest in linguistic research and theory

DECLARE @ varchar(max)= '>>>><^v^v'

;WITH C as
(
  SELECT 0 a,b=1
  UNION ALL
  SELECT a+POWER(CHARINDEX(SUBSTRING(@,b,1),'> <v')-2,15),b+1
  FROM C
  WHERE b<=LEN(@)
)
SELECT sum(z) FROM 
  (SELECT sum(1)%2z
   FROM c
   WHERE b>1
   GROUP BY a)z
OPTION(MAXRECURSION 0)

Enter Parameters

Options:
Switch to main site
loading Hold tight while we fetch your results