5 ms·
Define "actually program". What are you evaluating them on? Leetcode?
by leetrout 2y ago
Define "actually program".
What are you evaluating them on? Leetcode?
- geraldwhen 2y agoSimple test. I’d say half struggle to declare a variable. Maybe 1/4 can get a class to compile. 1/6 can get code to run. 1/20 can get code to run and maybe start to solve the problem.
- leetrout 2y agoI am very curious if it is actually simple or not. I've had some "easy" interview questions that are pure CS trivia. But this and your other comments make it sound practical... can you just post it?
- HeyLaughingBoy 2y agoGiven a 10x10 array filled with numbers. For a given (x,y) starting point, search the 3x3 grid starting with that point as its upper left corner and indicate if it contains a particular number. Ignore error conditions such as running off the edge of the array. I estimate that 80% of candidates could not accomplish this in an hour. 50% of them could not even get out of the gate.
- em-bee 2y agothis? array data = (array(int))random_string(100)/10; int x = random(10); int y = random(10); int seek = random(255); int findgrid(array data, int x, int y, int seek){ for(int i=0;i<=2;i++){ for(int j=0;j<=2;j++){ write("%d:%d\n", data[x+i][y+j], data[x+i][y+j]==seek); if(data[x+i][y+j]==seek){ return true; } } } } took me 15 minutes, and only because i am tired and took a break in between. i can't imagine anyone calling themselves programmer not being able to do that. 80%? hard to believe it's that bad.
- 6510 2y agocouldn't help myself, I think 3-5 min grid = [ [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0], [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] ] foo = function(x,y,num){ if (grid[x][y] == num) return true; if (grid[x+1] && grid[x+1][y] == num) return true; if (grid[x+2] && grid[x+2][y] == num) return true; if (grid[y+1]){ if (grid[x][y + 1] == num) return true; if (grid[x+1] && grid[x+1][y+1] == num) return true; if (grid[x+2] && grid[x+2][y+1] == num) return true; } if (grid[y+2]){ if (grid[x][y+2] == num) return true; if (grid[x+1] && grid[x+1][y+2] == num) return true; if (grid[x+2] && grid[x+2][y+2] == num) return true; } return false; } alert(foo(1,2,3)); alert(foo(1,2,30)); humm worked first try, probably something wrong with it.. https://jsfiddle.net/ycx159kg/ https://jsfiddle.net/ycx159kg/ 13 min later... round2 = function(x,y,num){ return grid.slice(x,x+3).map(g=>g.slice(y,y+3)).flat().includes(num); }
- HeyLaughingBoy 2y agoAnd that reminded me that some people were nervous about doing the nested loop solution so asked if they could "brute force" it and we would accept that. Interview stress is a thing after all. I'm intrigued by the slice/map solution. It would have been perfectly acceptable if you could explain what the functions did. In fact, it would have led to very probing conversations: my usual interview partner and me had a deep interest in elegant solutions.
- 6510 2y agogrid.slice(x,x+3) Turns the 10x10 array into a 3x10 discarding the rows before and after the target rows. If the second value in slice is larger than the length it slices to the end. It could be a 2x10 or 1x10 but lets pretend it is 3. .map(g=>g.slice(y,y+3)) Does the same with each row making it into a 3x3 (or 2x3 or 1x1 etc) .flat() Turns the 3x3 into a flat array of up to 9 values. .includes(num) tests if the flat sliced array include num.
- kcartlidge 2y agoOut of curiosity, here's a bit of C# to do it. This randomly populates a 10x10 grid then looks for a random target in a randomly located 3x3 sub-grid. As per the question I've ignored error conditions, but using the simple expedient in this case of positioning the 3x3's top left within the first 8x8 not the full 10x10. Example output is underneath. // Make and fill the grid. var r = new Random(); var grid = new int[10, 10]; for (var y = 0; y < 10; y++) for (var x = 0; x < 10; x++) grid[x, y] = r.Next(10); // Draw the grid for reference. Console.WriteLine(); Console.WriteLine(" 0 1 2 3 4 5 6 7 8 9"); Console.WriteLine(); for (var y = 0; y < 10; y++) { Console.Write($"{y} "); for (var x = 0; x < 10; x++) Console.Write(grid[x, y] + " "); Console.WriteLine(); } Console.WriteLine(); // Random starting point and target. var tlx = r.Next(8); var tly = r.Next(8); var target = r.Next(10); // Extract the 3x3 sub-grid and "[ ]" any matches. Console.WriteLine($"Looking for {target} in 3x3 grid at {tlx},{tly}"); Console.WriteLine(); for (var dy = 0; dy < 3; dy++) { for (var dx = 0; dx < 3; dx++) { var ax = tlx + dx; var ay = tly + dy; var v = grid[ax, ay]; if (v == target) Console.Write($"[{v}]"); else Console.Write($" {v} "); } Console.WriteLine(); } Console.WriteLine(); Example output: 0 1 2 3 4 5 6 7 8 9 0 1 2 5 4 1 8 0 2 8 5 1 4 2 2 5 8 4 4 0 4 8 2 7 1 8 2 5 6 3 6 3 6 3 8 7 3 2 4 6 5 9 6 2 4 6 3 4 2 9 7 4 7 6 1 5 1 4 2 3 8 3 2 4 3 3 6 0 6 6 5 1 4 7 3 4 9 7 2 0 6 9 9 9 3 9 1 7 8 1 6 5 8 3 8 9 8 3 4 9 0 8 7 9 5 4 0 7 0 3 Looking for 5 in 3x3 grid at 2,6 6 [5] 1 6 9 9 [5] 8 3 As others have said elsewhere this could use a one-dimensional array but as we know upfront what the constraints are I've gone for the clarity of the two-dimensional. This is said to be the very first mistake everyone makes in graphics programming - but nothing in the question says it is for use in graphics, so being an interview question I went for clarity. Similarly there's the possible use of a ternary, less memory allocation, and tighter code, but again in this situation I'd go for readability. There may also be edge cases not covered; this was a 10 minute hack (as it looked fun) and isn't exhaustively tested.
- deadbabe 2y agoSimple assignments that should be doable without using google or any external sources. Just fire up an IDE and solve a problem while someone watches. So many fail.
- digitalsushi 2y agoI'd fail 90% of tech interviews on the spot if I had to fire up your IDE, instead of firing up a white board and an expo2
- deadbabe 2y agoAnd that’s why we don’t hire people that are like that. We need to hire people who are comfortable being uncomfortable, and can think on their own rather than just pull down answers from other places and massage them to fit whatever problem their solving.
- deleted 2y ago[deleted]
- wruza 2y agoWhat is the sign that one knows his job? He comes dressed for it and with his own toolkit. You seem to be testing for proficiency in slow NIH-tendencies basically, but since discomfort is a requirement, maybe that works for you and for them too.
- dymk 2y agoIf you can't fire up an IDE and write code, you probably should fail that interview
- seadan83 2y agoIIRC, Joel's thesis was could not program anything. I believe his example was fizzbuzz, and he stated an absurd number of people could not do that in an hour
- vidarh 2y agoThe level of tests I've seen many places includes stuff like reversing a string, or if you want to be fancy, reversing words within a string. It takes shockingly little to filter out a lot of people, and I'd argue that often you want it to be at a really stupidly low level for a first pass, even when using tests they surely must have seen before.
- LoganDark 2y agoReversing the order of the words, or the order of the characters within each word?
- vidarh 2y agoEvery variant is fine. It's really the kind of thing you do for the most basic possible filter. The point isn't so much what they do, as whether they're able to produce any working code more advanced than Hello World. But it's also then possible to make use of "one step up" by asking people for variations and seeing whether they can talk about tradeoffs (still at a very basic level, but still). E.g. in a higher level language, if asked to reverse the order of the words you often get variations of split on space, reverse the resulting array, join. In which case you have an opening to ask them if they can do it lower level, in minimal space. In which case, the "typical" solution becomes to reverse the string in place, then iterate and find the start of each word, and reverse that in place. Both reverse operations need at most two pointers and a temporary, and can be done with the same function if you take in a start and end pointer. If you have that helper to reverse a given character range in place, reversing the order of the characters within each word without reversing the word order is just the same thing without reversing the whole string first.
- all2 2y ago
- dymk 2y agoAt least half the candidates I interview cannot figure out how to basically split a string. They all have years of SWE experience on their resumes.
- NhanH 2y agoWhat was your question? Is it “please split a string by whitespace”, and do you accept s.split() as a correct answer? One google interviewers ask me a question that starts with “implement google search” and ends with my implementing splitting a paragraph. Of course I failed the interview, but I have to think he has failed me way before we get to write any code.
- dymk 2y agoI'd rather not post too many details about the particular question, but it's only slightly more complex than String#split. It has multiple valid solutions, from regex matching to for/while/do&while loops to String#substring. If you have even a basic understanding of your language of choice's standard library, at least one solution is obvious and implementable within minutes. I'd say about half of the candidates that interview are unfamiliar with the String#substring equivalent of their language. This is for a senior position, and everyone has multiple years of experience on their resume. It's... interesting.
- NhanH 2y agoMy point is: are you sure the candidates failed because of their programming ability (unable to use substring), or was they confused due to the question itself? It is very easy to get to the situation in a interview where the candidate is just straight up unsure on what the question is about. The candidate might fumble not because of not understanding #substring, but rather whether you would accept it as an answer. Many people would say those candidates should be failed anyway due to X, Y, Z reasons. But I want to highlight that in those cases, the interviewers should realize they are assessing something else, and not programming skill.