The easy way to code-golf ascii art!

Perl 6: 60 characters EDIT: 38 points (see bottom)

  #C#O     D#E#G#O       #L#
#F    #.#S#       T#A#C#K
  get\     .subst(       "*"
,{    shift       BEGIN [
  get\     .comb,\       "."
xx    * ]},       :g)\ .\
  say\     xx get\       ()\
#E    #X#C#       H#A#N#G
  #E#.     #C#O#M#       #!#

If you don't appreciate my terrible art skills, here's the golf:

get.subst("*",{shift BEGIN [get.comb,"."xx*]},:g).say xx get

This one does weird things with evaluation times.

First, the BEGIN keyword forces [get.comb, "." xx *] to be evaluated first, putting into an array the list of characters that make up "the code", followed by an infinite amount of "."s.

Next, the get at the end is evaluated, getting the number of lines of the ASCII art template. The xx operator repeats the first part of the program this many times. This makes more sense when you realize that code() xx count() is basically sugar for code() for 1..count(): count() should be evaluated first.

Finally, the get in the beginning of the program gets a line of the ASCII art template and substitutes every "*" with a value shifted off of the beginning of the array we made before everything else ({shift BEGIN …}).

EDIT:

Golfed down to 37 characters, plus one for the command line switch:

perl6 -pe's:g[\*]=shift BEGIN [get.comb,"."xx*]'

This is the same concept as the original, the -p switch iterating over each line (after the BEGIN has read in "the code"), and substituting all *s with the next letter from "the code" before printing it. The input format for this shouldn't include the number of lines of the format.


Ruby 2.0, 53 52 characters

c=gets.chop
$><<gets($n).gsub(?*){c.slice!(0)||?.}+c

As per the spec, doesn't use the 'number of lines' paramater.

Example run:

qwertyuiopasd
***** * ***
*   * * *
*   * * *
***** * ***

Output:

qwert y uio
p   a s d
.   . . .
..... . ...

GolfScript, 30 characters

n/(\(;n*'*'/{@.!'.'*+([]+@+}*\

Run online.

Examples:

> qwertyuiopasdfghjklzxcvbnm
> 4
> ***** * ***
> *   * * *
> *   * * *
> ***** * ***

qwert y uio
p   a s d
f   g h j
klzxc v bnm

> qwertyuiopasdfghjklzxcvbnm
> 1
> ***** * ***

qwert y uio
pasdfghjklzxcvbnm

> qwerty
> 2
> ***** * ***
> *   * * *

qwert y ...
.   . . .