develooper Front page | | Postings from July 2002

It's so simple ! It can't be that hard !

Thread Next
July 24, 2002 15:29
It's so simple ! It can't be that hard !
Message ID:
Another one that was done as a (very quick, only half a day) ircnet golf
for you to try your teeth on.
Won by mtve with a score of 85, but in the postmortem we are at 77.
How well can the mailinglist do this as an open golf (post your attempts
Only for people who haven't played it and haven't looked at the web page.

Consider a 2x2 square where each position can be filled (represented by a O
(that's not a zero)), or empty (represented by a .). You can then
look how many elements are filled on each row and column, for example: 

 OO  -> 2 filled
 .O  -> 1 filled
1  2   filled

Which we could write in several ways. The two we will consider are: 

   * 21 (row sums, top first)         12 (column sums, left first) 
   * 12 (column sums, left first)     21 (rwo sums, top first) 

Your program will get as commandline arguments the row and column sums in
the form /^[012][012]\z/. You are to output exactly one pattern that has
these row and column sums or nothing if there is no way to satisfy the
input. Nothing should go to STDERR. The output should match
/^([O.][O.]\n){2}\z/ or /^\z/. 

Example commandline arguments: 11 11

Example Output: 




You are free to interpret the two arguments as row-sums first or
column-sums first. but you should be consistent. If your program
assumes one order for a certain input, you must assume that order
for all inputs. 

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About