Kolakoski

Score: 54.11 (pass)

Playing with tiebreakers...

#!perl -l
print map$$[$.++]=$ARGV[--$$[$;]||++$;,$;&1],1..pop

Score: 54.11 (fail)

Can't understand why this one does not work...

#!perl -l
print map$$[~~@$]=$ARGV[--$$[$;]||++$;,$;&1],1..pop

Score: 54.11 (pass)

Just for the obfusc^Wfun, and to prepare perl6...

#!perl -l
print map@@[$.++]=$ARGV[--@@[$@]||++$@,$@&1],1..pop

Score: 54.13 (pass)

Re-YES! :-)

#!perl -l
print map$$[--$_]=$ARGV[--$$[$;]||++$;,$;&1],1..pop

Score: 55.13 (pass)

playing with tiebreakers...

#!perl -l
print map{--$$[$;]||++$;;$$[--$_]=$ARGV[$;&1]}1..pop

Score: 55.15 (pass)

YES!

#!perl -l
print map{--$$[$;]or++$;;$$[--$_]=$ARGV[$;&1]}1..pop

Score: 58.12 (pass)

#!perl -l
print map{--$$[$;]or$;++,--$|;$$[--$_]=$ARGV[$|]}1..pop

Score: 60.15 (pass)

could this solution be the one?

#!perl -l
$_.=$$[$.++]=$ARGV[--$$[$;]||++$;,$;&1]for($_)x pop;print

Score: 63.13 (pass)

A Cantor-like style...

#!perl -l
s/$/$$[$.++]=$ARGV[--$$[$;]||++$;,$;&1]/egfor($_)x pop;print

Score: 68.15 (pass)

a night to rest, and here we are...

#!perl -l
print+map{push@$,($ARGV[$|--])x($.=$$[--$_]||$ARGV[$_]);$.}1..pop

Score: 69.13 (pass)

#!perl -l
print+map{@$=(@$,($ARGV[$|--])x($.=$$[--$_]||$ARGV[$_]));$.}1..pop

Score: 71.14 (pass)

I have an headache now... Giving up for today!

#!perl -l
@==@ARGV;print+map{push@$,($=[$|--])x($.=$$[--$_]||$=[$_]);$.}1..pop

Score: 72.18 (pass)

#!perl -l
print+map{$w.=$ARGV[$|--]x($.=substr($w,--$_,1)||$ARGV[$_]);$.}1..pop

Score: 73.14 (pass)

#!perl -l
$==$ARGV[0];print map{--$$[$;]or$;++,$==$ARGV[--$|];$$[--$_]=$=}1..pop

Score: 78.17 (pass)

#!perl -l
map{push@$,($ARGV[$|--])x($.=$$[--$_]||$ARGV[$_])}1..500;print@$[0..-1+pop]

Score: 79.15 (pass)

#!perl -l
@==@ARGV;print+map{push@$,($=[$|--])x($.=--$_?$$[$_]||$=[1]:$=[0]);$.}1..pop

Score: 79.16 (pass)

That's what I told you! :)

#!perl -l
print+map{push@$,($ARGV[$|--])x($.=--$_?$$[$_]||$ARGV[1]:$ARGV[0]);$.}1..pop

Score: 80.15 (pass)

Nah, here I am!

#!perl -l
($;,$")=@ARGV;print+map{push@$,(--$_%2?$":$;)x($.=$_?$$[$_]||$":$;);$.}1..pop

Score: 80.22 (pass)

#!perl -l
$w.=$ARGV[$|--]x(substr($w,--$_,1)||$ARGV[$_])for 1..500;print substr$w,0,pop

Score: 91.12 (pass)

I should care about shaving strokes instead of playing with tiebreakers

#!perl -l
($;,$",$=)=@ARGV;map{$$[@$]=$;for 1..$$[$i++]||$;;($;,$")=($",$;)}1..$=;print@$[0..$=-1]

Score: 91.14 (pass)

this tiebreaker rule leads to really obfuscated code! :)

#!perl -l
($;,$")=@ARGV;map{$$[@$]=$;for 1..$$[$i++]||$;;($;,$")=($",$;)}1..500;print@$[0..-1+pop]

Score: 91.21 (pass)

#!perl -l
($;,$y)=@ARGV;map{$w[@w]=$;for 1..$w[$i++]||$;;($;,$y)=($y,$;)}1..500;print@w[0..-1+pop]

Score: 92.22 (pass)

#!perl -l
($;,$y,$z)=@ARGV;map{$w[@w]=$;for 1..$w[$i++]||$;;($;,$y)=($y,$;)}1..500;print@w[0..$z-1]

Score: 95.23 (pass)

#!perl -l
($;,$y,$z)=@ARGV;for$a(1..500){push@w,$;for 1..$w[$i++]||$;;($;,$y)=($y,$;)}print@w[0..$z-1]

Score: 103.19 (fail)

#!perl -l
($;,$y,$z)=@ARGV;$_=$;x$;;for$a(1..$$){($;,$y)=($y,$;);$_.=$;x(substr($_,++$i,1)||$;)}print/(.{$z})/

Score: 105.25 (fail)

#!perl -l
($x,$y,$z)=@ARGV;$_=$x x$x;for$a(1..$$){($x,$y)=($y,$x);$_.=$x x(substr($_,++$i,1)||$x)}print/(.{$z})/

Score: 106.26 (pass)

#!perl -l
($x,$y,$z)=@ARGV;$_=$x x$x;for$a(1..500){($x,$y)=($y,$x);$_.=$x x(substr($_,++$i,1)||$x)}print/(.{$z})/

Score: 108.26 (pass)

#!perl -l
($x,$y,$z)=@ARGV;$_=$x x$x;for$a(1..500){$w=($w==$y)?$x:$y;$_.=$w x(substr($_,++$i,1)||$y)}print/(.{$z})/

Score: 949.13 (pass)

!!Check it!! Here's a _trilingual_ solution of the Kolakoski problem. You are to remove the shebang line, I only put it because pgas want a properly formatted shebang line. Once the shebang line is cut out, you can run the program: - in perl, just type: $ perl kola.pl - in C, compile it with: $ gcc kola.c -o kola and run it: $ ./kola - in Befunge, you'll need a Befunge interpreter (such as the one I provide with the Language::Befunge module): $ jqbf98 cantor.bf

#!perl
#undef fff /* n a9+y >#v_ 0> \ :   #v_ $ :0ep :0fp '0+, v
"                    ^ <   ^+-0'\*a\<      >\a*\'0-+v
ve50pe40pe30 pe2 $ _v# ! : \ < 0    pe1 $ _^# ! : \ < 0 <
p                   >\a*\'0-+^
> 2eg 1- : 2ep !#v_ 4eg : fg 1- \ fp 4eg fg #v _  3eg ! 3ep 4eg 1+ 4ep v
                 a
^ pf pe5 :+1 ge5 ,              +0' : ge ge3 <                         <
                 q
*/ //";
#include 
#define ARGV argv
#define $ /*
unshift @ARGV, "foo";
sub atoi{ $_[0] }
"*/
main (int argc, char *argv[]) //";
{
  int $ tab[atoi( $ ARGV[3])];
  int $ i;
  int $ which, $ offset;
  $ which = $ offset = 1;
  $ tab [1] = atoi( $ ARGV[ $ which ] );
  printf("%d", $ tab[1]);
  for( $ i = 2; $ i <= atoi( $ ARGV[3] ) ; $ i++ ) {
    $ tab[ $ offset ] -= 1;
    if ( $ tab[ $ offset ] == 0 ) {
      $ offset++;
      $ which = ( ! ( -- $ which ) ) + 1;
    }
    printf("%d", $ tab[ $ i ] = atoi( $ ARGV[ $ which ] ) );
  }
  printf("\n");
}

Score: 969.13 (pass)

Eugene required #include As always, remove the #!perl line (shebang), only there because of pgas

#!perl
#undef fff /* n a9+y >#v_ 0> \ :   #v_ $ :0ep :0fp '0+, v
"                    ^ <   ^+-0'\*a\<      >\a*\'0-+v
ve50pe40pe30 pe2 $ _v# ! : \ < 0    pe1 $ _^# ! : \ < 0 <
p                   >\a*\'0-+^
> 2eg 1- : 2ep !#v_ 4eg : fg 1- \ fp 4eg fg #v _  3eg ! 3ep 4eg 1+ 4ep v
                 a
^ pf pe5 :+1 ge5 ,              +0' : ge ge3 <                         <
                 q
*/ //";
#include 
#include 
#define ARGV argv
#define $ /*
unshift @ARGV, "foo";
sub atoi{ $_[0] }
"*/
main (int argc, char *argv[]) //";
{
  int $ tab[atoi( $ ARGV[3])];
  int $ i;
  int $ which, $ offset;
  $ which = $ offset = 1;
  $ tab [1] = atoi( $ ARGV[ $ which ] );
  printf("%d", $ tab[1]);
  for( $ i = 2; $ i <= atoi( $ ARGV[3] ) ; $ i++ ) {
    $ tab[ $ offset ] -= 1;
    if ( $ tab[ $ offset ] == 0 ) {
      $ offset++;
      $ which = ( ! ( -- $ which ) ) + 1;
    }
    printf("%d", $ tab[ $ i ] = atoi( $ ARGV[ $ which ] ) );
  }
  printf("\n");
}

Score: 2255.06 (pass)

Wowow! Finally, here's the ultimate challenge completed! Here's the _quadrilingual_ solution of the Cantor problem... You are to remove the shebang line, I only put it because pgas want a properly formatted shebang line. Once the shebang line is cut out, you can run the program: - in Perl, just type: $ perl kola.pl - in C, compile it with: $ gcc kola.c -o kola and run it: $ ./kola - in Befunge, you'll need a Befunge-98 compliant interpreter (such as the one I provide with the Language::Befunge module): $ jqbf98 cantor.bf - in BrainFuck, there's a little tweak. Since Brainfuck does not support command-line arguments, you are to concatenate the args into one. The last argument (ie, the number of characters to be displayed) must be formatted with leading zeroes. So, the big argument can be obtained with sthg like: $arg = sprintf("%d%d%03d", $nb1, $nb2, $count); Once this done, you can run it with: $ echo | aidbf kola.bfk where aidbf is a BrainFuck interpreter (I tested my solution with the aidbf interpreter, available here: http://ailis.de/~k/projects/aidbf/aidbf-0.1.tar.gz ) Please note that I'm using non-buffered I/O For those of you who want to test it, I can tell you that Brainfuck is really a nasty language... ;-)

#!perl
#undef fff /*v>> >,-----------------------------------------
"-------[>+>> >>>>+>+<<<<<<<<-]>>,--------------------------
---------------------->+>>>>>+++++++++++++++++++++++++++++++
+++++++++++++++++.------------------------------------------
------->+<[>- <[>>+<<-]]>[-<<<<<+<-<[<<+>>-]<<[>>+>>>>>>>>+<
<<<<<<<<<-]>> >>>>>>>>[>+>+<<-]>[<+>-]<-<]>[<<+>>-]<<<<<<<<<
<<<<,------------------------------------------------>,-----
------------------------------------------->,---------------
---------------------------------<<[>++++++++++<-]>>>>>>>>+<
<<<<<[[>+<-]> >>>>>-<<<<<<]>[<+>-]>>>>>[-<<<<<<++++++++++<->
>>>>>>]<<<<<<-<<>[>>+<<-]>>[<<+<+>>>-]<<<[[-]>->++++++++++<<
]>>[<<+>>-]<< [>>+>+<<<-]>>>[[-]<<<>>>>>>>>>>>>>>>[+++++++++
+++++++++++++++++++++++++++++++++++++++.<<<<<<<<<<<<<->>>>>>
>>>>>>>[-]]<< <<<<<<<<<<<<<>+[->[->>>>>>>>[>]>[>]+[<]<[<]<<<
[->>>+<<<<<[<+>-]<[>+>>>>+<<<<<-]>>>]>>>[<<<+>>>-]<<[->>+<<<
<[<<+>>-]<<[> >+>>>+<<<<<-]>>>>]>>[<<+>>-]<[>>[>]>[>]<+[<]<[
<]<-]>>[>]>[> ]<++++++++++++++++++++++++++++++++++++++++++++
+++.------------------------------------------------[<]<[<]<
+>>[>]<-[[>+<-]<<[<]<->>[>]]>[<+>-]<<[<]<[<<<<<+>>>>>-]<<<<<
[->>>[->>>+<< <]>[->+<]>[<<+>>-]>[<<+>>-]>[>]+>>[<+>-]<[<]<<
<<<<]<]++++++n++++<][-]<]++++++++++.[-][
             >  a9+y >#v_ 0> \ :   #v_ $ :0ep :0fp '0+, v
                     ^ <   ^+-0'\*a\<      >\a*\'0-+v
ve50pe40pe30 pe2 $ _v# ! : \ < 0    pe1 $ _^# ! : \ < 0 <
p                   >\a*\'0-+^
> 2eg 1- : 2ep !#v_ 4eg : fg 1- \ fp 4eg fg #v _  3eg ! 3ep 4eg 1+ 4ep v
                 a
^ pf pe5 :+1 ge5 ,              +0' : ge ge3 <                         <
                 q
*/ //";
#include 
#include 
#define ARGV argv
#define $ /*
unshift @ARGV, "foo";
sub atoi{ $_[0] }
"*/
main (int argc, char *argv[]) //";
{
  int $ tab[atoi( $ ARGV[3])];
  int $ i;
  int $ which, $ offset;
  $ which = $ offset = 1;
  $ tab [1] = atoi( $ ARGV[ $ which ] );
  printf("%d", $ tab[1]);
  for( $ i = 2; $ i <= atoi( $ ARGV[3] ) ; $ i++ ) {
    $ tab[ $ offset ] -= 1;
    if ( $ tab[ $ offset ] == 0 ) {
      $ offset++;
      $ which = ( ! ( -- $ which ) ) + 1;
    }
    printf("%d", $ tab[ $ i ] = atoi( $ ARGV[ $ which ] ) );
  }
  printf("\n");
}
#define BLAHBLAH /* ] */