Draw the shadows of buildings
Perl - 85

BEGIN{$d=-&lt;&gt;}$d?s/X /X./g:s/ X/.X/g;s/ /substr($p,$+[0]+$d,1)eq'.'?'.':$&amp;/ge;$p=$_;


EDIT: I totally forgot about the -p flag this needs to be run with. Added 2 to char count.
The flag specified at the first line is 0 for shadows going left and 2 for shadows going right.