March 7, 2011 at 12:05 am
Comments posted to this topic are about the item TSQL Challenge 51 - Convert long Binary strings to Decimal strings
.
March 7, 2011 at 8:03 am
Not able to reach the site with the link provided the Site. The answer could be
;WITH CTE
AS
(
SELECT SEQ, BINARYVALUE, 0 AS EXPO, CONVERT(NVARCHAR(4000),RIGHT(BINARYVALUE,1)) REMAINING
, CONVERT(NVARCHAR(4000),LEFT(BINARYVALUE,LEN(BINARYVALUE) - 1)) DEDUCTIBLE
FROM TC51
UNION ALL
SELECT SEQ, BINARYVALUE, EXPO + 1, CONVERT(NVARCHAR(4000),RIGHT(DEDUCTIBLE,1))
,CONVERT(NVARCHAR(4000),LEFT(DEDUCTIBLE,LEN(DEDUCTIBLE) - CASE WHEN LEN(DEDUCTIBLE) > 0 THEN 1 ELSE 0 END )) DEDUCTIBLE
FROM CTE
WHERE LEN(DEDUCTIBLE) > 0
)
sELECT SUM(remaining * power(CONVERT(NUMERIC(18,0),2),expo)),seq, binaryvalue
FROM CTE
group by seq, binaryvalue
order by seq, binaryvalue
If there is any better method, please let me know how can I view it?
March 7, 2011 at 8:51 am
Most people submit their solutions in the first two weeks after the challenge is published. The evaluation then might take another 2-4 weeks to complete. The solutions will be available publicly after the evaluation is completed.
I would encourage you to go to http://beyondrelational.com/puzzles/sqlserver/tsql/51/submit.aspx and submit your solution.
.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy