in reply to Filling an array. (Golf challenge?)

#12345678901234567890123456789012345678901234567 for$i(1..8){push@a,$_.$i for"a".."h"} for$i(1..8){push@a,map$_.$i,"a".."h"} # Hrm, only close. # And for a completely different approach: #12345678901234567890123456789012345678901234567 @a=("a".."h")x8;$_.=(1+int$i++/8)for @a; @a=("a".."h")x8;$a[$_].=1+int$_/8for 0..$#a; # Trying a combination.. #12345678901234567890123456789012345678901234567 push@a,$_.(1+int$i++/8)for(("a".."h")x8); # I'm on to something.. #12345678901234567890123456789012345678901234567 $_.=1+int$i++/8for @a=("a".."h")x8; # Bah! :) # Assuming 'use integer;' it's a winner though: #12345678901234567890123456789012 $_.=1+$i++/8for @a=("a".."h")x8; # 32 characters. But.. :/

Replies are listed 'Best First'.
Re: Re: Filling an array. (Golf challenge?)
by gmax (Abbot) on Dec 27, 2001 at 19:56 UTC
    Nice. But it's two lines, counting the array declaration.
    I am addicted to strict! ;-)
    my @a; for$i(1..8){push@a,$_.$i for"a".."h"};
    update Of course it should be also
    my $i; # after my @a; sorry :-(
     _  _ _  _  
    (_|| | |(_|><
     _|   
    
      Then that would have to be:
      my (@a, $i);
      Pay attention! :P

      Unless of course, you go for for my $i.