July 7, 2017 at 7:54 am
TomThomson - Thursday, July 6, 2017 3:32 PMHad it been me who was asked that question, you would have received a lecture on not starting to write code untile the requirements were clear; so why should I waste my time on an incompletely specified requirement - tell me what you want the statement to return if @Num is divisible by neither 3 nor 5.
If you resolved that without making a fool of yourself, I would then have pointed out that the appropriate statement is one that relies on @Num being NULL, since your problem declares it and then wants it evaluated despite no value having been assigned. So depending on what you wanted returned when testing for neither divsibility by 5 nor divisibility by 3 would return true the answer would be either "select <whatever tyou said you wanted returned for the non-divisible case>" or, if you said you wanted nothing returned, "select null where 1 = 0" (which returns nothing, for some reasonable interpretation of "returns nothing").
That would demonstrate that I can think for myself and can see the flaws in incomplete specification and ask for clarification.
Perhaps the interviewee you mentioned burst into tears because she realised that she didn't want to work in a shop where the guy interviewing recruits was that sloppy about specifications, so she'd been wasting her time coming to be interviewed because she didn't want to work with a bunch of incompetents. Probably not, but maybe you should be a bit more careful of the impression you give.
I'm with you on this one...
What's the business requirement behind this, why does the user need such an odd piece of code *FOR*?
Is it so HR can lay people off based on their employee ID?
If they get a "Fizz" they get the nice severance package with 6 months pay and health benefits, "Buzz"ers get 1 month pay and no benefits, and "FizzBuzz"ers' get a cardboard box and 5 minutes?
July 7, 2017 at 8:46 am
jasona.work - Friday, July 7, 2017 7:54 AMTomThomson - Thursday, July 6, 2017 3:32 PMHad it been me who was asked that question, you would have received a lecture on not starting to write code untile the requirements were clear; so why should I waste my time on an incompletely specified requirement - tell me what you want the statement to return if @Num is divisible by neither 3 nor 5.
If you resolved that without making a fool of yourself, I would then have pointed out that the appropriate statement is one that relies on @Num being NULL, since your problem declares it and then wants it evaluated despite no value having been assigned. So depending on what you wanted returned when testing for neither divsibility by 5 nor divisibility by 3 would return true the answer would be either "select <whatever tyou said you wanted returned for the non-divisible case>" or, if you said you wanted nothing returned, "select null where 1 = 0" (which returns nothing, for some reasonable interpretation of "returns nothing").
That would demonstrate that I can think for myself and can see the flaws in incomplete specification and ask for clarification.
Perhaps the interviewee you mentioned burst into tears because she realised that she didn't want to work in a shop where the guy interviewing recruits was that sloppy about specifications, so she'd been wasting her time coming to be interviewed because she didn't want to work with a bunch of incompetents. Probably not, but maybe you should be a bit more careful of the impression you give.I'm with you on this one...
What's the business requirement behind this, why does the user need such an odd piece of code *FOR*?
Is it so HR can lay people off based on their employee ID?
If they get a "Fizz" they get the nice severance package with 6 months pay and health benefits, "Buzz"ers get 1 month pay and no benefits, and "FizzBuzz"ers' get a cardboard box and 5 minutes?
Pretty sure there is more to it than just coming up with a solution. She stared at for almost 5 minutes and never asked a question. That is where the failure occurred. Yes, I went beyond what was asked, but then I just wanted to be sure I still knew how to write the FizzBuzz code as it has been a few years since I saw this particular "requirement" being asked.
July 7, 2017 at 8:51 am
J Livingston SQL - Friday, July 7, 2017 5:18 AMDesNorton - Friday, July 7, 2017 5:14 AM..... The spec provides a scenario, and table design, with some sample data. It also provides a set expected outcome.....if only all the questions on this site did this 😀😀
Feel free to write some.
July 7, 2017 at 8:59 am
Steve Jones - SSC Editor - Friday, July 7, 2017 8:51 AMJ Livingston SQL - Friday, July 7, 2017 5:18 AMDesNorton - Friday, July 7, 2017 5:14 AM..... The spec provides a scenario, and table design, with some sample data. It also provides a set expected outcome.....if only all the questions on this site did this 😀😀
Feel free to write some.
A 'perfect' question would be great. I'd add it as a link in my signature and refer posters to it all the time.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
July 7, 2017 at 8:59 am
jasona.work - Friday, July 7, 2017 7:54 AMTomThomson - Thursday, July 6, 2017 3:32 PMHad it been me who was asked that question, you would have received a lecture on not starting to write code untile the requirements were clear; so why should I waste my time on an incompletely specified requirement - tell me what you want the statement to return if @Num is divisible by neither 3 nor 5.
If you resolved that without making a fool of yourself, I would then have pointed out that the appropriate statement is one that relies on @Num being NULL, since your problem declares it and then wants it evaluated despite no value having been assigned. So depending on what you wanted returned when testing for neither divsibility by 5 nor divisibility by 3 would return true the answer would be either "select <whatever tyou said you wanted returned for the non-divisible case>" or, if you said you wanted nothing returned, "select null where 1 = 0" (which returns nothing, for some reasonable interpretation of "returns nothing").
That would demonstrate that I can think for myself and can see the flaws in incomplete specification and ask for clarification.
Perhaps the interviewee you mentioned burst into tears because she realised that she didn't want to work in a shop where the guy interviewing recruits was that sloppy about specifications, so she'd been wasting her time coming to be interviewed because she didn't want to work with a bunch of incompetents. Probably not, but maybe you should be a bit more careful of the impression you give.I'm with you on this one...
What's the business requirement behind this, why does the user need such an odd piece of code *FOR*?
Is it so HR can lay people off based on their employee ID?
If they get a "Fizz" they get the nice severance package with 6 months pay and health benefits, "Buzz"ers get 1 month pay and no benefits, and "FizzBuzz"ers' get a cardboard box and 5 minutes?
I'd have to say that if either of these was a serious response, I'd mark you off my list and end the interview soon. I dislike pedantic arguments for the sake of being difficult.
I think it's an interesting low bar test, an exercise in seeing the user sort through logic. Certainly asking about NULL might be a nice question, but returning the number or just returning the Fizz, Buzz, Fizz, Fizz, etc. is fine. It is just be interesting to see how someone solves the logical problem.
This one is well known, so I'd likely construct something similar but different, just to see how they interpret a simple question.
July 7, 2017 at 9:03 am
Phil Parkin - Friday, July 7, 2017 8:59 AMSteve Jones - SSC Editor - Friday, July 7, 2017 8:51 AMJ Livingston SQL - Friday, July 7, 2017 5:18 AMDesNorton - Friday, July 7, 2017 5:14 AM..... The spec provides a scenario, and table design, with some sample data. It also provides a set expected outcome.....if only all the questions on this site did this 😀😀
Feel free to write some.
A 'perfect' question would be great. I'd add it as a link in my signature and refer posters to it all the time.
If the answer is '42', what is the question?
July 7, 2017 at 9:06 am
Brandie Tarvin - Friday, July 7, 2017 9:03 AMIf the answer is '42', what is the question?
42 + 0? 🙂
This also reminds me of: https://www.youtube.com/watch?v=DKbQFMOEFTs
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
July 7, 2017 at 9:09 am
I know that there some new updates coming for the site. One thing that seems to be missing is a cancel button when posting. If you accidentally click Quote instead of Like there is no way to cancel your post without reloading the page or going to another page. Even stranger is that if you click quote on a different thread you are suddenly quoting both posts. Weird.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 7, 2017 at 9:11 am
Thom A - Friday, July 7, 2017 9:06 AMBrandie Tarvin - Friday, July 7, 2017 9:03 AMIf the answer is '42', what is the question?42 + 0? 🙂
DECLARE @Question VARCHAR(100) =
'The Answer to the Ultimate Question of Life, the Universe, and Everything'
DECLARE @Source VARCHAR(100) =
'The Hitchhikers Guide to the Galaxy'
DECLARE @Answer VARCHAR(10)
SET NOCOUNT ON
IF object_id('tempdb..#ParallelUniverse') IS NOT NULL
DROP TABLE #ParallelUniverse
SELECT top (len(@Source)) IDENTITY(INT, 1, 1) n
INTO #ParallelUniverse FROM master.sys.all_columns
SET @Answer = (select len(@Question) - (SELECT MAX(n) from
((SELECT n FROM #ParallelUniverse )
EXCEPT
(SELECT (PU1.n * PU2.n) AS cn
FROM #ParallelUniverse AS PU1, #ParallelUniverse AS PU2
WHERE PU1.n BETWEEN 2 AND CEILING (SQRT (1000))
AND PU2.n BETWEEN 2 AND CEILING (SQRT (1000))
AND PU1.n <= PU2.n
AND (PU1.n * PU2.n) <= 1000) )x))PRINT @Question + ' is.. ' + @Answer
SET NOCOUNT OFF
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
July 7, 2017 at 9:13 am
Sean Lange - Friday, July 7, 2017 9:09 AMI know that there some new updates coming for the site. One thing that seems to be missing is a cancel button when posting. If you accidentally click Quote instead of Like there is no way to cancel your post without reloading the page or going to another page. Even stranger is that if you click quote on a different thread you are suddenly quoting both posts. Weird.
I like hitting multiple quote buttons to quote multiple posts and being able to type in between them, but the quotes don't get rendered properly. They don't have the boxed outline and I haven't figured out a way to fix it yet.
July 7, 2017 at 9:15 am
Ed Wagner - Friday, July 7, 2017 9:13 AMSean Lange - Friday, July 7, 2017 9:09 AMI know that there some new updates coming for the site. One thing that seems to be missing is a cancel button when posting. If you accidentally click Quote instead of Like there is no way to cancel your post without reloading the page or going to another page. Even stranger is that if you click quote on a different thread you are suddenly quoting both posts. Weird.I like hitting multiple quote buttons to quote multiple posts and being able to type in between them, but the quotes don't get rendered properly. They don't have the boxed outline and I haven't figured out a way to fix it yet.
I can see where the multiple quotes is kind of useful occasionally but not being able to cancel a post is kind of silly.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
July 7, 2017 at 9:20 am
jasona.work - Friday, July 7, 2017 7:54 AMTomThomson - Thursday, July 6, 2017 3:32 PMHad it been me who was asked that question, you would have received a lecture on not starting to write code untile the requirements were clear; so why should I waste my time on an incompletely specified requirement - tell me what you want the statement to return if @Num is divisible by neither 3 nor 5.
If you resolved that without making a fool of yourself, I would then have pointed out that the appropriate statement is one that relies on @Num being NULL, since your problem declares it and then wants it evaluated despite no value having been assigned. So depending on what you wanted returned when testing for neither divsibility by 5 nor divisibility by 3 would return true the answer would be either "select <whatever tyou said you wanted returned for the non-divisible case>" or, if you said you wanted nothing returned, "select null where 1 = 0" (which returns nothing, for some reasonable interpretation of "returns nothing").
That would demonstrate that I can think for myself and can see the flaws in incomplete specification and ask for clarification.
Perhaps the interviewee you mentioned burst into tears because she realised that she didn't want to work in a shop where the guy interviewing recruits was that sloppy about specifications, so she'd been wasting her time coming to be interviewed because she didn't want to work with a bunch of incompetents. Probably not, but maybe you should be a bit more careful of the impression you give.I'm with you on this one...
What's the business requirement behind this, why does the user need such an odd piece of code *FOR*?
Is it so HR can lay people off based on their employee ID?
If they get a "Fizz" they get the nice severance package with 6 months pay and health benefits, "Buzz"ers get 1 month pay and no benefits, and "FizzBuzz"ers' get a cardboard box and 5 minutes?
It's pretty common to have a business requirement that might match 1 or more criteria, the basic question can you do a % in SQL is easy. But perhaps an additional caveat would be to include showing multiple solutions that have different results and explaining why each of them does.
July 7, 2017 at 9:28 am
Sean Lange - Friday, July 7, 2017 9:15 AMEd Wagner - Friday, July 7, 2017 9:13 AMSean Lange - Friday, July 7, 2017 9:09 AMI know that there some new updates coming for the site. One thing that seems to be missing is a cancel button when posting. If you accidentally click Quote instead of Like there is no way to cancel your post without reloading the page or going to another page. Even stranger is that if you click quote on a different thread you are suddenly quoting both posts. Weird.I like hitting multiple quote buttons to quote multiple posts and being able to type in between them, but the quotes don't get rendered properly. They don't have the boxed outline and I haven't figured out a way to fix it yet.
I can see where the multiple quotes is kind of useful occasionally but not being able to cancel a post is kind of silly.
Agreed
July 7, 2017 at 10:08 am
Steve Jones - SSC Editor - Friday, July 7, 2017 8:59 AMjasona.work - Friday, July 7, 2017 7:54 AMTomThomson - Thursday, July 6, 2017 3:32 PMHad it been me who was asked that question, you would have received a lecture on not starting to write code untile the requirements were clear; so why should I waste my time on an incompletely specified requirement - tell me what you want the statement to return if @Num is divisible by neither 3 nor 5.
If you resolved that without making a fool of yourself, I would then have pointed out that the appropriate statement is one that relies on @Num being NULL, since your problem declares it and then wants it evaluated despite no value having been assigned. So depending on what you wanted returned when testing for neither divsibility by 5 nor divisibility by 3 would return true the answer would be either "select <whatever tyou said you wanted returned for the non-divisible case>" or, if you said you wanted nothing returned, "select null where 1 = 0" (which returns nothing, for some reasonable interpretation of "returns nothing").
That would demonstrate that I can think for myself and can see the flaws in incomplete specification and ask for clarification.
Perhaps the interviewee you mentioned burst into tears because she realised that she didn't want to work in a shop where the guy interviewing recruits was that sloppy about specifications, so she'd been wasting her time coming to be interviewed because she didn't want to work with a bunch of incompetents. Probably not, but maybe you should be a bit more careful of the impression you give.I'm with you on this one...
What's the business requirement behind this, why does the user need such an odd piece of code *FOR*?
Is it so HR can lay people off based on their employee ID?
If they get a "Fizz" they get the nice severance package with 6 months pay and health benefits, "Buzz"ers get 1 month pay and no benefits, and "FizzBuzz"ers' get a cardboard box and 5 minutes?I'd have to say that if either of these was a serious response, I'd mark you off my list and end the interview soon. I dislike pedantic arguments for the sake of being difficult.
I think it's an interesting low bar test, an exercise in seeing the user sort through logic. Certainly asking about NULL might be a nice question, but returning the number or just returning the Fizz, Buzz, Fizz, Fizz, etc. is fine. It is just be interesting to see how someone solves the logical problem.
This one is well known, so I'd likely construct something similar but different, just to see how they interpret a simple question.
/FWWEETTT!!!!
Serious talk at the water cooler!
20 minute penalty cleaning the hippos enclosure with a spatula!
😀
July 9, 2017 at 3:29 pm
FizzBuzz.
Back in my college days BizBuzz was a game involving shot glasses of beer and change of direction in saying Biz, Buzz, BizBuzz, or the number.
Cheating by drinking from your fill bottle usually resulted in ensuing penalties later on as it came around.
Little did I know that a game would evolve into an interview question.
Viewing 15 posts - 59,176 through 59,190 (of 66,738 total)
You must be logged in to reply to this topic. Login to reply