Ircnet Perl Maxigolf 1 (Finished)

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:
  1. 21 (row sums, top first) 12 (column sums, left first)
  2. 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 arguments: 11 11

Example Output:

O.
.O
or
.O
O.
You are free to interpret the 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.

The challenge runs under the generic perl golf rules.

You may assume the current directory is empty.

Tell the length of your solutions (but not the solution itself) to ton- on ircnet #perl or mail the number to perl-golf@ton.iguana.be

The challenge finishes at 2002/07/23 00:00:00 UTC

Leaderboard

 85 mtve
 96 ton
 99 tybalt89
115 andys   (rejected)
122 suo
  

Some Solutions

 85 mtve     map/../*$&+$'-"@ARGV"|$&%9 .$'%9-$ARGV[1]||y/01/.O/|s//$&\n/g|print|exit,glob'{0,1}'x4
 96 ton      $_=pop;s/./{${\(0 x2,"01,10",11)[$&]}}/g;map{$_%99-"@ARGV"or s/../$&\n/g,y/01/.O/,exit print}glob
 99 tybalt89 s/.//,s/../$&\n/g,/.\n(.)/,$`+$&.($1+$').$".($`+$1).($&+$')ne"@ARGV"|y/01/.O/-4||pop^print for 1..2e4
115 andys    -n0 ($a,$b,$c,$d)=/\d/g}{for$g(0,1){$_=($a+$g-$d).($c-$a+$d-$g)."\n".($d-$g)."$g\n";$o=y/10/O./,print if!/[2-]/&&!$o}  (rejected)
122 suo      ($a,$b)=@ARGV;for$x(@x=qw(00 01 10 11)){for$y(@x){$_="$x\n$y\n";y/01/.O/;print,exit if$a==$x+$y&&$b==$a+9*$x%10-9*int$y/10}}
133 andys    ($a,$b,$c,$d)="@ARGV"=~/\d/g;$o=$b-$c+$a-$d;for$g(0,1){$_=($a+$g-$d).($c-$a+$d-$g)."\n".($d-$g)."$g\n";$o=y/10/O./,print if!/2|-/&&!$o}
  
This was found during the post-mortem:
 84 tybalt89 map/../*$&+$'-"@ARGV"|$&%9 .$'%9-$ARGV[1]||y/01/.O/|s//$&\n/g|print|pop,glob'{0,1}'x4
 81 ton      map"@ARGV".s/../$&\n/g-$&-$`|$`%9 .$&%9-$ARGV[1]||y/01/.O/|print|pop,glob'{0,1}'x4
 80 mtve     map$ARGV[s/../$&\n/g&y/01/.O/]-$&-$`|$`%9 .$&%9-$ARGV[1]||print|pop,glob'{0,1}'x4 
 81 mtve     map$ARGV[s/.//&s/../$&\n/g]-$&-$`|$`%03.$&%9-$ARGV[1]|y/01/.O/-4||print|pop,0..1x5
 81 mtve     map$ARGV[s/.//&s/../$&\n/g]-$&-$`|$`%9 .$&%9-$ARGV[5^y/01/.O/]||print|pop,1e4..1x5
 81 mtve+ton $_=((glob'{.,O}'x4),'')[index"\0\4\37#\15\21,0(,GK59TX",chr 3*(pop)+pop];s/../$&\n/g;print
 79 ton+mtve -l print for(glob'{.,O}'x4 .$:)[index"\0\4\37#\15\21,0(,GK59TX",chr 3*(pop)+pop]=~/../g
 78 ton+mtve -l print for(0,glob'{O,.}'x4)[~index"\0\4\37#\15\21,0(,GK59TX",chr 3*(pop)+pop]=~/../g
 78 mtve+ton -l print for(glob'{.,O}'x4)[31&index"\0\4\37#\15\21,0(,GK59TX",chr 3*(pop)+pop]=~/../g
 77 mtve+ton -l "\377\373\340\334\362\356\323\317\327\323\270\264\312\306\253\247"=~~chr 3*(pop)+pop&&map{print}(glob'{.,O}'x4)[@-]=~/../g     (code red)
 77 ton+mtve -l print for(0,glob'{.,O}'x4)["\377\373\340\334\362\356\323\317\327\323\270\264\312\306\253\247"=~~chr 3*(pop)+pop,@+]=~/../g