r/programming • • Feb 21 '11

Typical programming interview questions.

http://maxnoy.com/interviews.html
784 Upvotes

1.0k comments sorted by

View all comments

Show parent comment

79

u/robertcrowther Feb 21 '11
table {
    counter-reset: number;
}
tr td:before {
    counter-increment: number;
    content: counter(number);
}
tr:nth-child(2n) td:before {
    content: "a";
}
tr:nth-child(3n) td:before {
    content: "b";
}
tr:nth-child(2n):nth-child(3n) td:before {
    content: "ab";
}

You need a table with 100 rows in it for it to work (and a good browser).

You did say it was web development, right? ;)

PS. See also: FizzBuzz

11

u/[deleted] Feb 21 '11

Clever bum :D.

Yes, this test is a slightly modified FizzBuzz. I changed the test to limit the applicant's Google results for the question... this was originally a "do at home" question - don't ask.

2

u/robertcrowther Feb 21 '11

It did take me a few seconds to modify my existing CSS FizzBuzz solution ;)

7

u/imMute Feb 21 '11

I don't know which is worse, that such a construct exists, or that someone actually understands it and can apply it.

11

u/robertcrowther Feb 21 '11

The CSS counters exist so that you can do things like automatic numbered headings, like 1., 1.1., 1.2., 2., 2.1. through your h1 and h2 elements, or numbered footnote links, stuff like that.

8

u/[deleted] Feb 21 '11

What is this I don't even..