How many lights are on?

0

Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

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

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

Enter Parameters

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