My Solution was:

#!perl -l
($},$h,$x,$s)[EMAIL PROTECTED];$s-=print
map$s|($t=$_-$x-1)?(grep!($s%$_|$t%$_),2..99)?$":"*":"@",1..$}for 1..$h

Here's an explanation:

($},$h,$x,$s)[EMAIL PROTECTED];

This reads the width, height, x and y positions from the command line
arguments. Note that instead of $w I used $} so I'll later be able to
append "for" after it without a whitespace.

I also named $s $s instead of $y, because that's a leftover from an older
code, where I used $s as an iterator.

Now:

$s-=print

This prints the stuff and decrements $s (as print returns 1 on success).
Because I used the -l flag, this automatically prints a newline at the
end.

map... ,1..$}

A mapping of the numbers to what has to be printed. This generates a list
that is later passed to print for printing.

$s|($t=$_-$x-1)?(grep!($s%$_|$t%$_),2..99)?$":"*":"@"

$t accepts the normalized x position, and s is the normalized y position.
The first test see if they are both 0. ($s|$t).
The second test checks if they are both divisable by a common denominator
(grep!....).
Then the character that has to be printed is printed according to both
tests. $" is whitespace.

for 1..$h
This entire thing is done for height lines.

Regards,

        Shlomi Fish

----------------------------------------------------------------------
Shlomi Fish        [EMAIL PROTECTED]
Home Page:         http://t2.technion.ac.il/~shlomif/

An apple a day will keep a doctor away. Two apples a day will keep two
doctors away.

        Falk Fish

Reply via email to