Re: SPOILER: Solution to Perl Quiz of the Week #26 (Acrostic puzzle formatter)
Greg Matheson <[email protected]> Wed, 20 Oct 2004 22:27:51 +0800
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 19 Oct 2004, Jon Ericson wrote: > Greg Matheson <[email protected]> writes: > > My solution puts two copies of the puzzle on one piece of B5 paper > > using latex. > I tried to get this working, but ... It wasn't very robust. The most important problem was I wasn't normalizing everything to upper case, I think. With the following changes, I was able to print the example anagram in the quiz question on one A4 piece of paper. However, a few rough edges remain. $ diff -u qotw.pl.orig qotw.pl --- qotw.pl.orig 2004-10-20 22:09:42.000000000 +0800 +++ qotw.pl 2004-10-20 22:11:30.000000000 +0800 @@ -1,22 +1,23 @@ -#!/usr/bin/perl -wd +#!/usr/bin/perl use strict; use warnings; -my $quote = <>; -chomp $quote; +$_=<>; +chomp; +my $quote = uc; <>; my @answers; while (<>) { chomp; - push @answers, $_; + push @answers, uc; } my $half = $#answers / 2; my $answers; push @{ $answers->{RED} }, shift @answers while $half-- > 0; push @{ $answers->{BLACK} }, shift @answers while @answers; -my %dim = ( 'y' => 9, x => 11 ); +my %dim = ( 'y' => 10, x => 18 ); $quote =~ tr/a-zA-Z/ /cs; my $length = length $quote; @@ -44,9 +45,9 @@ } my $HEAD = <<HEAD; -\\documentclass[b5paper]{article} -\\newcommand{\\printlandscape}{\\special{landscape}} -\\printlandscape +\\documentclass[a4paper]{article} +%\\newcommand{\\printlandscape}{\\special{landscape}} +%\\printlandscape \\pagestyle{empty} \\usepackage{texdraw} \\usepackage{color} @@ -65,8 +66,8 @@ } \\begin{document} \\begin{minipage}{17cm} -\\mypuzzle{(+1.5,6.2)} -\\mypuzzle{(-5.9,6.2)} +\\mypuzzle{(+1.5,16.7)} +%\\mypuzzle{(-5.9,6.2)} \\end{minipage} \\end{document} FOOT @@ -177,4 +178,3 @@ open F, '>qotw.tex'; print F $HEAD . $tex . $FOOT; close F; - > I was thinking this might be an excellent application for PerlTex > (http://www.ctan.org/tex-archive/macros/latex/contrib/perltex/). Thanks. I will have to check that out. -- Greg Matheson, Taiwan