# The lost art (Was: The VAX is running

John Floren slawmaster at gmail.com
Mon Apr 6 16:41:13 CDT 2009

```On Mon, Apr 6, 2009 at 5:25 PM, Chris Kennedy <chris at mainecoon.com> wrote:
> Ian King wrote:
>
>> I used to ask college grads to write a function in C to convert a
>> null-terminated string representing an octal number into an int.
>
> Mine has always been to postulate a singly-linked list with each node
> containing a string value, then ask them to write something to print out
> the list in reverse order.  There's a bunch of obvious ways to solve
> that problem; the nice thing about it is that depending on the answer
> that they give you can apply more constraints (copying isn't allowed,
> memory is constrained, optimize for speed, whatever) in order to better
> estimate their approach to solving problems.
>

I hope the answer is recursion. The answer should ALWAYS be recursion,
right Professor McCarthy? :)

void print-list(node *n) {
if (n->next != 0)
print-list(n->next);
printf("%s\n", n->string);
}

The string-of-octal to int is an interesting one too, I'd do it by
banking on the "one octal digit = 3 bits" trick but I'm sure Ian saw
some interesting answers... as a computer engineering student, I do
wonder if CS undergrads are getting the same kind of explanations as
us: "This is hex. One hex number -> 4 binary bits. Here, do some math
in hex by hand." It's the CE courses that have really led me to
understand how computers work, while CS seems to care less about the
representation and more about how super awesome Java is.

John
--
"I've tried programming Ruby on Rails, following TechCrunch in my RSS
reader, and drinking absinthe. It doesn't work. I'm going back to C,
Hunter S. Thompson, and cheap whiskey." -- Ted Dziuba

```