Why it’s hard for programmers to write a program to flatten a list?
shekhargulati.com
Why it’s hard for programmers to write a program to flatten a list?
1–10 of 128 posts
Re: Why it’s hard for programmers to write a program to flatten a list?
#2Re: Why it’s hard for programmers to write a program to flatten a list?
#3Re: Why it’s hard for programmers to write a program to flatten a list?
#4I'm a retired data architect and C developer with 36 years of professional experience. In my opinion, this is not how you find an appropriate candidate. It would be better to ask substantive questions that are related to the thing you are making. What does this person bring to the team? How will the team receive this person? Has this person delivered something of substance in the recent past that would convince you t…
Re: Why it’s hard for programmers to write a program to flatten a list?
#5 import { flattenDeep } from 'lodash';
const flat = flattenDeep([1,2[3], [4, [5,6]]);
Not sure why employers care about developers being able to write utility functions from scratch, when that is not (typically) the job developers are hired for.Having said that, I lament the issues that the OP brought up: poor naming, unfamiliarity with their language's data structures, etc. Those are issues that will come up. Especially naming.
Re: Why it’s hard for programmers to write a program to flatten a list?
#6I'm a retired data architect and C developer with 36 years of professional experience. In my opinion, this is not how you find an appropriate candidate. It would be better to ask substantive questions that are related to the thing you are making. What does this person bring to the team? How will the team receive this person? Has this person delivered something of substance in the recent past that would convince you t…
Those are questions for juniors. Most likely they had no previous job at all. The only thing they can bring is potential, and this question tests it rather well.
I've been asked a barrage of these questions for senior positions, even.
Especially sucks because I don't usually program terribly fast or well in an interview environment, so I look worse than I actually am, and often get put on the defensive in these interviews, which I absolutely hate.
Re: Why it’s hard for programmers to write a program to flatten a list?
#7* Nobody required this from them before.
* Recursion is rarely used to write business logic, most common thing programmers write and learn. Same for static methods and being generic.
* Type checking is done by compiler for them, so no surprise that they don't know how to do it.
* Relatively few people go beyond minimal, so adoption of is java 8 is low
Overall, it looks like a good question to pick up the best developers - assuming this is what you want.
Re: Why it’s hard for programmers to write a program to flatten a list?
#8Whatever else you say about it, Java is one of the entry-level languages. It's no wonder there are many entry-level programmers among its users. It's obviously a trade-off, as you get that many more candidates to choose from, compared to for example OCaml, Clojure or Erlang programmers. On the other hand, a percentage of people who can flatten a list is greater in users of the more "advanced" languages.
If you want to have a good signal to noise ratio: avoid languages used in "Programming 101" like a plague and languages which are currently fashionable. This way you'll get candidates who learned the language by themselves, in most cases after learning and mastering their previous language.
Becoming a programmer is a long process. Depending on the person, the time required to learn a single programming language may be shorter than the time needed to really master all the essential programming skills. Which I think explains why there is a correlation between good programmers and people who know more than one programming language.
Re: Why it’s hard for programmers to write a program to flatten a list?
#9 def flatten(x):
if isIterable(x):
for y in x:
yield from flatten(y)
else:
yield x
Well, technically this is a generator, but it's easy enough to put its result in a list.Re: Why it’s hard for programmers to write a program to flatten a list?
#10Couldn't you just do something like: def flatten(x): if isIterable(x): for y in x: yield from flatten(y) else: yield x Well, technically this is a generator, but it's easy enough to put its result in a list.
[item for sublist in l for item in sublist]