Two Plus Two Publishing LLC Two Plus Two Publishing LLC
 

Go Back   Two Plus Two Poker Forums > >

Notices

Programming Discussions about computer programming

Reply
 
Thread Tools Display Modes
Old 09-26-2016, 06:01 PM   #151
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 83,617
Re: Interview Test Questions Problems, Solutions, Links, Discussion

I gave DaveT's question as a 1-ish hour take home assignment for a job intervewee for a node position today (we had no way to share screens to whiteboard). He returned it in under and hour... in C#.

Then when I made it clear I wanted the answer in JS - as that's the position he's applying for - all of a sudden his day was too busy for that. Also he had some fun stuff on his resume - like he was working in angular and react in 2014 for a large bank. Riiiiiggght.

So here's his reply. Seems pretty brute force/standard, but at least it works (someone else ran it and confirmed for me). C# experts please weigh in if you want to.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication1
{
   class Program
    {
        static void Main(string[] args)
        {
           
            int[,] arr = new int[,] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 }, { 13, 14, 15, 16 }, { 17, 18, 19, 20 } };
            int rowLength = arr.GetLength(0);
            int colLength = arr.GetLength(1);
            for (int a = 0; a < rowLength; a++)
            {
                for (int b = 0; b < colLength; b++)
                {
                    Console.Write(arr[a, b] + "\t");
                }
                Console.WriteLine();
            }
            Console.WriteLine("Output Is:");
            //Taken m*n matrix 5*4
            int m = rowLength;
            int n = colLength;
            int i; int k = 0; int l = 0;
             m--;
             n--;

            while (k <= m && l <= n)
            {
                // It prints the row left to right up to column length 
                for (i = l; i <= n; ++i)
                {
                    Console.Write(arr[k, i]+" ");
                }

                // Prints the column top to bottom
                k++;
                for (i = k; i <= m; ++i)
                {
                    Console.Write(arr[i, n]+" ");
                }

                // Prints the row right to left
                n--;
                if (m >= k)
                {
                    for (i = n; i >= l; --i)
                    {
                        Console.Write(arr[m, i]+" ");
                    }
                    m--;
                }

                // Prints the column bottom to top
                for (i = m; i >= k; --i)
                {
                    Console.Write(arr[i, l] + " ");
                }

                l++;
            }

            Console.ReadLine();
        }

    }
}
I grilled him a little about how he'd do it in JS and he just mumbled some buzzwords. I specifically asked him what built in JS array functions he might use to reduce code complexity, and he had nothing.

jquery came up a lot in his interview, so I think he at least knows his way around that. Oh yeah - also he couldn't name the server they run JSPs on at his last job. Like he didn't seem to know what a webserver is. So yeah that plus no JS = GREAT candidate for node job.

Also he said they were using stored procedures over C++ to access mongodb from node. I guess it's theoretically possible someone wrote some weird-ass stored proc simulator. Any attempts to drill down further were just met with buzzwords like "single-threaded" and "highly-scalable".

Now maybe you guys understand why we take anyone with a hint of being a good programmer. Otherwise you're just interviewing people like this until the end of time.

Last edited by suzzer99; 09-26-2016 at 06:07 PM.
suzzer99 is offline   Reply With Quote
Old 09-26-2016, 10:22 PM   #152
candybar
old hand
 
Join Date: Aug 2011
Posts: 1,756
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by suzzer99 View Post
I gave DaveT's question as a 1-ish hour take home assignment for a job intervewee for a node position today (we had no way to share screens to whiteboard). He returned it in under and hour... in C#.
I don't think he wrote this himself btw. It looks like a vague copy of this:

http://www.geeksforgeeks.org/print-a...n-spiral-form/

I would try to avoid giving known algorithm problems in a takehome assignment for this reason.
candybar is offline   Reply With Quote
Old 09-26-2016, 11:21 PM   #153
Barrin6
Carpal \'Tunnel
 
Barrin6's Avatar
 
Join Date: Dec 2005
Location: beyond legal blindness
Posts: 6,657
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Funny, I was working on the spiral problem today.

Here my code. Started off writing it in google doc. Submitted to leetcode but then my solution wasn't working when the column or row were equal to 1. So I had to add some weird checker as the base case...

I'm not exactly proud of this. Going to look at geeksforgeeks.

Code:
class Solution {
public:
    vector<int> spiralOrder(vector<vector<int>>& matrix) {
       
        vector<int> answer;

        if (matrix.empty()) return answer;

        recurse(matrix, 0, 0 , matrix[0].size(), matrix.size(), answer);
        return answer;

    }

   void recurse(const vector<vector<int>> &matrix, int row, int col, int cLen, int rLen, vector<int>& answer) {
                if (cLen <= 0 || rLen <= 0) return;
                
                if (cLen == 1) {
                    for (int r = row; r < row + rLen; r++) {
                        answer.push_back(matrix[r][col]);
                    }
                    
                    return ;
                }
                
                if (rLen == 1) {
                    for (int c = col; c < col + cLen; c++) {
                        answer.push_back(matrix[row][c]);
                    }
                    
                    return ;
                }

               //go full length across      
                for (int c = col; c < col + cLen; c++)
                answer.push_back(matrix[row][c]);

              //go row+1 downto rLen + row
              for (int r = row + 1; r < row + rLen; ++r)
                  answer.push_back(matrix[r][col + cLen - 1]);

             //go last col - 1 down to col
             for (int c = col + cLen - 2; c >= col; --c)
                  answer.push_back(matrix[row+rLen -1][c]);

            //go last row - 1 up to row + 1
             for (int r = row + rLen - 2; r >= row + 1; r--)
                   answer.push_back(matrix[r][col]);

            recurse(matrix, row + 1, col + 1, cLen - 2, rLen - 2, answer);           
   }
};
Barrin6 is offline   Reply With Quote
Old 09-27-2016, 12:05 AM   #154
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 83,617
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by candybar View Post
I don't think he wrote this himself btw. It looks like a vague copy of this:

http://www.geeksforgeeks.org/print-a...n-spiral-form/

I would try to avoid giving known algorithm problems in a takehome assignment for this reason.
Sheesh. What a putz. Now he's begging for a job over email.
suzzer99 is offline   Reply With Quote
Old 09-27-2016, 12:38 AM   #155
Barrin6
Carpal \'Tunnel
 
Barrin6's Avatar
 
Join Date: Dec 2005
Location: beyond legal blindness
Posts: 6,657
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Also if you can't screen share you should do a google doc and just be over the phone. Having the candidate write something up and have him/her not show you the thought process makes it kind of useless.
Barrin6 is offline   Reply With Quote
Old 09-27-2016, 12:42 AM   #156
suzzer99
Carpal \'Tunnel
 
suzzer99's Avatar
 
Join Date: Nov 2005
Location: on top of the bell curve
Posts: 83,617
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Well the idea was to have him explain the thought process, but yeah if these ****ers are going to cheat. Wasn't my department or anything, I just got pulled in as the node expert. People just call me with node stuff and I try to help them. I have no idea who anyone is or even if it's in my job description to help them.
suzzer99 is offline   Reply With Quote
Old 09-27-2016, 06:41 AM   #157
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 21,935
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Suzzer, you can use this:

https://coderpad.io/

There are quite a few alternatives as well,

My knowledge of C# has waned a bit, but that's clearly hot garbage. Why do you need Linq (an SQL / data lib) or any of the other libs to do this?
daveT is offline   Reply With Quote
Old 09-27-2016, 10:12 AM   #158
Victor
Carpal \'Tunnel
 
Victor's Avatar
 
Join Date: Jul 2003
Posts: 58,089
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by suzzer99 View Post
Sheesh. What a putz. Now he's begging for a job over email.
i dunno, something to be said for resourcefulness and persistence. he seems like he has promise.

btw, that c# code should yield the right results. though, its not nearly as cool as some of the other submissions itt. ofc, I have no clue wtf is going in candybars and it took me a bit figure out wtf that gaming mouse ramda thing was.
Victor is offline   Reply With Quote
Old 09-27-2016, 12:28 PM   #159
candybar
old hand
 
Join Date: Aug 2011
Posts: 1,756
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by daveT View Post
My knowledge of C# has waned a bit, but that's clearly hot garbage. Why do you need Linq (an SQL / data lib) or any of the other libs to do this?
I think that's what VS spits out when you create a new class. I don't bother removing that either.
candybar is offline   Reply With Quote
Old 09-27-2016, 04:03 PM   #160
Prickly Pear
enthusiast
 
Prickly Pear's Avatar
 
Join Date: Aug 2016
Posts: 60
Re: Interview Test Questions Problems, Solutions, Links, Discussion

https://www.hackerrank.com/challenges/new-year-chaos

I'm curious what people think of this question.

Spoiler:
Prickly Pear is offline   Reply With Quote
Old 09-28-2016, 06:20 PM   #161
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,265
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by Prickly Pear View Post
https://www.hackerrank.com/challenges/new-year-chaos

I'm curious what people think of this question.
I haven't actually tried it but I have an approach in mind, that I expect would be O(n) and not too hard to implement. It might actually only be a few lines of python. I am ****ing swamped but if I get some free time I might try it.
RustyBrooks is online now   Reply With Quote
Old 09-28-2016, 06:23 PM   #162
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,265
Re: Interview Test Questions Problems, Solutions, Links, Discussion

But, I think you need to stipulate that there's no bribe-backs. Consider the case where you start with
1 2 3
and 3 bribes 2, now you have
1 3 2
and now 2 bribes 3, now you have
1 2 3

Which means that given the string 1 2 3 you could have 0, 2 or 4 swaps (I think those are the only possible ones for 3 people)

If there's no swapbacks then I think it should be straight forward.
RustyBrooks is online now   Reply With Quote
Old 09-28-2016, 06:57 PM   #163
gaming_mouse
Carpal \'Tunnel
 
gaming_mouse's Avatar
 
Join Date: Oct 2004
Location: taking notes on u (see profile)
Posts: 13,767
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by RustyBrooks View Post
But, I think you need to stipulate that there's no bribe-backs. Consider the case where you start with
1 2 3
and 3 bribes 2, now you have
1 3 2
and now 2 bribes 3, now you have
1 2 3

Which means that given the string 1 2 3 you could have 0, 2 or 4 swaps (I think those are the only possible ones for 3 people)

If there's no swapbacks then I think it should be straight forward.
but it's asking for the min number, so it would be 0 in that case
gaming_mouse is offline   Reply With Quote
Old 09-28-2016, 08:32 PM   #164
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,265
Re: Interview Test Questions Problems, Solutions, Links, Discussion

OK it does say minimum, so, never mind.

My algorithm does not work if there are swaps back in the other direction. If I have some time I'll try to look at it soon.
RustyBrooks is online now   Reply With Quote
Old 09-29-2016, 10:18 PM   #165
Sholar
Carpal \'Tunnel
 
Sholar's Avatar
 
Join Date: Jul 2007
Posts: 6,341
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Pretty good interview question, I think.
Spoiler:
Sholar is offline   Reply With Quote
Old 09-30-2016, 02:54 AM   #166
Barrin6
Carpal \'Tunnel
 
Barrin6's Avatar
 
Join Date: Dec 2005
Location: beyond legal blindness
Posts: 6,657
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Had my Boogle phone interview today. Not sure how I feel about the interview. But so far I haven't got a rejection yet so that's good. Spent a lot of time on big O analysis over one simple problem and many different approaches.
Barrin6 is offline   Reply With Quote
Old 09-30-2016, 04:07 AM   #167
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 21,935
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by Prickly Pear View Post
https://www.hackerrank.com/challenges/new-year-chaos

I'm curious what people think of this question.
Spoiler:
daveT is offline   Reply With Quote
Old 09-30-2016, 08:02 AM   #168
Sholar
Carpal \'Tunnel
 
Sholar's Avatar
 
Join Date: Jul 2007
Posts: 6,341
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by daveT View Post
Spoiler:
Spoiler:
Sholar is offline   Reply With Quote
Old 09-30-2016, 10:14 AM   #169
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 21,935
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Is this what you are attempting to describe?

Spoiler:
daveT is offline   Reply With Quote
Old 09-30-2016, 10:22 AM   #170
Sholar
Carpal \'Tunnel
 
Sholar's Avatar
 
Join Date: Jul 2007
Posts: 6,341
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Spoiler:
Sholar is offline   Reply With Quote
Old 09-30-2016, 10:23 AM   #171
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 21,935
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Then I have to say that's a pretty darn good interview question.
daveT is offline   Reply With Quote
Old 09-30-2016, 10:53 AM   #172
Sholar
Carpal \'Tunnel
 
Sholar's Avatar
 
Join Date: Jul 2007
Posts: 6,341
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Agreed. There's one other thing that I like about this one:
Spoiler:
Sholar is offline   Reply With Quote
Old 09-30-2016, 12:06 PM   #173
RustyBrooks
Carpal \'Tunnel
 
RustyBrooks's Avatar
 
Join Date: Feb 2006
Location: Austin, TX
Posts: 23,265
Re: Interview Test Questions Problems, Solutions, Links, Discussion

I think if you're going to ask this question in an interview you need to have a hint ready, because I don't think I'd have come up with this on my feet. Or, I guess maybe I should accept that you wouldn't hire me.
RustyBrooks is online now   Reply With Quote
Old 09-30-2016, 12:18 PM   #174
Prickly Pear
enthusiast
 
Prickly Pear's Avatar
 
Join Date: Aug 2016
Posts: 60
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by daveT View Post
Spoiler:
Spoiler:
Prickly Pear is offline   Reply With Quote
Old 10-01-2016, 04:14 AM   #175
daveT
S.A.G.E. Master
 
daveT's Avatar
 
Join Date: Jun 2005
Location: Why didn't I use Clojure instead?
Posts: 21,935
Re: Interview Test Questions Problems, Solutions, Links, Discussion

Quote:
Originally Posted by RustyBrooks View Post
I think if you're going to ask this question in an interview you need to have a hint ready, because I don't think I'd have come up with this on my feet. Or, I guess maybe I should accept that you wouldn't hire me.
Yeah, give me matrices and I'm stumped. Give a strange recursion puzzler and I'll get to the answer eventually. I know damn well there are tons of algorithms that you'd destroy me on in an instant, but with a question like this, I'd definitely have hints.

Quote:
Originally Posted by Prickly Pear View Post
Spoiler:
Spoiler:
daveT is offline   Reply With Quote

Reply
      

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Forum Jump


All times are GMT -4. The time now is 12:56 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © 2008-2017, Two Plus Two Interactive
 
 
Poker Players - Streaming Live Online