Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python, Lua and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Java, C, C++, Ruby, MySQL and Linux / Tomcat systems
 
Romeo and Julie

Romeo wants to take his girlfriend Julie out to The Jolly Judge tomorrow night, but Julie's Dad (who really doesn't approve of young Romeo) has shut her in her room on the first floor of their home, which as you can see is on the top of a substantial mound.

Being a resourceful lad, Romeo is going to nip down to his local B & Q Store and nick a couple of ladders (it's this habit of his of nicking things that has put Julie's Dad off him, by the way) to get her out.

Your task ... if you're on our Perl Course ... is to write a program to help Romeo work out how long the two ladders he'll need will be:

• The mount is 12 metres tall, and there's a good grounding about 5 metres away from the base

• the window of Julie's room is 4 metres up from the ground, but Dad has placed a line of holly bushes just under Julie's window, so Romeo is going to have to foot the ladder 3 metres out.

The algorithm you need is:
   $ladlen = sqrt($w * $w + $h * $h);
and you're asked to write that in a separate sub / in a separate file, so that you can easily re-use the same code later if you need too (since Romeo is a bit of a jack-the-lad by all accounts, it would be a shame to write code just for him rather than have it available for re-use, wouldn't it?)


There's a sample answer - source code of the main program here, and you can find the file that contains the sub here. If you ARE here because you're a Perl programmer, do have a look at the source which is rather thoroughly commented - and contains examples of things like my v our, package definition, and the use of the wantarray function.
(written 2008-12-04, updated 2008-12-03)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
P209 - Subroutines in Perl
  [3833] Learning to use existing classes in Perl - (2012-08-10)
  [3574] Perl functions such as chop change their input parameters - (2012-01-10)
  [3066] Separating groups of variables into namespaces - (2010-11-24)
  [2929] Passing a variable number of parameters in to a function / method - (2010-08-20)
  [2833] Fresh Perl Teaching Examples - part 2 of 3 - (2010-06-27)
  [2550] Do not copy and paste code - there are much better ways - (2009-12-26)
  [2069] Efficient calls to subs in Perl - avoid duplication, gain speed - (2009-03-07)
  [1860] Seven new intermediate Perl examples - (2008-10-30)
  [1850] Daisy the Cow and a Pint of Ginger Beer - (2008-10-21)
  [1826] Perl - Subs, Chop v Chomp, => v , - (2008-10-08)
  [1784] Global - Tcl, PHP, Python - (2008-09-03)
  [1782] Calling procs in Tcl and how it compares to Perl - (2008-09-02)
  [1202] Returning multiple values from a function (Perl, PHP, Python) - (2007-05-24)
  [1163] A better alternative to cutting and pasting code - (2007-04-26)
  [969] Perl - $_ and @_ - (2006-12-07)
  [775] Do not duplicate your code - (2006-06-23)
  [588] Changing @INC - where Perl loads its modules - (2006-02-02)
  [531] Packages in packages in Perl - (2005-12-16)
  [357] Where do Perl modules load from - (2005-06-24)
  [308] Call by name v call by value - (2005-05-11)
  [96] Variable Scope - (2004-10-22)


Back to
Progress Bar Techniques - Perl
Previous and next
or
Horse's mouth home
Forward to
Flurinci knows Raby Lae PHP and Jeve
Some other Articles
Introduction to Object Oriented Programming
Preventing ^C stopping / killing a program - Perl
Making it all worthwhile
Flurinci knows Raby Lae PHP and Jeve
Romeo and Julie
Progress Bar Techniques - Perl
Transition
Perl Socket Programming Examples
Out of memory during array extend - Perl
Why I remember East Grafton
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2018: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/1921_Rom ... Julie.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat