How many lights are on?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Android Enthusiasts Meta

Q&A about the site for enthusiasts and power users of the Android operating system

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 sites:
loading Hold tight while we fetch your results