|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On November 30 2017 03:35 sc-darkness wrote: Do you guys fail logic tests and/or programming tests which ask you to write code which you're unlikely to use at work/in real life? For example, I was told to write code for an MxM matrix. It's artificially split into layers. Here's an example:
1 1 1 1 1 2 2 1 1 1 1 1
Outer layer starts with one. The deeper you dig the higher the number which is 2 in this case. Matrix can be from 1x1 to 9x9 or 100x100. I can't remember exactly. I had to take matrix input and validate if each layer has the expected number.
Also, if you have 1x1 and 2x2 matrix, then they only have an outer layer.
Overall test had to take 1 hour and 30 minutes. It was split into 3 categories - logic questions, SQL questions (8.6/9.0 here) and 2 programming questions. I just think this matrix stuff alone is so time-consuming that it will fuck up your remaining time anyway. Or, is it just me who is being silly?
Personally, it was very easy for me to understand what this matrix question was about. Programming isn't my weakness overall, but coming up with an algorithm/helper functions to check inner layers proved to be the more difficult task. Do you have any suggestions what to read/do so I can become better at tricky stuff like that?
Your example doesn't correspond to the problem, it's not a square. And this seems trivial with recursivity, the matrix is correct if and only if the outer layer has the right numbers and the inner matrix is correct.
|
On November 30 2017 04:20 Liebig wrote:Show nested quote +On November 30 2017 03:35 sc-darkness wrote: Do you guys fail logic tests and/or programming tests which ask you to write code which you're unlikely to use at work/in real life? For example, I was told to write code for an MxM matrix. It's artificially split into layers. Here's an example:
1 1 1 1 1 2 2 1 1 1 1 1
Outer layer starts with one. The deeper you dig the higher the number which is 2 in this case. Matrix can be from 1x1 to 9x9 or 100x100. I can't remember exactly. I had to take matrix input and validate if each layer has the expected number.
Also, if you have 1x1 and 2x2 matrix, then they only have an outer layer.
Overall test had to take 1 hour and 30 minutes. It was split into 3 categories - logic questions, SQL questions (8.6/9.0 here) and 2 programming questions. I just think this matrix stuff alone is so time-consuming that it will fuck up your remaining time anyway. Or, is it just me who is being silly?
Personally, it was very easy for me to understand what this matrix question was about. Programming isn't my weakness overall, but coming up with an algorithm/helper functions to check inner layers proved to be the more difficult task. Do you have any suggestions what to read/do so I can become better at tricky stuff like that? Your example doesn't correspond to the problem, it's not a square. And this seems trivial with recursivity, the matrix is correct if and only if the outer layer has the right numbers and the inner matrix is correct.
Yes, apologies.
It's
1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1
How would you do it with recursion?
Edit: I think I see what you mean. Do you mean you can break each matrix into a smaller one and validate it? There would only be one validation method to do this.
|
On November 30 2017 04:23 sc-darkness wrote:Show nested quote +On November 30 2017 04:20 Liebig wrote:On November 30 2017 03:35 sc-darkness wrote: Do you guys fail logic tests and/or programming tests which ask you to write code which you're unlikely to use at work/in real life? For example, I was told to write code for an MxM matrix. It's artificially split into layers. Here's an example:
1 1 1 1 1 2 2 1 1 1 1 1
Outer layer starts with one. The deeper you dig the higher the number which is 2 in this case. Matrix can be from 1x1 to 9x9 or 100x100. I can't remember exactly. I had to take matrix input and validate if each layer has the expected number.
Also, if you have 1x1 and 2x2 matrix, then they only have an outer layer.
Overall test had to take 1 hour and 30 minutes. It was split into 3 categories - logic questions, SQL questions (8.6/9.0 here) and 2 programming questions. I just think this matrix stuff alone is so time-consuming that it will fuck up your remaining time anyway. Or, is it just me who is being silly?
Personally, it was very easy for me to understand what this matrix question was about. Programming isn't my weakness overall, but coming up with an algorithm/helper functions to check inner layers proved to be the more difficult task. Do you have any suggestions what to read/do so I can become better at tricky stuff like that? Your example doesn't correspond to the problem, it's not a square. And this seems trivial with recursivity, the matrix is correct if and only if the outer layer has the right numbers and the inner matrix is correct. Yes, apologies. It's 1 1 1 1 1 2 2 1 1 2 2 1 1 1 1 1
How would you do it with recursion?
In kinda pseudo code:
Suppose you have a function check_outer(m, i, j, l, k) that takes the big matrix m, the position of the top left corner (i, j) of the inner matrix of size l and checks that the outer layer of that inner matrix is k and returns true if it is so and false otherwise
Now to check the whole matrix, you just define
check_matrix_aux(m, i, j, l, k) = if l <= 2 then check_outer(m, i, j, l, k) else if check_outer(m, i, j, l, k) then check_matrix_aux(m,i+1,j+1,l-1,k+1) else false
and finally check_matrix(m) = check_matrix_aux(m,0,0, length m, 1)
edit: i'm assuming a matrix is an array of arrays
|
So it's simply a matter of iterating in the correct pattern. (and in this case, incrementing some sort of value that you assign to the matrix indices).
I actually just did something just like this in another program I was doing.
Here is a modified version of the code I used: + Show Spoiler + Inc_i = 0 Inc_j = 0 count = 1
while Inc_i < (row-length) and Inc_j < (row length): for j in xrange((row length) - Inc_j): YourArray[count][j + count] = count #go from top left to top right Inc_i = Inc_i + 1 for i in xrange((row length) - Inc_i): YourArray[i + count][(row length) - count] = count #go from top right to bottom right Inc_j = Inc_j + 1 for j in xrange((row length) - Inc_j): YourArray[(row length) - count][(row length) - count - j] = count #bottom right to bottom left Inc_i = Inc_i + 1 for i in xrange((row length) - Inc_i): YourArray[(row length ) - count - i][count] = count #bottom left to top right count = count + 1
|
|
A bit for my algorithms class.
|
That book is called CLR(S), it is the canonical algorithms text. If you are going to read one algorithms book, that is the one to read.
|
On November 29 2017 17:54 Silvanel wrote:Show nested quote +On November 29 2017 15:25 phar wrote:On November 29 2017 08:09 Blitzkrieg0 wrote:On November 29 2017 08:05 Excludos wrote:On November 29 2017 07:26 Blitzkrieg0 wrote:On November 29 2017 07:15 Excludos wrote: You can't expect someone to know of every possible scenario they might come across. And if you can't test for that, all you can really test for is a super easy fizzbuzz function, which tells you exactly nothing about a person beyond "He does indeed know what a for loop is". You keep harping on this, but that is exactly what we're testing for. What percentage of candidates do you think we interview that can not write fizzbuzz? We do this for our interns and our entry/newgrad level positions. Exactly what kind of education do you guys have? In Norway computer science is an engineering degree on the same line as electrical engineer, biochemistry or machine engineers. It requires semi decent grades and quite a bit of math, physics, a bit of chemistry, and a few other general subjects. A for-loop is literally what you learn at first week, and you finish the third year by spending the last 6 months programming a fully functioning program and a full thesis to go along with it. I would have suspected that most of the world operates like this? If so there is simply no way you don't know how to do extremely basic things like a loop after graduating. I thought the same thing until I interviewed people who couldn't write fizzbuzz with cs degrees. Yea anyone telling you fizz buzz style questions aren't necessary has not done enough interviews, or is at a tiny company that can be very picky about who they interview (or is unaware of a pipeline in front of them that is filtering for people who can't do fizz buzz). Thats not necessarily true. Different companies have different recruiting schemes. For example in my company most people are either recommended by present employees or found by headhunters. Then HR vet them for their experience, salary expectation and etc. And only after that they have interview with technical staff. We dont ask fizzbuzz questions at any point. Even for junior positions. For junior testers You get some (simple) program and requirements are told to find as many bugs as possible. For junior developers there are some simple tasks/questions depending on the technology but no fizzbuzz. And besides tasks there is always a converastion. Every candidate gets hhis chance. And we are by no means small company. Granted they might do things differently in other locations, but thats how it is done in our polish location. I do get what You are saying, there are tech companies in my town that do things this way. They invite a hell lot of people throw fizzbuzz/lanaguage standarized tests at them and invite selct few with best results to interview. You can do things this way. But it is not the only way. Sure yea, it's a matter of numbers. Your company sounds like it falls into the third category I mentioned - a pipeline that does most of the work for you (referrals and some headhunters), and possibly a bit of the first category (small) if you can rely on *only* referrals and some headhunters. But as soon as you open the floodgates and have a million applicants, a significant fraction of whom will be... less than honest... about their programming skills, you're gonna be kicking yourself for not checking basic (and I mean *basic*) ability first through some cheap hopefully-automated fashion.
|
On November 30 2017 12:11 phar wrote:That book is called CLR(S), it is the canonical algorithms text. If you are going to read one algorithms book, that is the one to read. It's like a Christian asking if the Bible is a good read
|
On November 30 2017 12:19 phar wrote:Show nested quote +On November 29 2017 17:54 Silvanel wrote:On November 29 2017 15:25 phar wrote:On November 29 2017 08:09 Blitzkrieg0 wrote:On November 29 2017 08:05 Excludos wrote:On November 29 2017 07:26 Blitzkrieg0 wrote:On November 29 2017 07:15 Excludos wrote: You can't expect someone to know of every possible scenario they might come across. And if you can't test for that, all you can really test for is a super easy fizzbuzz function, which tells you exactly nothing about a person beyond "He does indeed know what a for loop is". You keep harping on this, but that is exactly what we're testing for. What percentage of candidates do you think we interview that can not write fizzbuzz? We do this for our interns and our entry/newgrad level positions. Exactly what kind of education do you guys have? In Norway computer science is an engineering degree on the same line as electrical engineer, biochemistry or machine engineers. It requires semi decent grades and quite a bit of math, physics, a bit of chemistry, and a few other general subjects. A for-loop is literally what you learn at first week, and you finish the third year by spending the last 6 months programming a fully functioning program and a full thesis to go along with it. I would have suspected that most of the world operates like this? If so there is simply no way you don't know how to do extremely basic things like a loop after graduating. I thought the same thing until I interviewed people who couldn't write fizzbuzz with cs degrees. Yea anyone telling you fizz buzz style questions aren't necessary has not done enough interviews, or is at a tiny company that can be very picky about who they interview (or is unaware of a pipeline in front of them that is filtering for people who can't do fizz buzz). Thats not necessarily true. Different companies have different recruiting schemes. For example in my company most people are either recommended by present employees or found by headhunters. Then HR vet them for their experience, salary expectation and etc. And only after that they have interview with technical staff. We dont ask fizzbuzz questions at any point. Even for junior positions. For junior testers You get some (simple) program and requirements are told to find as many bugs as possible. For junior developers there are some simple tasks/questions depending on the technology but no fizzbuzz. And besides tasks there is always a converastion. Every candidate gets hhis chance. And we are by no means small company. Granted they might do things differently in other locations, but thats how it is done in our polish location. I do get what You are saying, there are tech companies in my town that do things this way. They invite a hell lot of people throw fizzbuzz/lanaguage standarized tests at them and invite selct few with best results to interview. You can do things this way. But it is not the only way. Sure yea, it's a matter of numbers. Your company sounds like it falls into the third category I mentioned - a pipeline that does most of the work for you (referrals and some headhunters), and possibly a bit of the first category (small) if you can rely on *only* referrals and some headhunters. But as soon as you open the floodgates and have a million applicants, a significant fraction of whom will be... less than honest... about their programming skills, you're gonna be kicking yourself for not checking basic (and I mean *basic*) ability first through some cheap hopefully-automated fashion. I've seen the the exact opposite happen as well, that companies will overvalue how exceptional they are and end up with completely overqualified people (if anyone at all) filling positions with skillsets that could be taught entirely on-the-job, and likely still will be.
And those positions end up empty again in less than a year.
|
Lot of places (in)famous for that, true. The only way you hang on to people there is if you pay them like half a mil a year or w/e lol.
|
My company has around 26000 employees dunno if its is large or small for You. Granted the recruiting scheme is different depending on location (so can be different say in German, USA or in India and i would say it most certainly is). Still it works fine for our location i think (Poland). The project i work currently in has around 600 engineers spread around the globe. For sure some of them are overqualified for their postion, some underqualified and some are exactly where they need to be. But i would say its more because of the size than recruiting scheme.
|
Hi guys,
Lets say we have the following: I'm accessing 3 huge XML file via HTTP (Each file about 200,000 node). However, via URL, I can determine how many nodes returned each time and from what starting point (rows=5000&start=0, "rows" determine how rows returned and "start" determines from what node to start fetching nodes)
I'm writing a Java code that will compare these files and determine if they are all equal or not.
What is the best way to do this? Do I write these 3 files locally and compare them? Or do I store portions using DocumentBuilder and Document and compare each iteration (lets say each iteration about 5000 node/record).
|
|
|
Every fall as it nears finals time I manage to get distracted by furiously trying to come up with solutions to the travelling salesman problem. I'm talking like, 14 hour days spent deep in thought. Coincidence, or tactic to avoid responsibility?
|
On November 30 2017 21:32 travis wrote: Every fall as it nears finals time I manage to get distracted by furiously trying to come up with solutions to the travelling salesman problem. I'm talking like, 14 hour days spent deep in thought. Coincidence, or tactic to avoid responsibility?
Traveling Salesman is one of the prime examples for problems that are not economicly solveable via exhaustive enumeration and a great problem for genetic algorithms which search for a "good enough" solution rather than the best.
|
Dumb question:
I have a stupid problem where I have to correct a whole load of stuff. And it's going to be fastest to do this with a long list of radio buttons where I can mark "right" "half right" or "wrong". However, I don't know exactly how many radio buttons I need beforehand because it's loaded dynamically from the database.
I have my code for loading this stuff in python, but wtf do I use to generate the UI? I was looking at guidata, but it seems to want a fixed number of items up front, rather than being able to add them at runtime.
Am I incredibly stupid to think a simple and fast way of doing this is by simply generating a webpage, hosting it with flask and then saving the answers back into the database on a form submission?
|
I guess a really fast hack could be a GUI presenting 3 radio buttons and 'back'/'next' buttons to navigate between questions.
|
On November 30 2017 21:32 travis wrote: Every fall as it nears finals time I manage to get distracted by furiously trying to come up with solutions to the travelling salesman problem. I'm talking like, 14 hour days spent deep in thought. Coincidence, or tactic to avoid responsibility?
My current problem at work is not too different from the travelling salesman: Calculating the cheapest possible shopping cart given a set of multiple discount rules.
Multiple discounts can apply to each item in different order. Some discounts do not allow for other discounts. Some discounts only apply to multiples of a mixed set of items (e.g. two mattresses, either the same or different, for a set price). Some discounts apply to products that already have a reduced price, some don't, but if they don't and the discount is cheaper than the reduced price, then they apply and the reduced price doesn't.
I started that task thinking I could just use a prioritized list, apply discount A, apply discount B, then check for each exclusive discount whether it would be better, ... but eventually I got stuck, because all discounts essentially needed to know about all other discounts. The logic grew too much, trying to solve cases where the distinct items A, B and C all could be in an exclusive set that only applied to sets of two items but also had one or more potential non-exclusive discounts. Depending on the non-exclusive discounts, (AB)C could be cheaper than A(BC) or (AC)B or the set might even be more expensive than using the non-exclusive discounts for all three.
I eventually decided that it looks more like a graph problem and refactored it to recursively go through all possible iterations of cart positions and discounts, trying to find the cheapest path. The logic looks much cleaner and easier to understand, though I have yet to test the performance. It should still be fine, because on average there are only 3-4 items in the carts and the upper boundary is around 25.
|
|
|
|