Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
qntm
Jun 17, 2009
why would you ever actually need to know the number of set bits in an int, anyway

Adbot
ADBOT LOVES YOU

Soricidus
Oct 21, 2010
freedom-hating statist shill

qntm posted:

why would you ever actually need to know the number of set bits in an int, anyway
parity check maybe?

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

qntm posted:

why would you ever actually need to know the number of set bits in an int, anyway

bitsets;

= Hamming weight

Malcolm XML fucked around with this message at 10:28 on Jul 9, 2014

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av
when my boss asked us what questions to ask to candidates, I suggested "make them read code". explain what this function does, find the bug in this function and fix it, etc.

I know as a programmer I'm supposed to do cool intellectual stuff, design algorithms, elegant data structures and bit twiddling hacks, but the reality of my job is reading code written by someone else or supposedly by me (in some dead-end alternate timeline where I huff glue and eat paint chips maybe?). reading a ton of code, sometimes from inside a debugger, sometimes the debugger can even match the current execution address to the right line (!). invariably bad code, either crap through and through, overambitious code abandoned a third of the way through or some kind of elegantly designed dynamic indirection hell

even when I start a new project from scratch, I'm usually editing some kind of template. in fact, another good test is: start a project from scratch. it has to do this incredibly complicated thing that you have to use an external library for, show me how you integrate external dependencies in your project, how you know which implementation to pick from the vast offering of crap, etc.

algorithms and data structures are way overrated

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

tef posted:

poor sod. are you in n|s|e|w london?

north ish

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
malcolm ur not sounding v. happy with yr job. you trapped by visa reqs or something?

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

coffeetable posted:

malcolm ur not sounding v. happy with yr job. you trapped by visa reqs or something?

nah i like my job + coworkers its just that london weather sux

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

hackbunny posted:

when my boss asked us what questions to ask to candidates, I suggested "make them read code". explain what this function does, find the bug in this function and fix it, etc.

I like the idea, but I've never made it work well. what would you have them read?

I couldn't find stuff that was domain neutral, interesting in terms of signal, and was small enough to fit in an interview. maybe as a take-home where they can take the usual 20 mins to understand the lifecycle properties of a library it depends on and then move to pulling on the next string, but not in an on-site slot. we also don't require candidates to know any specific language, so we'd need a half-dozen of them and every interviewer would need to be fluent in all of them.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
What about asking them what clever code they've read recently? What bugs have they fixed and what code have they been really pleased with in their experience, either ones they wrote or ones they read?

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

Suspicious Dish posted:

What about asking them what clever code they've read recently? What bugs have they fixed and what code have they been really pleased with in their experience, either ones they wrote or ones they read?

sure, that's all good stuff to ask, or things like it. do you find that you can get to interesting levels of detail when asking about code when the code isn't in front of both of you? I find it gets pretty hard to follow more than cursory description of clever code, and hard to generate follow-up questions from the answers -- especially if it's from a domain or language I don't know well.

do you think that's a substitute for asking more pointed questions about actual code that's in the room, or having the candidate write some? I don't think anyone is advocating for only doing ds&a exercises.

I also like "what was the hardest part of your project to test?" and "if you could change one design decision in your project for free, what would it be?", but those are evaluating a different set of things.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I've never given an interview. I have no idea about these things. I just was just giving a suggestion. It was bad.

hackbunny
Jul 22, 2007

I haven't been on SA for years but the person who gave me my previous av as a joke felt guilty for doing so and decided to get me a non-shitty av

Subjunctive posted:

I like the idea, but I've never made it work well. what would you have them read?

I didn't participate in the interviews, but I think we used stuff from our own codebase. probably made candidates work on actual bugs we've fixed recently, or asked them to explain what some function does

we're a small company and we make a single product so it works for us... I guess? the two viable candidates just vanished and in the end we hired a QA guy instead. not sure what the moral is

FamDav
Mar 29, 2008
the "read code" sample a former coworker used was an implementation of some sort (can't remember if it was quick sort or simpler) that had a few style issues, a bug or two, and some issues w/ using the function in a threaded program.

seemed to work p well i guess

Notorious b.s.d.
Jan 25, 2003

by Reene
i hate sitting on the other side of a desk in an interview. false negatives are terrifying. finding and interviewing candidates is expensive and unpleasant, i really don't want to 'pass' on the wrong person

performance on algorithm problems correlate strongly with how recently you graduated from college and how recently you dicked around with an algorithms book. i don't see it as a great way to get to grips with a stranger's thought process

MononcQc
May 29, 2007

Letting someone read or fix code from your company is also a good way to let them know what your good or bad stuff looks like, which may be valuable if you want them to know what they're getting into in advance.

Mr. Glass
May 1, 2009

Notorious b.s.d. posted:

performance on algorithm problems correlate strongly with how recently you graduated from college and how recently you dicked around with an algorithms book. i don't see it as a great way to get to grips with a stranger's thought process

wow i could not disagree more w/ this

i don't care if you graduated yesterday or have been in the industry for 25 years if you can't apply algorithm concepts i don't want to work with you


note that i also don't like trick questions for the reason you state

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip
there is a difference between the ostensibly-dsa question "detect whether a singly linked list is cyclic using constant space" and the actually-dsa question "find the most recent common ancestor of two nodes in a binary tree"

Mr. Glass
May 1, 2009
agreed. a good algorithms question has multiple solutions of varying complexities. trick questions provide no signal.

FamDav
Mar 29, 2008
was it in this thread where somebody said that some standard interview question was an unsolved problem in computer science for half a decade?

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
when i interviewed the goonlord yesterday i asked the detect-balanced-parenthesis question and he said he'd just use a regex

qntm
Jun 17, 2009

Tiny Bug Child posted:

when i interviewed the goonlord yesterday i asked the detect-balanced-parenthesis question and he said he'd just use a regex

Perl code:
use strict;
use warnings;
use English;

my $input = "(((())()())";

eval { qr/$input/ };

print $EVAL_ERROR ? "unbalanced" : "balanced";
story checks out

Mr. Glass
May 1, 2009

Tiny Bug Child posted:

when i interviewed the goonlord yesterday i asked the detect-balanced-parenthesis question and he said he'd just use a regex

no hire, eject from premises immediately

MononcQc
May 29, 2007

FamDav posted:

was it in this thread where somebody said that some standard interview question was an unsolved problem in computer science for half a decade?
http://www.nomachetejuggling.com/2014/06/24/the-worst-programming-interview-question/

quote:

Anyway, I think this question perfectly represents everything that can go wrong with an interview question, so I'd like to discuss it here to explain why it's almost hilariously awful as an interview question:

quote:

Write a function that can detect a cycle in a linked list.

Seems like your basic algorithm coding question at first, right? Hop up and write the function on the white board; totally reasonable, right? Except it's not, it's brain-meltingly terrible. Let's break it down.

[...]

[...]The only one that makes the question "stop" is the tortoise-and-hare algorithm.

Is it reasonable to expect someone to think of this, from scratch? After all, you're pretty confident you could think of it, right? Well, the Linked List as a data structure was discovered by Allen Newell, Cliff Shaw and Herbert A. Simon in 1955. The "correct" cycle detection algorithm for a Linked List is named "Floyd's cycle-finding algorithm" in honor of its inventor, Robert W. Floyd, who discovered it in a 1967 paper.

Between 1955 and 1967, the problem of "how do we determine if there is a cycle in a linked list without modifying the list" was an open problem. Meaning, any number of PhD candidates in Mathematics or Computer Science could have written about it as part of their dissertation. With all of those hundreds and hundreds of minds, this problem remained open for 12 years.

Tiny Bug Child
Sep 11, 2004

Avoid Symmetry, Allow Complexity, Introduce Terror
ya i asked him about the pumping lemma and stuff but he just kinda smiled and nodded

FamDav
Mar 29, 2008

Tiny Bug Child posted:

ya i asked him about the pumping lemma and stuff but he just kinda smiled and nodded

remember you work in porn

fritz
Jul 26, 2003

Tiny Bug Child posted:

when i interviewed the goonlord yesterday i asked the detect-balanced-parenthesis question and he said he'd just use a regex

Tiny Bug Co-worker

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

hahaha, what the gently caress? how is

code:
bool is_cyclic (Node *head) {
    for (Node *l = head->next; l; l = l->next)
        if (l == head)
            return TRUE;
    return FALSE;
}
a twelve-year problem?

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Suspicious Dish posted:

hahaha, what the gently caress? how is

code:
bool is_cyclic (Node *head) {
    for (Node *l = head->next; l; l = l->next)
        if (l == head)
            return TRUE;
    return FALSE;
}
a twelve-year problem?

your solution doesn't work, it would loop infinitely if it didn't loop back to the head of the list, no?

Sweeper fucked around with this message at 17:56 on Jul 9, 2014

Squinty Applebottom
Jan 1, 2013

pythagoras came up groundbreaking new theorem but i would expect most people to know it by now

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
I think it's just too obvious an algorithm and a solution to have a name.

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

Suspicious Dish posted:

I think it's just too obvious an algorithm and a solution to have a name.

a -> b -> c -> b

MononcQc
May 29, 2007

Suspicious Dish posted:

hahaha, what the gently caress? how is

code:
bool is_cyclic (Node *head) {
    for (Node *l = head->next; l; l = l->next)
        if (l == head)
            return TRUE;
    return FALSE;
}
a twelve-year problem?

This looks like you're looking for actual circular lists, not just cycles, which may happen from any point in the list.

Unless I read your code wrong, this one would actually run forever on:

code:
1 -> 2 -> 3 -> 4 --,
          ^--------'
Sorry, you just tanked the interview.

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

MononcQc posted:

This looks like you're looking for actual circular lists, not just cycles, which may happen from any point in the list.

Unless I read your code wrong, this one would actually run forever on:

code:
1 -> 2 -> 3 -> 4 --,
          ^--------'
Sorry, you just tanked the interview.

Yes, it would. I thought cyclic lists meant the same thing as circular lists. My bad.

Max Facetime
Apr 18, 2009

tef posted:

meanwhile "is this for recommending things to users or recommending adverts to users" is an honest question which has a substantial effect on the answer. the "it's complicated" wasn't really helpful.

"is this for users or advertisers" is a good question, but "it's complicated" is a great answer and a wonderful conversation starter. "it's complicated" should have your ears instantly perked and bring a sparkle in your eyes :allears:

"how is it complicated? in what sort of ways?"

~they don't give any real answer~

"alright, i'm going to go with a strictly 100% user-focused solution to start with. we can changes things depending on what you think as we go along" and so on...

shrughes posted:

You couldn't figure out the trick.

yeah...

the trick isn't remembering that you need to traverse the lists twice, first time to get the size. that's rather a hint

if working on a whiteboard, the trick is that instead of drawing the lists like this:

pre:
   |a| -> |a| -> |a| -> |a| -> |1| -> |2| -> |3| -> | |

   |B| -> |B| -> |B| -> |B| -> |B| -> |B| -> |B| -> |B| -> |1| -> |2| -> |3| -> | |

you need to draw them like this instead, vertically and aligned on their tails, not heads. the result would look like this:


pre:
        |B|
        |B|
        |B|
   |a|  |B|
   |a|  |B|
   |a|  |B|
   |a|  |B|
   |1|  |1|
   |2|  |2|
   |3|  |3|
   | |  | |
from that it's easy to see you need to "chop off" the parts that are different, and to do that you need to chop them to same length first
. which is where needing to know the sizes comes from


Suspicious Dish posted:

hahaha, what the gently caress? how is

code:
bool is_cyclic (Node *head) {
    for (Node *l = head->next; l; l = l->next)
        if (l == head)
            return TRUE;
    return FALSE;
}
a twelve-year problem?

what if the cycle starts from or really stops at the node next to the head?

spoiler

Sweeper
Nov 29, 2007
The Joe Buck of Posting
Dinosaur Gum

MononcQc posted:

This looks like you're looking for actual circular lists, not just cycles, which may happen from any point in the list.

Unless I read your code wrong, this one would actually run forever on:

code:
1 -> 2 -> 3 -> 4 --,
          ^--------'
Sorry, you just tanked the interview.

octopus man, you work on distributed systems right? in your interviews do you ask about leader election strategies, quorums, other distributed systems concepts or assume that someone can learn that stuff? I feel like I'm going to have to be interviewing soon and idk if it is that important for them to get the low level stuff or just the general can you do things at massive scale with little to no state

Max Facetime
Apr 18, 2009

as for reversing the list, i'd say the trick here is (again working on a whiteboard) to draw the list in the starting state like this:

pre:
 

        | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> nil
         |     |     |     |     |     |     |     |     |     |
         v     v     v     v     v     v     v     v     v     v

        (H)   (e)   (l)   (l)   (o)   (.)   (j)   (p)   (e)   (g)

and then complete the drawing by writing the end state below the first list so that it links to the same payloads:

pre:
 

        | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> | |-> nil
         v     v     v     v     v     v     v     v     v     v

        (H)   (e)   (l)   (l)   (o)   (.)   (j)   (p)   (e)   (g)

         ^     ^     ^     ^     ^     ^     ^     ^     ^     ^
  nil <-| | <-| | <-| | <-| | <-| | <-| | <-| | <-| | <-| | <-| |

now it's pretty clear all you need to do is turn each link 180 degrees at every node to get the reversed list

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe
Which is the exact same thing as popping from the head of the first list and building a new linked list starting with that.

I still haven't ever been told what the "in-place" requirement means.

MononcQc
May 29, 2007

Sweeper posted:

octopus man, you work on distributed systems right? in your interviews do you ask about leader election strategies, quorums, other distributed systems concepts or assume that someone can learn that stuff? I feel like I'm going to have to be interviewing soon and idk if it is that important for them to get the low level stuff or just the general can you do things at massive scale with little to no state

It depends if we're looking to fill a junior or senior position, and what we have available on the team or not. We currently seem to be focusing on getting good people we think would work well with us.

We have something like a general interview with the manager, then one or more interviews with individual team members if we feel we need more to judge from, then we may have you come on site or work remotely on a small project with us. The interviews I did were as one of the additional team members.

So what we aim to do is size up who the person is. We want to pick projects for them that will fit their experience, and know what roles they could fill on the team. Would they be additional hands on the regular development? Real good at testing? Better at architecturing stuff, or maybe operational burden?

What will we need to teach them? Distributed systems? The languages and libraries we use? The external dependencies we have? How to work remotely? What can they teach us (this one is harder if you don't know your weaknesses properly)?

What they like, what's their experience, what they know, and what they don't know, basically. We sometimes hire people who know poo poo good enough in general areas we really need but some big hurdles (i.e. you don't know the programming language we use, but you're willing to learn and you know a lot about other stuff).

So for distributed systems, I try to ask them if they have any experience or interest that way. If they don't have experience but are interested, I can try to gauge what they know for now. If they don't have interest, there isn't much we can do.

For gauging, I usually flat out ask if they know about specific things, or ask them how they approached them in projects they mention having worked on that were in any way distributed:

- end-to-end principle
- idempotence
- CAP theorem > PACELC
- Latencies vs. netsplits
- protocols they used before (HTTP, TCP, UDP, etc.?)
- Do they know of things like CRDTs, how Quorum or two-phase commits work (and fail), etc.
- leader election
- What's a consistent cut
- How they would do state replication or whatever
- Experience in parallelism/concurrency (they are kind of similar at times)
- distributed databases they may have used before
- Etc.

There are no bad answers to these, it's really to try and figure out where they stand, what they know or don't know. For the cases where they don't know the term, I can try to describe a situation about it to see if they know the principle, but not the terminology (this is especially frequent with self-taught people). So if it's about two-phase commits, I can ask for things like the usual "how would you go about coordinating a bunch of nodes to make sure they all make the right decision in this situation" and see what questions they ask to clarify the concept, to see if they're asking stuff relevant to the case (latencies? can it be inconsistent at all? do you need it to never freeze up? do you need it to be centralized or not?, etc.)

Having them ask the right questions is often good enough to let us know that they know how to spot problem cases and could probably ask for help if they just don't know the solution, which is pretty good.

Once we have a general idea where they stand on that front (and on plenty of others -- Erlang, ops work, testing, system design, etc.), we'll try to set up a project that matches the strength we perceived them to have, with durations that are flexible (from half a day to three days, remote or local). We've had people come in and design a replication protocol we have plans for and wanted to see what they'd come up with. We've had people whose project was planning sharding of some specific data feed. My own was implementing a binary serialization format decoder from almost legacy software over the course of a few (all expenses paid) days on-site to know how I'd mesh in with the other team members.

After that, the candidate must present (small document, short presentation) to people who are interested (our team and some from other teams) what they did for their project. Just 15 minutes or so. That lets us know how well you'll communicate and document things, especially on a distributed team.

Once that's all done, the manager consults team members one on one for their impressions and feedback, and can decide that the candidate is accepted or rejected from that feedback.

It's a heavy process and possibly cuts us away from really great people who just don't have the time or will to go through the entire process, but tends to give us fairly good hirees we're happy with. I'm not sure if other teams here proceed in the same way.

MononcQc fucked around with this message at 18:33 on Jul 9, 2014

Mr. Glass
May 1, 2009

Suspicious Dish posted:

I still haven't ever been told what the "in-place" requirement means.

"don't explicitly allocate any memory", usually

Adbot
ADBOT LOVES YOU

Max Facetime
Apr 18, 2009

Mr. Glass posted:

"don't explicitly allocate any memory", usually

this

also "stack is an explicit data structure rather than a free endless resource", mayhaps

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply