Hacker News new | past | comments | ask | show | jobs | submit login

The lights in the conference room flickered intermittently, a slight buzz heard each time they dimmed. Something was dripping on to the ceiling tiles from above, a large orange colored stain had developed in the corner.

The interviewer leaned in again, his tie loose, his face covered in stubble. He'd been at this for four hours now and it was showing.

"Tell us your social media passwords."

The candidate flinched back, shaking his head.

"I told you, I...that's illegal, you can't ask for those."

The interviewer clasped his hands together, cracked his knuckles, and flashed a big grin. With a swift motion he swiped a marker from the table, flicked off the cap, and stabbed it in the direction of the candidate.

"Write a linked-list implementation in C. Oh, and because you've been such a tough-guy you only get to use malloc...once. In the main function."

A bead of sweat quickly ran down the candidate's face. He looked tense, fraught with concern. The sound of his teeth grinding together wasn't hard to hear.

"S-seven salamander six exclamation three five."




> Oh, and because you've been such a tough-guy you only get to use malloc...once. In the main function

Oh yeah? How about I just don't use malloc then:

    static char ALLTHEFUCKINGMEMORY[1024*1024*1024];
    static size_t NEXTBYTE = 0;
    void *myAlloc(size_t size) {
        void *ptr = &ALLTHEFUCKINGMEMORY[NEXTBYTE];
        NEXTBYTE += size;
        if (size & 3) NEXTBYTE = (NEXTBYTE & (~3)) + 4;
        return ptr;
    }
    void myFree(void *ptr) {
        fprintf(stderr, "REAL PROGRAMMERS DON'T NEED TO FREE MEMORY\n");
        exit(-1);
    }


nice one!

for single linked list you can just use an array of the struct and borrow/return via circular list. my C is beyond the rust levels of 20y Golf 2 but I guess I won't sweat over.

An alternative solution would be cheating away and using realloc instead of malloc.


This story was fun to read but you lost me at the pass phrase with four numbers as words. That's clearly not dice ware!


65324 zero 44346 one 62245 two 61154 three 26252 four 25534 five 54225 six 53415 seven 24253 eight 43526 nine

Of course, if these were your dice rolls, you're pretty unlucky, and should try again. And/or buy a lottery ticket.


Someone upvote the parent, I can do it just once!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: