I was browsing SO careers and came across a job that had a pdf with a couple of puzzles they wanted applicants to send in.
Although I'm not interested in the job, I read the questions anyway and had a play in Visual Studio / SMSS. The first question was fairly easy to solve although I couldn't think if any way to optimise it (I solved it in C#). The second puzzle only one obvious solution strikes me and I can't think of any others.
I'm not sure if it's bad to discuss these questions here though, but if anyone can give me some hints or perhaps suggest somewhere where I can ask this without creating any grief it'd be appreciated.
The questions are in here: http://www.debtx.com/doc/DebtX_Programming_Problems.pdf
I could let the first one slide but the second one has me stumped on other ways of solving it than the obvious. Shame there's no PM function on SO...
Boilerplate solution for the first part C#:
public static bool Compare(int[] num, int[] div)
{
for (int i = 0; i < num.Length; i++)
{
for (int j = 0; j < div.Length; j++)
{
if (num[i] % div[j] == 0)
return true;
}
}
return false;
}
My SQL Solutions
select Table1.Key1, Table1.Key2 from Table1 inner join Table2 on Table1.Key1 = Table2.key2 where IsDeleted=0
select * from Table1 where key1 in(select Key2 from Table2 where IsDeleted=0)
It all seems so samey though