News for hackers. Stuff that matters.
Re:Why it’s hard for programmers to write a program to flatt... by cableshaft on Friday February 24, 2017 @09:59AM (#13724184)
Doesn't stop people from asking these questions of people at all levels. I still get asked these coding questions pretty much every interview I have had, and I have almost a decade of programming experience, and have even been lead programmer on some projects (without the title).

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 flatt... by collyw on Friday February 24, 2017 @01:51PM (#13726466)
Have you ever needed to flatten a list in your career outside exams and interviews?
Re:Why it’s hard for programmers to write a program to flatt... by throwaway2016a on Friday February 24, 2017 @03:08PM (#13727351)
> Have you ever needed to flatten a list in your career outside exams and interviews?

Yes, multiple times in multiple languages. C, C++, Javascript... sometimes "npm install" is not the answer.

Re:Why it’s hard for programmers to write a program to flatt... by mannykannot on Friday February 24, 2017 @02:38PM (#13726965)
I am not an enthusiast of this approach to recruiting, but to be fair, the purpose of the question is not to find someone to flatten lists.

It is reasonable to ask, if a programmer cannot flatten a list, in what sense is that person a programmer? Putting aside the question of whether this is a good approach to recruiting, if this question is being failed with any regularity, it raises some interesting and important questions about the innate difficulty of programming and/or the methods by which it is taught.

Re:Why it’s hard for programmers to write a program to flatt... by brudgers on Friday February 24, 2017 @04:59PM (#13728326)
If the person flattens a list with the:

   Google
   Copy
   Paste
Algorithm, are they a programmer? Are they more or less of a programmer if instead they use racket or clojure's built-in =flatten=?
Re:Why it’s hard for programmers to write a program to flatt... by mannykannot on Friday February 24, 2017 @05:40PM (#13728608)
It is the cases of failure that are interesting and informative, and if the methods you mention are the only ways a person can solve the problem, that counts as a failure - as I mentioned, this is not actually about flattening lists.
Re:Why it’s hard for programmers to write a program to flatt... by cableshaft on Friday February 24, 2017 @02:54PM (#13727163)
I mean, I once wrote a python script called unearthed.py that took all the files in all subfolders and put them into the parent folder, then deleted the subfolders, but I'm pretty sure I just used a simple os.walk for that.

Came in handy when working with rom archives that liked to put everything in its own folder, and a couple of times when I just had a bunch of crap that I didn't want to have to manually dig up anymore.

Other than that? No, not really.

Re:Why it’s hard for programmers to write a program to flatt... by zzzcpan on Friday February 24, 2017 @02:54PM (#13727160)
"Have you ever needed to flatten a list in your career outside exams and interviews?"

I had to write this function to flatten a tree of expressions, so I could sort them by precedence, etc and fold them into a tree. I already had a bunch of higher-order primitives for constructing a parser and that was basically a lazy hack for me to get expressions parsed. I eventually implemented a proper expression parser, that was basically the same thing, but produced a flat list from the beginning.

Re:Why it’s hard for programmers to write a program to flatt... by WkndTriathlete on Monday February 27, 2017 @09:06AM (#13744229)
Flattening a list of lists is a problem that occurs quite frequently in functional programming.

OTOH, in functional programming languages and frameworks, there is no need to actually write a method that does that since it is usually a library function call.

Re:Why it’s hard for programmers to write a program to flatt... by scarface74 on Friday February 24, 2017 @03:32PM (#13727613)
Yes. Something like:

List<List<Blah>> records;

We would send a request off to multiple services, wait for all the responses and then the front end would sometimes need all of the lists and other times need it flatten.

How would I do it?

var allitems = records.SelectMany(b => b).ToList();

Re:Why it’s hard for programmers to write a program to flatt... by fiedzia on Friday February 24, 2017 @03:58PM (#13727835)
Exactly once. But I needed to know recursion, typechecking, and modern language features almost every day.
Re:Why it’s hard for programmers to write a program to flatt... by iguanayou on Friday February 24, 2017 @01:58PM (#13726531)
Yes.