Expert C Programming

(Jeff_L) #1

Programming Challenge


Professor Perlis's Gut-Busting Homework Assignment


Caution: This Programming Challenge may be too intense for some viewers.


Some graduate schools also use programming questions to test their new students. At Yale
University, Professor Alan Perlis (one of the fathers of Algol-60) used to set the following
assignment (due in one week) to his incoming class of graduate students.


Program each of the following problems:



  1. Read a string and output all combinations of its characters.

  2. The "8-queens" problem (print all the chess configurations where eight
    queens can be placed on a board without attacking each other).

  3. Given N, list all the prime numbers up to N.

  4. Write a subroutine to multiply two arbitrary-sized matrices together.


in each of the following languages:



  1. C

  2. APL

  3. Lisp

  4. Fortran


Any one of these programming problems would have been a pretty reasonable assignment
for a class that was just one of several that a graduate student took. But here we were being
asked to do all of them in just one week, in all of a variety of languages that some of us had
never even seen before!


Of course, we didn't know that Perlis was just testing us, and that he wasn't actually going to
nail anyone. Most of the new graduate students spent a frantic week of late nights hunched
over a terminal, only to find that, back in class, Alan asked for volunteers to present a single
lan-guage/problem combination on the board.


Some of the problems could be solved by idioms, like the APL one-liner [1] for problem 3:


(2=+.0=T .|T)/T (^) iN
Thus, anyone who attempted any part of the assignment had the opportunity to show it.
Anyone who was so overwhelmed by the problem that they didn't even try the smallest part

Free download pdf