Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 Reader Challenge #3: Find the Yak!
 Reply to Topic
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 3

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/07/2002 :  15:09:10  Show Profile  Reply with Quote
The safe that guards the results of the Find The Yak competition has a combination lock. Sadly, Rob has forgotten what the code is. He can remember the following:

The code is a sequence of 9 distinct non-zero digits.
The fourth digit minus the sixth digit equals the seventh digit.
The product of the first 3 digits is the same as sum of the last two.
The sum of the second, third and sixth is less than the eighth digit.
The ninth digit is smaller than the eighth.
None of the digits is equal to its position in the sequence.

Can you write some SQL to help Rob recover the results?


Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 04/07/2002 :  18:11:47  Show Profile  Visit nr's Homepage  Reply with Quote

/*
1 The code is a sequence of 9 distinct non-zero digits.
2 The fourth digit minus the sixth digit equals the seventh digit.
3 The product of the first 3 digits is the same as sum of the last two.
4 The sum of the second, third and sixth is less than the eighth digit.
5 The ninth digit is smaller than the eighth.
6 None of the digits is equal to its position in the sequence.
*/

set nocount on
create table #a (position int, value int)
declare @i int, @j int
select @i = 0, @j = 0

while @j < 9
begin
select @j = @j + 1
select @i = 0
while @i < 9
begin
select @i = @i + 1
insert #a select @j, @i
end
end

-- condition 6
delete #a where position = value

-- derived table
select a1.value, a2.value, a3.value, a4.value, a5.value, a6.value, a7.value, a8.value, a9.value
from #a a1, #a a2, #a a3, #a a4, #a a5, #a a6, #a a7, #a a8, #a a9
where a1.position = 1
and a2.position = 2
and a3.position = 3
and a4.position = 4
and a5.position = 5
and a6.position = 6
and a7.position = 7
and a8.position = 8
and a9.position = 9
-- condition 1
and a1.value not in (a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value)
and a2.value not in (a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value)
and a3.value not in (a4.value,a5.value,a6.value,a7.value,a8.value,a9.value)
and a4.value not in (a5.value,a6.value,a7.value,a8.value,a9.value)
and a5.value not in (a6.value,a7.value,a8.value,a9.value)
and a6.value not in (a7.value,a8.value,a9.value)
and a7.value not in (a8.value,a9.value)
and a8.value not in (a9.value)
-- condition 2
and a4.value - a6.value = a7.value
-- condition 3
and a1.value * a2.value * a3.value = a8.value + a9.value
-- condition 4
and a2.value + a3.value + a6.value < a8.value
-- condition 5
and a9.value < a8.value

drop table #a
go

result
value value value value value value value value value
----------- ----------- ----------- ----------- ----------- ----------- ----------- ----------- -----------
4 3 1 8 9 2 6 7 5


==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/08/2002 :  04:30:11  Show Profile  Reply with Quote
Well, that's the safe opened. But what's this? It's huge! And walking in, we're faced by an array of fearsome heraldic beasts. Six each of Bears, Dragons, Griffins, Lions, Unicorns and Yaks (natch). They've arranged themselves into a square, and each row has all 6 types of animal, and so do the columns. That's clever, I wonder how many ways they could have done that...
Oh, I've just noticed that these animals are 6 different colours (Gules, Vert, Azure, Tenné, Sable and Purpure). Each type of animal comes in all 6 colours. And each row has all 6 colours in it, and so do the columns. Or am I dreaming?



Edited by - Arnold Fribble on 04/08/2002 04:43:58
Go to Top of Page

nr
SQLTeam MVY

United Kingdom
12543 Posts

Posted - 04/08/2002 :  05:54:51  Show Profile  Visit nr's Homepage  Reply with Quote
isn't this all a bit trivial?

==========================================
Cursors are useful if you don't know sql.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/08/2002 :  06:01:14  Show Profile  Reply with Quote
Yes and no (respectively).
Just trying to help pass the time...


Go to Top of Page

efelito
Constraint Violating Yak Guru

USA
478 Posts

Posted - 04/08/2002 :  12:26:07  Show Profile  Visit efelito's Homepage  Reply with Quote
OK... Now I'm starting to get just plain scaired.

Jeff Banschbach
Consultant, MCDBA
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/11/2002 :  17:07:35  Show Profile  Reply with Quote
No takers? Never mind...
Shorn of the nonsense about heraldic beasts and such, the first part is effectively asking to enumerate the latin squares of order 6. A latin square is simply an n×n array of n different symbols so that each column and each row contains no symbol more than once (or equivalently contains all n symbols). It's relatively easy, if tedious, to write a query to do this, but you probably wouldn't want to run it to completion since the answer is 812851200. However, a simple observation is that the order of columns and rows has no effect on whether the arrangement is valid. From this, you can restrict the first row and first column to both be, say, 012345. Doing this gives you just 9408 possibilities, which a moderate PC can enumerate in a couple of seconds (in SQL). From there, it's just a question of multiplying: 9408 * 6! * 5! = 812851200.

The second part is slightly unfair since it's asking to find 2 mutually orthogonal latin squares of order six. A question that is often posed as the "36 officer problem". Leonard Euler attempted to find a solution, or a proof that none existed, but failed. The answer of 'no' had to wait for over 100 years until Tarry finally proved it (by enumeration!!) in 1900. I've written a little program to generate the SQL to test each of the 9408 normalized latin squares for an orthogonal pair, but it takes a while to run (about 45 minutes!) -- this is compared to about 25 seconds for a similarly generated version in Delphi (essentially 55 nested for-loops with an unhealthy sprinkling of if's).
It's all rather disappointing since you end up with a result of no rows... but the code looks dead scary
This generates the normalized latin squares first as a temporary table -- probably not necessary, but easier to debug! The FORCE ORDER hint on the end is just because otherwise the query plan takes a couple of minutes to generate and ends up putting #normal some way in... it may well work ok without it, but I haven't tried.

SET STATISTICS IO ON
SET STATISTICS TIME ON

CREATE TABLE #n (n int PRIMARY KEY)
INSERT INTO #n
SELECT 0
UNION SELECT 1
UNION SELECT 2
UNION SELECT 3
UNION SELECT 4
UNION SELECT 5

SELECT *
INTO #normal
FROM (
SELECT
0 a00, 1 a01, 2 a02, 3 a03, 4 a04, 5 a05,
1 a10, a11.n a11, a12.n a12, a13.n a13, a14.n a14, a15.n a15,
2 a20, a21.n a21, a22.n a22, a23.n a23, a24.n a24, a25.n a25,
3 a30, a31.n a31, a32.n a32, a33.n a33, a34.n a34, a35.n a35,
4 a40, a41.n a41, a42.n a42, a43.n a43, a44.n a44, a45.n a45,
5 a50, a51.n a51, a52.n a52, a53.n a53, a54.n a54, a55.n a55
FROM
#n a11, #n a12, #n a13, #n a14, #n a15,
#n a21, #n a22, #n a23, #n a24, #n a25,
#n a31, #n a32, #n a33, #n a34, #n a35,
#n a41, #n a42, #n a43, #n a44, #n a45,
#n a51, #n a52, #n a53, #n a54, #n a55
) x
WHERE
NOT (a10 = a11 OR a12 IN (a10,a11) OR a13 IN (a10,a11,a12) OR a14 IN (a10,a11,a12,a13) OR a15 IN (a10,a11,a12,a13,a14)
OR a20 = a21 OR a22 IN (a20,a21) OR a23 IN (a20,a21,a22) OR a24 IN (a20,a21,a22,a23) OR a25 IN (a20,a21,a22,a23,a24)
OR a30 = a31 OR a32 IN (a30,a31) OR a33 IN (a30,a31,a32) OR a34 IN (a30,a31,a32,a33) OR a35 IN (a30,a31,a32,a33,a34)
OR a40 = a41 OR a42 IN (a40,a41) OR a43 IN (a40,a41,a42) OR a44 IN (a40,a41,a42,a43) OR a45 IN (a40,a41,a42,a43,a44)
OR a50 = a51 OR a52 IN (a50,a51) OR a53 IN (a50,a51,a52) OR a54 IN (a50,a51,a52,a53) OR a55 IN (a50,a51,a52,a53,a54)

OR a01 = a11 OR a21 IN (a01,a11) OR a31 IN (a01,a11,a21) OR a41 IN (a01,a11,a21,a31) OR a51 IN (a01,a11,a21,a31,a41)
OR a02 = a12 OR a22 IN (a02,a12) OR a32 IN (a02,a12,a22) OR a42 IN (a02,a12,a22,a32) OR a52 IN (a02,a12,a22,a32,a42)
OR a03 = a13 OR a23 IN (a03,a13) OR a33 IN (a03,a13,a23) OR a43 IN (a03,a13,a23,a33) OR a53 IN (a03,a13,a23,a33,a43)
OR a04 = a14 OR a24 IN (a04,a14) OR a34 IN (a04,a14,a24) OR a44 IN (a04,a14,a24,a34) OR a54 IN (a04,a14,a24,a34,a44)
OR a05 = a15 OR a25 IN (a05,a15) OR a35 IN (a05,a15,a25) OR a45 IN (a05,a15,a25,a35) OR a55 IN (a05,a15,a25,a35,a45)
)

SELECT *
FROM #normal, (
SELECT
0 b00, 1 b01, 2 b02, 3 b03, 4 b04, 5 b05,
b10.n b10, b11.n b11, b12.n b12, b13.n b13, b14.n b14, b15.n b15,
b20.n b20, b21.n b21, b22.n b22, b23.n b23, b24.n b24, b25.n b25,
b30.n b30, b31.n b31, b32.n b32, b33.n b33, b34.n b34, b35.n b35,
b40.n b40, b41.n b41, b42.n b42, b43.n b43, b44.n b44, b45.n b45,
b50.n b50, b51.n b51, b52.n b52, b53.n b53, b54.n b54, b55.n b55
FROM
#n b10, #n b11, #n b12, #n b13, #n b14, #n b15,
#n b20, #n b21, #n b22, #n b23, #n b24, #n b25,
#n b30, #n b31, #n b32, #n b33, #n b34, #n b35,
#n b40, #n b41, #n b42, #n b43, #n b44, #n b45,
#n b50, #n b51, #n b52, #n b53, #n b54, #n b55
) x
WHERE
NOT (b10 = b11 OR b12 IN (b10,b11) OR b13 IN (b10,b11,b12) OR b14 IN (b10,b11,b12,b13) OR b15 IN (b10,b11,b12,b13,b14)
OR b20 = b21 OR b22 IN (b20,b21) OR b23 IN (b20,b21,b22) OR b24 IN (b20,b21,b22,b23) OR b25 IN (b20,b21,b22,b23,b24)
OR b30 = b31 OR b32 IN (b30,b31) OR b33 IN (b30,b31,b32) OR b34 IN (b30,b31,b32,b33) OR b35 IN (b30,b31,b32,b33,b34)
OR b40 = b41 OR b42 IN (b40,b41) OR b43 IN (b40,b41,b42) OR b44 IN (b40,b41,b42,b43) OR b45 IN (b40,b41,b42,b43,b44)
OR b50 = b51 OR b52 IN (b50,b51) OR b53 IN (b50,b51,b52) OR b54 IN (b50,b51,b52,b53) OR b55 IN (b50,b51,b52,b53,b54)

OR b00 = b10 OR b20 IN (b00,b10) OR b30 IN (b00,b10,b20) OR b40 IN (b00,b10,b20,b30) OR b50 IN (b00,b10,b20,b30,b40)
OR b01 = b11 OR b21 IN (b01,b11) OR b31 IN (b01,b11,b21) OR b41 IN (b01,b11,b21,b31) OR b51 IN (b01,b11,b21,b31,b41)
OR b02 = b12 OR b22 IN (b02,b12) OR b32 IN (b02,b12,b22) OR b42 IN (b02,b12,b22,b32) OR b52 IN (b02,b12,b22,b32,b42)
OR b03 = b13 OR b23 IN (b03,b13) OR b33 IN (b03,b13,b23) OR b43 IN (b03,b13,b23,b33) OR b53 IN (b03,b13,b23,b33,b43)
OR b04 = b14 OR b24 IN (b04,b14) OR b34 IN (b04,b14,b24) OR b44 IN (b04,b14,b24,b34) OR b54 IN (b04,b14,b24,b34,b44)
OR b05 = b15 OR b25 IN (b05,b15) OR b35 IN (b05,b15,b25) OR b45 IN (b05,b15,b25,b35) OR b55 IN (b05,b15,b25,b35,b45)

OR b10 = b01
OR (a11=a00 AND b11=b00) OR (a11=a02 AND b11=b02) OR (a11=a03 AND b11=b03) OR (a11=a04 AND b11=b04) OR (a11=a05 AND b11=b05)
OR (a12=a00 AND b12=b00) OR (a12=a01 AND b12=b01) OR (a12=a03 AND b12=b03) OR (a12=a04 AND b12=b04) OR (a12=a05 AND b12=b05)
OR (a13=a00 AND b13=b00) OR (a13=a01 AND b13=b01) OR (a13=a02 AND b13=b02) OR (a13=a04 AND b13=b04) OR (a13=a05 AND b13=b05)
OR (a14=a00 AND b14=b00) OR (a14=a01 AND b14=b01) OR (a14=a02 AND b14=b02) OR (a14=a03 AND b14=b03) OR (a14=a05 AND b14=b05)
OR (a15=a00 AND b15=b00) OR (a15=a01 AND b15=b01) OR (a15=a02 AND b15=b02) OR (a15=a03 AND b15=b03) OR (a15=a04 AND b15=b04)

OR b20 = b02
OR (a20=a11 AND b20=b11) OR (a20=a12 AND b20=b12) OR (a20=a13 AND b20=b13) OR (a20=a14 AND b20=b14) OR (a20=a15 AND b20=b15)
OR (a21=a00 AND b21=b00) OR (a21=a02 AND b21=b02) OR (a21=a03 AND b21=b03) OR (a21=a04 AND b21=b04) OR (a21=a05 AND b21=b05)
OR (a21=a10 AND b21=b10) OR (a21=a12 AND b21=b12) OR (a21=a13 AND b21=b13) OR (a21=a14 AND b21=b14) OR (a21=a15 AND b21=b15)
OR (a22=a00 AND b22=b00) OR (a22=a01 AND b22=b01) OR (a22=a03 AND b22=b03) OR (a22=a04 AND b22=b04) OR (a22=a05 AND b22=b05)
OR (a22=a10 AND b22=b10) OR (a22=a11 AND b22=b11) OR (a22=a13 AND b22=b13) OR (a22=a14 AND b22=b14) OR (a22=a15 AND b22=b15)
OR (a23=a00 AND b23=b00) OR (a23=a01 AND b23=b01) OR (a23=a02 AND b23=b02) OR (a23=a04 AND b23=b04) OR (a23=a05 AND b23=b05)
OR (a23=a10 AND b23=b10) OR (a23=a11 AND b23=b11) OR (a23=a12 AND b23=b12) OR (a23=a14 AND b23=b14) OR (a23=a15 AND b23=b15)
OR (a24=a00 AND b24=b00) OR (a24=a01 AND b24=b01) OR (a24=a02 AND b24=b02) OR (a24=a03 AND b24=b03) OR (a24=a05 AND b24=b05)
OR (a24=a10 AND b24=b10) OR (a24=a11 AND b24=b11) OR (a24=a12 AND b24=b12) OR (a24=a13 AND b24=b13) OR (a24=a15 AND b24=b15)
OR (a25=a00 AND b25=b00) OR (a25=a01 AND b25=b01) OR (a25=a02 AND b25=b02) OR (a25=a03 AND b25=b03) OR (a25=a04 AND b25=b04)
OR (a25=a10 AND b25=b10) OR (a25=a11 AND b25=b11) OR (a25=a12 AND b25=b12) OR (a25=a13 AND b25=b13) OR (a25=a14 AND b25=b14)

OR b30 = b03
OR (a30=a11 AND b30=b11) OR (a30=a12 AND b30=b12) OR (a30=a13 AND b30=b13) OR (a30=a14 AND b30=b14) OR (a30=a15 AND b30=b15)
OR (a30=a21 AND b30=b21) OR (a30=a22 AND b30=b22) OR (a30=a23 AND b30=b23) OR (a30=a24 AND b30=b24) OR (a30=a25 AND b30=b25)
OR (a31=a00 AND b31=b00) OR (a31=a02 AND b31=b02) OR (a31=a03 AND b31=b03) OR (a31=a04 AND b31=b04) OR (a31=a05 AND b31=b05)
OR (a31=a10 AND b31=b10) OR (a31=a12 AND b31=b12) OR (a31=a13 AND b31=b13) OR (a31=a14 AND b31=b14) OR (a31=a15 AND b31=b15)
OR (a31=a20 AND b31=b20) OR (a31=a22 AND b31=b22) OR (a31=a23 AND b31=b23) OR (a31=a24 AND b31=b24) OR (a31=a25 AND b31=b25)
OR (a32=a00 AND b32=b00) OR (a32=a01 AND b32=b01) OR (a32=a03 AND b32=b03) OR (a32=a04 AND b32=b04) OR (a32=a05 AND b32=b05)
OR (a32=a10 AND b32=b10) OR (a32=a11 AND b32=b11) OR (a32=a13 AND b32=b13) OR (a32=a14 AND b32=b14) OR (a32=a15 AND b32=b15)
OR (a32=a20 AND b32=b20) OR (a32=a21 AND b32=b21) OR (a32=a23 AND b32=b23) OR (a32=a24 AND b32=b24) OR (a32=a25 AND b32=b25)
OR (a33=a00 AND b33=b00) OR (a33=a01 AND b33=b01) OR (a33=a02 AND b33=b02) OR (a33=a04 AND b33=b04) OR (a33=a05 AND b33=b05)
OR (a33=a10 AND b33=b10) OR (a33=a11 AND b33=b11) OR (a33=a12 AND b33=b12) OR (a33=a14 AND b33=b14) OR (a33=a15 AND b33=b15)
OR (a33=a20 AND b33=b20) OR (a33=a21 AND b33=b21) OR (a33=a22 AND b33=b22) OR (a33=a24 AND b33=b24) OR (a33=a25 AND b33=b25)
OR (a34=a00 AND b34=b00) OR (a34=a01 AND b34=b01) OR (a34=a02 AND b34=b02) OR (a34=a03 AND b34=b03) OR (a34=a05 AND b34=b05)
OR (a34=a10 AND b34=b10) OR (a34=a11 AND b34=b11) OR (a34=a12 AND b34=b12) OR (a34=a13 AND b34=b13) OR (a34=a15 AND b34=b15)
OR (a34=a20 AND b34=b20) OR (a34=a21 AND b34=b21) OR (a34=a22 AND b34=b22) OR (a34=a23 AND b34=b23) OR (a34=a25 AND b34=b25)
OR (a35=a00 AND b35=b00) OR (a35=a01 AND b35=b01) OR (a35=a02 AND b35=b02) OR (a35=a03 AND b35=b03) OR (a35=a04 AND b35=b04)
OR (a35=a10 AND b35=b10) OR (a35=a11 AND b35=b11) OR (a35=a12 AND b35=b12) OR (a35=a13 AND b35=b13) OR (a35=a14 AND b35=b14)
OR (a35=a20 AND b35=b20) OR (a35=a21 AND b35=b21) OR (a35=a22 AND b35=b22) OR (a35=a23 AND b35=b23) OR (a35=a24 AND b35=b24)

OR b40 = b04
OR (a40=a11 AND b40=b11) OR (a40=a12 AND b40=b12) OR (a40=a13 AND b40=b13) OR (a40=a14 AND b40=b14) OR (a40=a15 AND b40=b15)
OR (a40=a21 AND b40=b21) OR (a40=a22 AND b40=b22) OR (a40=a23 AND b40=b23) OR (a40=a24 AND b40=b24) OR (a40=a25 AND b40=b25)
OR (a40=a31 AND b40=b31) OR (a40=a32 AND b40=b32) OR (a40=a33 AND b40=b33) OR (a40=a34 AND b40=b34) OR (a40=a35 AND b40=b35)
OR (a41=a00 AND b41=b00) OR (a41=a02 AND b41=b02) OR (a41=a03 AND b41=b03) OR (a41=a04 AND b41=b04) OR (a41=a05 AND b41=b05)
OR (a41=a10 AND b41=b10) OR (a41=a12 AND b41=b12) OR (a41=a13 AND b41=b13) OR (a41=a14 AND b41=b14) OR (a41=a15 AND b41=b15)
OR (a41=a20 AND b41=b20) OR (a41=a22 AND b41=b22) OR (a41=a23 AND b41=b23) OR (a41=a24 AND b41=b24) OR (a41=a25 AND b41=b25)
OR (a41=a30 AND b41=b30) OR (a41=a32 AND b41=b32) OR (a41=a33 AND b41=b33) OR (a41=a34 AND b41=b34) OR (a41=a35 AND b41=b35)
OR (a42=a00 AND b42=b00) OR (a42=a01 AND b42=b01) OR (a42=a03 AND b42=b03) OR (a42=a04 AND b42=b04) OR (a42=a05 AND b42=b05)
OR (a42=a10 AND b42=b10) OR (a42=a11 AND b42=b11) OR (a42=a13 AND b42=b13) OR (a42=a14 AND b42=b14) OR (a42=a15 AND b42=b15)
OR (a42=a20 AND b42=b20) OR (a42=a21 AND b42=b21) OR (a42=a23 AND b42=b23) OR (a42=a24 AND b42=b24) OR (a42=a25 AND b42=b25)
OR (a42=a30 AND b42=b30) OR (a42=a31 AND b42=b31) OR (a42=a33 AND b42=b33) OR (a42=a34 AND b42=b34) OR (a42=a35 AND b42=b35)
OR (a43=a00 AND b43=b00) OR (a43=a01 AND b43=b01) OR (a43=a02 AND b43=b02) OR (a43=a04 AND b43=b04) OR (a43=a05 AND b43=b05)
OR (a43=a10 AND b43=b10) OR (a43=a11 AND b43=b11) OR (a43=a12 AND b43=b12) OR (a43=a14 AND b43=b14) OR (a43=a15 AND b43=b15)
OR (a43=a20 AND b43=b20) OR (a43=a21 AND b43=b21) OR (a43=a22 AND b43=b22) OR (a43=a24 AND b43=b24) OR (a43=a25 AND b43=b25)
OR (a43=a30 AND b43=b30) OR (a43=a31 AND b43=b31) OR (a43=a32 AND b43=b32) OR (a43=a34 AND b43=b34) OR (a43=a35 AND b43=b35)
OR (a44=a00 AND b44=b00) OR (a44=a01 AND b44=b01) OR (a44=a02 AND b44=b02) OR (a44=a03 AND b44=b03) OR (a44=a05 AND b44=b05)
OR (a44=a10 AND b44=b10) OR (a44=a11 AND b44=b11) OR (a44=a12 AND b44=b12) OR (a44=a13 AND b44=b13) OR (a44=a15 AND b44=b15)
OR (a44=a20 AND b44=b20) OR (a44=a21 AND b44=b21) OR (a44=a22 AND b44=b22) OR (a44=a23 AND b44=b23) OR (a44=a25 AND b44=b25)
OR (a44=a30 AND b44=b30) OR (a44=a31 AND b44=b31) OR (a44=a32 AND b44=b32) OR (a44=a33 AND b44=b33) OR (a44=a35 AND b44=b35)
OR (a45=a00 AND b45=b00) OR (a45=a01 AND b45=b01) OR (a45=a02 AND b45=b02) OR (a45=a03 AND b45=b03) OR (a45=a04 AND b45=b04)
OR (a45=a10 AND b45=b10) OR (a45=a11 AND b45=b11) OR (a45=a12 AND b45=b12) OR (a45=a13 AND b45=b13) OR (a45=a14 AND b45=b14)
OR (a45=a20 AND b45=b20) OR (a45=a21 AND b45=b21) OR (a45=a22 AND b45=b22) OR (a45=a23 AND b45=b23) OR (a45=a24 AND b45=b24)
OR (a45=a30 AND b45=b30) OR (a45=a31 AND b45=b31) OR (a45=a32 AND b45=b32) OR (a45=a33 AND b45=b33) OR (a45=a34 AND b45=b34)

OR b50 = b05
OR (a50=a11 AND b50=b11) OR (a50=a12 AND b50=b12) OR (a50=a13 AND b50=b13) OR (a50=a14 AND b50=b14) OR (a50=a15 AND b50=b15)
OR (a50=a21 AND b50=b21) OR (a50=a22 AND b50=b22) OR (a50=a23 AND b50=b23) OR (a50=a24 AND b50=b24) OR (a50=a25 AND b50=b25)
OR (a50=a31 AND b50=b31) OR (a50=a32 AND b50=b32) OR (a50=a33 AND b50=b33) OR (a50=a34 AND b50=b34) OR (a50=a35 AND b50=b35)
OR (a50=a41 AND b50=b41) OR (a50=a42 AND b50=b42) OR (a50=a43 AND b50=b43) OR (a50=a44 AND b50=b44) OR (a50=a45 AND b50=b45)
OR (a51=a00 AND b51=b00) OR (a51=a02 AND b51=b02) OR (a51=a03 AND b51=b03) OR (a51=a04 AND b51=b04) OR (a51=a05 AND b51=b05)
OR (a51=a10 AND b51=b10) OR (a51=a12 AND b51=b12) OR (a51=a13 AND b51=b13) OR (a51=a14 AND b51=b14) OR (a51=a15 AND b51=b15)
OR (a51=a20 AND b51=b20) OR (a51=a22 AND b51=b22) OR (a51=a23 AND b51=b23) OR (a51=a24 AND b51=b24) OR (a51=a25 AND b51=b25)
OR (a51=a30 AND b51=b30) OR (a51=a32 AND b51=b32) OR (a51=a33 AND b51=b33) OR (a51=a34 AND b51=b34) OR (a51=a35 AND b51=b35)
OR (a51=a40 AND b51=b40) OR (a51=a42 AND b51=b42) OR (a51=a43 AND b51=b43) OR (a51=a44 AND b51=b44) OR (a51=a45 AND b51=b45)
OR (a52=a00 AND b52=b00) OR (a52=a01 AND b52=b01) OR (a52=a03 AND b52=b03) OR (a52=a04 AND b52=b04) OR (a52=a05 AND b52=b05)
OR (a52=a10 AND b52=b10) OR (a52=a11 AND b52=b11) OR (a52=a13 AND b52=b13) OR (a52=a14 AND b52=b14) OR (a52=a15 AND b52=b15)
OR (a52=a20 AND b52=b20) OR (a52=a21 AND b52=b21) OR (a52=a23 AND b52=b23) OR (a52=a24 AND b52=b24) OR (a52=a25 AND b52=b25)
OR (a52=a30 AND b52=b30) OR (a52=a31 AND b52=b31) OR (a52=a33 AND b52=b33) OR (a52=a34 AND b52=b34) OR (a52=a35 AND b52=b35)
OR (a52=a40 AND b52=b40) OR (a52=a41 AND b52=b41) OR (a52=a43 AND b52=b43) OR (a52=a44 AND b52=b44) OR (a52=a45 AND b52=b45)
OR (a53=a00 AND b53=b00) OR (a53=a01 AND b53=b01) OR (a53=a02 AND b53=b02) OR (a53=a04 AND b53=b04) OR (a53=a05 AND b53=b05)
OR (a53=a10 AND b53=b10) OR (a53=a11 AND b53=b11) OR (a53=a12 AND b53=b12) OR (a53=a14 AND b53=b14) OR (a53=a15 AND b53=b15)
OR (a53=a20 AND b53=b20) OR (a53=a21 AND b53=b21) OR (a53=a22 AND b53=b22) OR (a53=a24 AND b53=b24) OR (a53=a25 AND b53=b25)
OR (a53=a30 AND b53=b30) OR (a53=a31 AND b53=b31) OR (a53=a32 AND b53=b32) OR (a53=a34 AND b53=b34) OR (a53=a35 AND b53=b35)
OR (a53=a40 AND b53=b40) OR (a53=a41 AND b53=b41) OR (a53=a42 AND b53=b42) OR (a53=a44 AND b53=b44) OR (a53=a45 AND b53=b45)
OR (a54=a00 AND b54=b00) OR (a54=a01 AND b54=b01) OR (a54=a02 AND b54=b02) OR (a54=a03 AND b54=b03) OR (a54=a05 AND b54=b05)
OR (a54=a10 AND b54=b10) OR (a54=a11 AND b54=b11) OR (a54=a12 AND b54=b12) OR (a54=a13 AND b54=b13) OR (a54=a15 AND b54=b15)
OR (a54=a20 AND b54=b20) OR (a54=a21 AND b54=b21) OR (a54=a22 AND b54=b22) OR (a54=a23 AND b54=b23) OR (a54=a25 AND b54=b25)
OR (a54=a30 AND b54=b30) OR (a54=a31 AND b54=b31) OR (a54=a32 AND b54=b32) OR (a54=a33 AND b54=b33) OR (a54=a35 AND b54=b35)
OR (a54=a40 AND b54=b40) OR (a54=a41 AND b54=b41) OR (a54=a42 AND b54=b42) OR (a54=a43 AND b54=b43) OR (a54=a45 AND b54=b45)
OR (a55=a00 AND b55=b00) OR (a55=a01 AND b55=b01) OR (a55=a02 AND b55=b02) OR (a55=a03 AND b55=b03) OR (a55=a04 AND b55=b04)
OR (a55=a10 AND b55=b10) OR (a55=a11 AND b55=b11) OR (a55=a12 AND b55=b12) OR (a55=a13 AND b55=b13) OR (a55=a14 AND b55=b14)
OR (a55=a20 AND b55=b20) OR (a55=a21 AND b55=b21) OR (a55=a22 AND b55=b22) OR (a55=a23 AND b55=b23) OR (a55=a24 AND b55=b24)
OR (a55=a30 AND b55=b30) OR (a55=a31 AND b55=b31) OR (a55=a32 AND b55=b32) OR (a55=a33 AND b55=b33) OR (a55=a34 AND b55=b34)
OR (a55=a40 AND b55=b40) OR (a55=a41 AND b55=b41) OR (a55=a42 AND b55=b42) OR (a55=a43 AND b55=b43) OR (a55=a44 AND b55=b44)
)
OPTION (FORCE ORDER)

DROP TABLE #n
DROP TABLE #normal

 


Go to Top of Page

graz
Chief SQLTeam Crack Dealer

USA
4149 Posts

Posted - 04/21/2002 :  22:50:39  Show Profile  Visit graz's Homepage  Reply with Quote
Maybe if we all bug Rob enough he'll get this article written :)

===============================================
Creating tomorrow's legacy systems today.
One crisis at a time.
Go to Top of Page

rrb
SQLTeam Poet Laureate

Australia
1479 Posts

Posted - 04/23/2002 :  20:37:14  Show Profile  Reply with Quote
Now I see how little I am . Kept getting a solution which gave me multiple answers and so I gave up thinking I had missed something. (damn)!

C'mon robvolk - if it will help, I can feed the s for you.

There once was an SQL riddle
Which complexity saw many a dribble
Some solutions were posted
But only one boasted
the name of the great Arnold Fribble!

OK I'm bored...

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/24/2002 :  04:30:37  Show Profile  Reply with Quote
quote:

Some solutions were posted


That one was later deleted. When it was posted, I'd assumed that the Unicode characters would get mangled somewhere along the way, and so it wouldn't work. I'm still a bit puzzled as to why they came out right: there was a thread about storing Russian text a while back, and everytime I tried posting to that the Russian characters got corrupted.
The solutions above are for other combinatorial problems.

До свидания
(argh!)


Edited by - Arnold Fribble on 04/24/2002 04:40:32
Go to Top of Page

Page47
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 04/24/2002 :  08:40:43  Show Profile  Reply with Quote
quote:

...But only one boasted...



I’m a sucker for a well-composed verse,
And I’ll try to keep my comment terse.
But, to claim only one,
Well, that’s not fun.
Cause Jay99 boasted first!!!



<O>
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 04/27/2002 :  04:44:50  Show Profile  Reply with Quote
4

Go to Top of Page

rrb
SQLTeam Poet Laureate

Australia
1479 Posts

Posted - 04/28/2002 :  19:23:14  Show Profile  Reply with Quote
Page47 has wrongly wrote
Regarding my earlier note!
I tried as hard as I could,
But I've been misunderstood
Because what I said was that only one solution could boast the NAME of good old Arnold Fribble, unquote.

(and what a great name that is)

Cold beer to all you poms.

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

Page47
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 04/29/2002 :  09:23:53  Show Profile  Reply with Quote
quote:

But I've been misunderstood



oops . . . right . . . gee, I musta gotten into beers, eh?

<O>
Go to Top of Page

rrb
SQLTeam Poet Laureate

Australia
1479 Posts

Posted - 04/29/2002 :  18:40:13  Show Profile  Reply with Quote
Ah Page... (may I call you Page?)

Beer is to Lymmericks as a horse is to water...You can take a horse to water, but don't change it mid-stream A stitch in time is better than two in the bush, and magic carpets are one thing, but sailing off into the rich tapestry of life is quite something else...



--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

Page47
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 05/02/2002 :  09:08:47  Show Profile  Reply with Quote
Gainesville produced a cruel ,
Who upside his head, should be smacked.
Cause on 3/22,
He challenged a few,
But has since neglected to post back.


. . . despite writing other articles . . .



<O>
Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 05/04/2002 :  03:08:16  Show Profile  Reply with Quote
5

Go to Top of Page

chadmat
The Chadinator

USA
1974 Posts

Posted - 05/04/2002 :  03:20:18  Show Profile  Visit chadmat's Homepage  Reply with Quote
quote:

5





What is ... the number of weeks since the contest closed!


I'll take "Over hyped contests that take too long to judge" for 200 Arnold.


-Chad

Go to Top of Page

Arnold Fribble
Yak-finder General

United Kingdom
1961 Posts

Posted - 05/04/2002 :  03:29:04  Show Profile  Reply with Quote
200? You think it'll take him 4 years? Oh, I see, it's a Jeopardy thing. Coupland got that right, too, then.



Go to Top of Page

chadmat
The Chadinator

USA
1974 Posts

Posted - 05/04/2002 :  03:59:34  Show Profile  Visit chadmat's Homepage  Reply with Quote
I think he is waiting until the winner reaches 1000 posts so they can get the custom title he promised.

(Not that I am entered, didn't have the time to put into it, but I am interested in seeing what the winning solution is)



Go to Top of Page
Page: of 3 Previous Topic Topic Next Topic  
Previous Page | Next Page
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 1.13 seconds. Powered By: Snitz Forums 2000