August 21, 2018 at 9:12 pm
Comments posted to this topic are about the item Who Works on What?
August 21, 2018 at 10:29 pm
Steve Jones - SSC Editor - Tuesday, August 21, 2018 9:12 PMComments posted to this topic are about the item Who Works on What?
Nice one Steve, just like making sense out of requirement documentation😀
😎
August 21, 2018 at 11:52 pm
August 22, 2018 at 4:09 am
Nice one - it's quite a tricky Einstein Riddle
Needs an "X" on the form though
Michael Gilchrist
Database Specialist
There are 10 types of people in the world, those who understand binary and those that don't. 😀
August 22, 2018 at 4:11 am
Hang on - was it a hint to provide a SQL based solution, I can see the where clause already 😎
Michael Gilchrist
Database Specialist
There are 10 types of people in the world, those who understand binary and those that don't. 😀
August 22, 2018 at 4:24 am
Haven't done of these since I was a kid, thanks! Enjoyed that 🙂
August 22, 2018 at 6:32 am
Luckily I already had my first cup of coffee on board before I tackled this.
August 22, 2018 at 9:34 am
When should we expect an answer?
August 22, 2018 at 9:46 am
Apologies on the answer. My scheduling thing didn't quite work as expected.
Answer here: http://www.sqlservercentral.com/articles/Logic+Puzzle/176523/
August 22, 2018 at 10:15 am
Steve Jones - SSC Editor - Wednesday, August 22, 2018 9:46 AMApologies on the answer. My scheduling thing didn't quite work as expected.Answer here: http://www.sqlservercentral.com/articles/Logic+Puzzle/176523/
As I said earlier, just like business requirements with all the implied ambiguity, this is not the only solution that fits the requirements 😉
😎
I found this one and another one, unfortunately forgot to safe it :pinch:
August 22, 2018 at 6:06 pm
I enjoyed this one a lot. Thanks for the fun challenge Steve!
August 23, 2018 at 1:42 am
Sack the new project manager because he was too lame to speak directly to the developers.
August 23, 2018 at 3:39 am
There may be a more elegant way of doing this, but given that SQL is declarative, we can just give all the information to the database engine and ask it to sort it out. It actually runs surprisingly fast.WITH post_its (post_it)
AS
(
SELECT 'pink'
UNION ALL SELECT 'brown'
UNION ALL SELECT 'red'
UNION ALL SELECT 'white'
UNION ALL SELECT 'gray'
),
drinks (drink)
AS
(
SELECT 'tea'
UNION ALL SELECT 'mountain dew'
UNION ALL SELECT 'beer'
UNION ALL SELECT 'water'
UNION ALL SELECT 'coffee'
),
languages (language)
AS
(
SELECT 'T-SQL'
UNION ALL SELECT 'C#'
UNION ALL SELECT 'Javascript'
UNION ALL SELECT 'PowerShell'
UNION ALL SELECT 'HTML/CSS'
),
combinations
AS
(
SELECT *
FROM post_its
CROSS JOIN drinks
CROSS JOIN languages
)
SELECT combinations_1.post_it AS post_it_1,
combinations_1.drink AS drink_1,
combinations_1.language AS language_1,
combinations_2.post_it AS post_it_2,
combinations_2.drink AS drink_2,
combinations_2.language AS language_2,
combinations_3.post_it AS post_it_3,
combinations_3.drink AS drink_3,
combinations_3.language AS language_3,
combinations_4.post_it AS post_it_4,
combinations_4.drink AS drink_4,
combinations_4.language AS language_4,
combinations_5.post_it AS post_it_5,
combinations_5.drink AS drink_5,
combinations_5.language AS language_5
FROM combinations AS combinations_1
CROSS JOIN combinations AS combinations_2
CROSS JOIN combinations AS combinations_3
CROSS JOIN combinations AS combinations_4
CROSS JOIN combinations AS combinations_5
WHERE combinations_1.post_it <> combinations_2.post_it
AND combinations_1.drink <> combinations_2.drink
AND combinations_1.language <> combinations_2.language
AND combinations_1.post_it <> combinations_3.post_it
AND combinations_1.drink <> combinations_3.drink
AND combinations_1.language <> combinations_3.language
AND combinations_1.post_it <> combinations_4.post_it
AND combinations_1.drink <> combinations_4.drink
AND combinations_1.language <> combinations_4.language
AND combinations_1.post_it <> combinations_5.post_it
AND combinations_1.drink <> combinations_5.drink
AND combinations_1.language <> combinations_5.language
AND combinations_2.post_it <> combinations_3.post_it
AND combinations_2.drink <> combinations_3.drink
AND combinations_2.language <> combinations_3.language
AND combinations_2.post_it <> combinations_4.post_it
AND combinations_2.drink <> combinations_4.drink
AND combinations_2.language <> combinations_4.language
AND combinations_2.post_it <> combinations_5.post_it
AND combinations_2.drink <> combinations_5.drink
AND combinations_2.language <> combinations_5.language
AND combinations_3.post_it <> combinations_4.post_it
AND combinations_3.drink <> combinations_4.drink
AND combinations_3.language <> combinations_4.language
AND combinations_3.post_it <> combinations_5.post_it
AND combinations_3.drink <> combinations_5.drink
AND combinations_3.language <> combinations_5.language
AND combinations_4.post_it <> combinations_5.post_it
AND combinations_4.drink <> combinations_5.drink
AND combinations_4.language <> combinations_5.language
AND ((combinations_1.post_it = 'pink' AND combinations_3.post_it = 'brown')
OR (combinations_1.post_it = 'brown' AND combinations_3.post_it = 'pink')
OR (combinations_2.post_it = 'pink' AND combinations_4.post_it = 'brown')
OR (combinations_2.post_it = 'brown' AND combinations_4.post_it = 'pink')
OR (combinations_5.post_it = 'pink' AND combinations_5.post_it = 'brown')
OR (combinations_5.post_it = 'brown' AND combinations_5.post_it = 'pink')
)
AND ((combinations_1.language = 'C#' AND combinations_2.drink = 'mountain dew')
OR (combinations_2.language = 'C#' AND combinations_3.drink = 'mountain dew')
OR (combinations_3.language = 'C#' AND combinations_4.drink = 'mountain dew')
OR (combinations_4.language = 'C#' AND combinations_5.drink = 'mountain dew')
)
AND ((combinations_1.language = 'T-SQL' AND combinations_2.post_it = 'red')
OR (combinations_1.language = 'T-SQL' AND combinations_3.post_it = 'red')
OR (combinations_1.language = 'T-SQL' AND combinations_4.post_it = 'red')
OR (combinations_1.language = 'T-SQL' AND combinations_5.post_it = 'red')
OR (combinations_2.language = 'T-SQL' AND combinations_3.post_it = 'red')
OR (combinations_2.language = 'T-SQL' AND combinations_4.post_it = 'red')
OR (combinations_2.language = 'T-SQL' AND combinations_5.post_it = 'red')
OR (combinations_3.language = 'T-SQL' AND combinations_4.post_it = 'red')
OR (combinations_3.language = 'T-SQL' AND combinations_5.post_it = 'red')
OR (combinations_4.language = 'T-SQL' AND combinations_5.post_it = 'red')
)
AND combinations_2.drink <> 'mountain dew'
AND ((combinations_1.language = 'Javascript' AND combinations_4.drink = 'tea')
OR (combinations_1.drink = 'tea' AND combinations_4.language = 'Javascript')
OR (combinations_2.language = 'Javascript' AND combinations_5.drink = 'tea')
OR (combinations_2.drink = 'tea' AND combinations_5.drink = 'tea')
)
AND combinations_2.language = 'PowerShell'
AND ((combinations_1.drink = 'beer' AND combinations_3.post_it = 'pink')
OR (combinations_1.post_it = 'pink' AND combinations_3.drink = 'beer')
OR (combinations_2.drink = 'beer' AND combinations_4.post_it = 'pink')
OR (combinations_2.post_it = 'pink' AND combinations_4.drink = 'beer')
OR (combinations_3.drink = 'beer' AND combinations_5.post_it = 'pink')
OR (combinations_3.post_it = 'pink' AND combinations_5.drink = 'beer')
)
AND ((combinations_1.post_it = 'gray' AND combinations_2.language = 'PowerShell')
OR (combinations_2.post_it = 'gray' AND combinations_3.language = 'PowerShell')
OR (combinations_3.post_it = 'gray' AND combinations_4.language = 'PowerShell')
OR (combinations_4.post_it = 'gray' AND combinations_5.language = 'PowerShell')
)
AND ((combinations_1.language = 'C#' AND combinations_4.language = 'Javascript')
OR (combinations_1.language = 'Javascript' AND combinations_4.language = 'C#')
OR (combinations_2.language = 'C#' AND combinations_5.language = 'Javascript')
OR (combinations_2.language = 'Javascript' AND combinations_5.language = 'C#')
)
AND ((combinations_1.drink = 'tea' AND combinations_3.post_it = 'brown')
OR (combinations_1.post_it = 'brown' AND combinations_3.drink = 'tea')
OR (combinations_2.drink = 'tea' AND combinations_4.post_it = 'brown')
OR (combinations_2.post_it = 'brown' AND combinations_4.drink = 'tea')
OR (combinations_3.drink = 'tea' AND combinations_5.post_it = 'brown')
OR (combinations_3.post_it = 'brown' AND combinations_5.drink = 'tea')
)
AND ((combinations_1.language = 'T-SQL' AND combinations_3.drink = 'coffee')
OR (combinations_1.drink = 'coffee' AND combinations_3.language = 'T-SQL')
OR (combinations_2.language = 'T-SQL' AND combinations_4.drink = 'coffee')
OR (combinations_2.drink = 'coffee' AND combinations_4.language = 'T-SQL')
OR (combinations_3.language = 'T-SQL' AND combinations_5.drink = 'coffee')
OR (combinations_3.drink = 'coffee' AND combinations_5.language = 'T-SQL')
);
By the way, this seems to work with or without the penultimate clue.
August 23, 2018 at 11:48 am
It took me three tries to realized that "sits to the left of" is not "sits directly to the left of"...
Viewing 15 posts - 1 through 15 (of 17 total)
You must be logged in to reply to this topic. Login to reply