Blog
Project Euler problem 4 T-SQL
Project Euler problem 4 was easier then 3. A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91*99 Find the largest palindrome made from the product of two 3-digit numbers. 1 2 3 4 5 6 7 8 9 10 11 12 13 USE tempdb WITH Scheherazade (i) AS ( SELECT TOP 600 ROW_NUMBER()OVER(ORDER BY object_id)+399 FROM sys.all_objects ) SELECT TOP 11 a.i,b.i , a.i*b.i AS j FROM Scheherazade a CROSS JOIN Scheherazade b WHERE...
read moreProject Euler problem 3 T-SQL Find Prime factors
Project Euler Problem 3 is: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? I thought of finding prime numbers and try to divide the number 600851475143 with them and then check if I found all the factors and finding the biggest one. For finding primes quickly under 10 millions Sieve of Eratosthenes is wellknown algorithm that has been around for 2500 years. ( What I do not understand of the algorithm is that I only have to check up to the square root of the number serie see row...
read moreSorting Chinese Characters in Javascript
To start learning to write a plug-in for jQuery component Datatables I have made a webpage http://sorting.lcube.se/. You can try to sort on different terms there. I plan to explain how Chinese characters are sorted and tell how I make the sorting and what troubles i get into. The first problem I had was that i thought 三 (san1) came after 二 (Er4). I was convinced that this was a bug. But after thinking about it I realized that number 3 三 (san1) has the radical 一 which has fewer strokes than the character for two which has two strokes in...
read moreSortera kinesiska tecken i javascript
För att träna på att skriva plug-in till jQuery komponenten Datatables så har jag gjort en websida: http://sorting.lcube.se/ . Där kan man prova sortera på olika begrepp med min plug-in. Jag tänker förklara hur jag förstått hur kinesiska tecken sorteras samt utveckla hur jag gör och vilka bekymmer som uppstår. Det första problemet jag hade var att jag trodde att 三 (san1) kom efter 二 (Er4). Det här måste vara en bugg var min första reflektion. Men efter att ha sovit på saken så insåg jag att talet 3 三 (san1) har ju radikalen 一 vilket har...
read moreProject Euler problem 2 T-SQL
Euler problem 2: By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. This is a sort of running sum problem that used to be hard (before T-SQL in SQL server 2012) I solved it with known math formula and recursion with common table expression. Tomas as usual solved with single-statement magic. Fibonacci can formula can be calculated by using golden ratio with Binets formula. (cool) . I define a function to calculate Fibonacci for the term n as: golden ratio raised to...
read moreProject Euler with T-SQL
Me and colleague in my current Project Tomas Eriksson decided to start to try the Project Euler problemes in Microsoft SQL Servers Language Transact SQL (T-SQL). First problem was: Add all the natural numbers below one thousand that are multiples of 3 or 5. I made my solution hack back in 2008. It has some flaws. But I post it here to invite criticism. ( Yes I know I should have used % for mod instead of floor, yes I know while loops in SQL do not earn respect) — Euler 1. Add all the natural numbers below one thousand that are...
read moreWill Datawarehouse models conjoint ?
In the 90 the three objectoriented gurus came togehter and became the three amigos. They buried the war tools picked and out grew things like UML. Will the same happened to datawarehouse modeling? I can see three major streams in datawarehouse modeling. Kimballs Star Scheme afficionade with conformed dimension, Bill Inmon with Normalized tables and Dan L with the DataVault. According the clan of Data Vault Inmon says: ” As Bill Inmon has stated, ‘The Data Vault is the optimal choice for modeling the EDW in the DW 2.0...
read more
Senaste kommentarerna