Job Application Test from Hell
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe
A job application test that doesn't reflect a real world problem is an utter waste of time and whoever devised this should be kicked in the balls and repeatedly told to "get real".
“If you want to build a ship, don't drum up people together to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea” - Antoine de Saint-Exupery
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe
SELECT 'look for different job' FROM 'places not full of self serving jerks who wish to prove their supposed superiority' Personally, my experience is that places that serve up such a test are full of jerks who think too highly of themselves. They find great pride in their ability to find questions few can answer, and probably can't produce anything worth having anyway. The number of people who think they are great far exceeds the number who really are great.
-
A job application test that doesn't reflect a real world problem is an utter waste of time and whoever devised this should be kicked in the balls and repeatedly told to "get real".
“If you want to build a ship, don't drum up people together to collect wood and don't assign them tasks and work, but rather teach them to long for the endless immensity of the sea” - Antoine de Saint-Exupery
Well, the one that did reflect a real world problem, probably the only one, was: Given a list of names, identify duplicate names as well as possible misspellings of the same name. I scrawled something about soundex in my answer. This was a written test taken after hours. I had nobody to raise issues with, but plenty of time to really think things through.
-
Yeah, I expect that's the main thing he was to glean from the question.
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
That's a good point Christian. My answer would be in the form of a question asked with the general idea of "What exactly are you trying to accomplish?". I can't imagine a reason for this sort order, as someone else mentioned. Either the order is insignificant, the significance is merely that some user likes it, or the data provided isn't complete and therefore doesn't reveal any logical reason for this order. I know programmers are often stuck with "just do it", but if the customer is open to it, I would prefer to have a discussion of the cost(both present and future) versus the benefit of having it this way (assuming it isn't an incomplete data issue).
-
Is there any sense to that order ?
Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
Fig. 2 Region Contact Durban John Durban Mary Johannesburg Frank Cape Town Anna CapeTown Fred Cape Town Joe The pattern seems pretty simple: 1. Region is reverse alphabetized using the second letter of the word (or maybe 2,3 and 4?), 2. Contact is alphabetized within the Region.
modified on Friday, November 26, 2010 10:50 AM
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe
Haha, i think i found the hidden order... Region are simply ordered by descending their longitude, contacts by the length of their name (descending) then by their fourth letter (ascending). As we know commonly longitudes of theses cities/regions are Cape Town : 18.45° Durban : 30.6° Johannesburg : 27° For the understanding, we suppose we have a table containing longitudes (while in real life we would need -of course- the request to connect to googlemap api to find it) (googlemap find CapeTown and Cape Town same longitude): wtf_region_longitude region longitude Cape Town 18 CapeTown 18 Durban 31 Johannesburg 27 and the table of fig 1: wtf_region_contacts Region Contact Cape Town Fred Cape Town Joe Cape Town Anna Durban John Durban Mary Johannesburg Frank Doing permutation between Joe and Fred, the request is :
select s.region, contact from
(
select c.region,
contact = case contact when 'Joe' then 'Fred' when 'Fred' then 'Joe' else contact end
,contact as ocontact
from wtf_region_contacts c
) s, wtf_region_longitude l
where s.region=l.region
order by longitude desc, LEN(contact) desc, SUBSTRING(contact,4,1) asc--> region contact Durban John Durban Mary Johannesburg Frank Cape Town Anna CapeTown Fred Cape Town Joe Am I right ?
modified on Friday, November 26, 2010 4:30 AM
-
Haha, i think i found the hidden order... Region are simply ordered by descending their longitude, contacts by the length of their name (descending) then by their fourth letter (ascending). As we know commonly longitudes of theses cities/regions are Cape Town : 18.45° Durban : 30.6° Johannesburg : 27° For the understanding, we suppose we have a table containing longitudes (while in real life we would need -of course- the request to connect to googlemap api to find it) (googlemap find CapeTown and Cape Town same longitude): wtf_region_longitude region longitude Cape Town 18 CapeTown 18 Durban 31 Johannesburg 27 and the table of fig 1: wtf_region_contacts Region Contact Cape Town Fred Cape Town Joe Cape Town Anna Durban John Durban Mary Johannesburg Frank Doing permutation between Joe and Fred, the request is :
select s.region, contact from
(
select c.region,
contact = case contact when 'Joe' then 'Fred' when 'Fred' then 'Joe' else contact end
,contact as ocontact
from wtf_region_contacts c
) s, wtf_region_longitude l
where s.region=l.region
order by longitude desc, LEN(contact) desc, SUBSTRING(contact,4,1) asc--> region contact Durban John Durban Mary Johannesburg Frank Cape Town Anna CapeTown Fred Cape Town Joe Am I right ?
modified on Friday, November 26, 2010 4:30 AM
I think your scenario is actually more likely than the real pattern being sorting by the second char of region.
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe
--There is no obvious sort in fig 2l; we have no specific req saying to order using a particular approach...so brute force order it. Obviously this solution wouldn't scale..then again any solution that makes an assumption that there is a scalable way to order it would only be correct by pure luck. Note - pseudocode, might have syntax errors but the basic methodology works select * from fig1 a into #temp01 --dump data into a temp table alter table #temp01 add orderr integer --add a new column update #temp01 set orderr = 1 where region = 'Durban' and Contact = 'John' --populate order info update #temp01 set orderr = 2 where region = 'Durban' and Contact = 'Mary' --populate order info --TODO update orderr for 4 remaining rows select region, contact from #temp01 order by orderr
-
I'm not looking for an answer here, I found my own, but this is quite a hard question. Given the table from Fig.1, write an SQL Select statement that would re-organize the results to look like Fig.2 Fig. 1
Region
Contact
Cape Town
Fred
CapeTown
Joe
Cape Town
Anna
Durban
John
Durban
Mary
Johannesburg
Frank
Fig. 2
Region
Contact
Durban
John
Durban
Mary
Johannesburg
Frank
Cape Town
Anna
CapeTown
Fred
Cape Town
Joe