Created
October 21, 2010 23:01
-
-
Save robbywalker/639551 to your computer and use it in GitHub Desktop.
Tim Lerner's T-SQL solution to GPCv1 Level 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare @String varchar(8000) = 'Fourscoreand...' | |
select l.N as TestLen | |
, c.N as TestChar | |
, substring(s.String, c.N, l.N) as Candidate | |
from (select @String as String) s | |
cross join master.dbo.Tally l | |
cross join master.dbo.Tally c | |
where 1 = 1 | |
and l.N > 1 | |
and l.N <= len(s.String) | |
and c.N <= len(s.String) | |
and c.N + l.N < len(s.String) | |
and substring(s.String, c.N, l.N) = reverse(substring(s.String, c.N, l.N)) | |
order by l.N desc, c.N desc | |
go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment