[Neworleans-pm] Fwd: Perl Quiz-of-the-Week #19
Brett D. Estrade
estrabd at yahoo.com
Wed Jul 7 14:16:56 CDT 2004
=====
http://www.brettsbsd.net/~estrabd
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
----- Original message -----
From: "Belden Lyman" <blyman at iii.com>
To: perl-qotw at plover.com
Date: Wed, 07 Jul 2004 12:49:53 -0400
Subject: Perl Quiz-of-the-Week #19
IMPORTANT: Please do not post solutions, hints, or other spoilers
until at least 60 hours after the date of this message.
Thanks.
IMPORTANTE: Por favor, no enviéis soluciones, pistas, o cualquier otra
cosa que pueda echar a perder la resolución del problema hasta
que hayan pasado por lo menos 60 horas desde el envío de este
mensaje. Gracias.
IMPORTANT: S'il vous plaît, attendez au minimum 60 heures après la
date de ce message avant de poster solutions, indices ou autres
révélations. Merci.
WICHTIG: Bitte schicken Sie keine Lösungen, Tipps oder Hinweise für
diese Aufgabe vor Ablauf von 60 Stunden nach dem Datum dieser
Mail. Danke.
BELANGRIJK: Stuur aub geen oplossingen, hints of andere tips in de
eerste 60 uur na het verzendingstijdstip van dit
bericht. Waarvoor dank.
VNIMANIE: Pozhalujsta ne shlite reshenija, nameki na reshenija, i
voobshe lyubye podskazki v techenie po krajnej mere 60 chasov
ot daty etogo soobshenija. Spasibo.
Qing3 Zhu4Yi4: Qing3 Ning2 Deng3Dao4 Jie1Dao4 Ben3 Xin4Xi2 Zhi1Hou4 60
Xiao3Shi2, Zai4 Fa1Biao3 Jie3Da2, Ti2Shi4, Huo4 Qi2Ta1 Hui4
Xie4Lou4 Da2An4 De5 Jian4Yi4. Xie4Xie4.
----------------------------------------------------------------
When you think of a sailing vessel, chances are good that you think
of a bermudan rig, which has two triangular sails arranged like this:
|*
| *
| *
| *
*| *
* | *
* | *
* | *
* | *
* | *
* | *
* | *
* | *
* | *
* | mainsail *
* jib | *
* |________________*
* |
--------------|
,--------------|------------------.
front \ / back
\_____________________________/
(A bermudan-rigged vessel)
If you've ever seen a Chinese junk, a Norse longboat, or a Polynesian
sailing outrigger, then you know that there are many other sail shapes.
For example, many popular small sailing dinghies use a lateen sail
because it is easy for a single person to manage. Notice the lack of
right angles:
| /\
| ,/ \.
| /' `\
|,/ \.
/' `\
,/ \.
/' lateen `\
,/ mainsail \.
/' `\
/ \
----------------------------
|
,--------|------------------------.
front \ / back
\_____________________________/
(A lateen-rigged vessel)
Finally, there are non-triangular sails, such as a gaff-rigged sail.
These look similar to a triangular bermudan mainsail, but have an
extra boom (the "gaff") at the *top* of the sail:
gaff--> /*
/ *
|/ *
| *
| *
| *
| *
| *
| *
| *
| *
| *
| gaffed *
| mainsail *
| *
|__________________*
|
|
,-----------|--------------------.
front \ / back
\_____________________________/
(A gaff-rigged vessel)
You will write a program, sailarea.pl, capable of calculating the
sail area of triangular and gaff-rigged sails. The program is run
as follows:
sailarea.pl filename [scale]
Scale, if given, is a percentage by which to increase or decrease the
calculated sail area. If not given, scale defaults to 100% (no scaling).
The input file contains the coordinates of each sail in the sailplan;
units are implied to be in centimeters. Blank and commented lines are
valid.
sailname.a: x,y
sailname.b: x,y
sailname.c: x,y
anothersail.a: x,y
anothersail.b: x,y
anothersail.c: x,y
The various sail shapes cannot be intuited from 'sailname'. 'sailname'
exists only as a tag to associate various points with a single sail.
Assume that the sail is gaff-rigged if it has four coordinates, and
triangular if it has only three.
For example, given bermudan.txt:
# coordinates for a bermudan rig
mainsail.a: 0, 450
mainsail.b: 0, 50
mainsail.c: 200, 50
jib.a: 0,400
jib.b: 150,0
jib.c: 0,0
When run as
sailarea.pl bermudan.txt
the program responds with individual sail areas and the total sail
area:
mainsail.area: 40000 cm^2
jib.area: 30000 cm^2
total.area: 70000 cm^2
More information about the NewOrleans-pm
mailing list