Exercises, examples and other material relating to training module Q110. This module is presented on
This section provide you with links to (and
comments on) pieces of code to performs certain
task - algorithms - that you can study if you
need to roll your own, or lift from us if you
like.
| Articles and tips on this subject | updated |
| 3451 | Why would you want to use a Perl hash? "What would I use one of THOSE for?" - a question often asked by newcomers to Perl when I first introduce hashes. Well - in writing a script to count up how many articles I've written about each subject we teach on, I came up with a perfect example.
A hash is described as an "unordered collection" ... | 2011-09-20 |
| 3102 | AND and OR operators - what is the difference between logical and bitwise varieties? Many modern programming languages have two operators for "or" and two for "and" - described as "bitwise" and "logical" operators. And you need to choose the right one in the right circumstances ... otherwise your code won't behave quite as you expect.
Bitwise OR takes the internal bit pattern of the ... | 2010-12-24 |
| 3093 | How many toilet rolls - hotel inventory and useage Running Well House Manor, we buy a lot of hotel supplies - ranging from sheets and towels when they are to be replaced, through guest soaps and toilet rolls, salt, sugar and jams which are ordered from time to time, to weekly or twice weekly orders such as fruit and fresh products and ultimately the ... | 2010-12-20 |
| 3072 | Finding elements common to many lists / arrays "What do these lists have in common". That's a common question - but what does the person asking it actually mean? Is (s)he looking for items that occur in all of the lists, but perhaps at different positions? For items that occur in two or more of the lists? For items that occur at the same position ... | 2010-11-27 |
| 3042 | Least Common Ancestor - what is it, and a Least Common Ancestor algorithm implemented in Perl Imagine you have a tree - a series of leaves which join together as you head towards the root into bigger and bigger branches. The "Least Common Ancestor" is the point at which the branches from two leaves you have chosen come together. In computing, such a tree structure is very common - files and ... | 2010-11-11 |
| 2993 | Arrays v Lists - what is the difference, why use one or the other If you want a program to run quickly through a data set (that's the sort of thing you'll be doing in heavy scientific work), you'll want the data loaded into successive memory locations - but that means that you have to know how much space to allocate before you set the data up. Otherwise, you'll find ... | 2010-10-10 |
| 2951 | Lots of way of converting 3 letter month abbreviations to numbers There are certain programming tasks that sound simple but end up fascinating ... they sound straightforward (and probably are), but it turns out there are lots of ways of doing them and you could spend a lot of time working out which was is best. One of those is converting three letter abbreviations ... | 2010-09-10 |
| 2894 | Sorting people by their names Please sort into order:
Tom Pearce
Bill Brewer
Peter Gurney
Peter Davy
Daniel Whiddon
Harry Hawk
Uncle Tom Cobbley
What would you do?
Bill Brewer
Uncle Tom Cobbley
Peter Davy
Peter Gurney
Harry Hawk
Tom Pearce
Daniel Whiddon
That's not a standard sort order for strings of text ... and if you've got ... | 2010-07-30 |
| 2617 | Comparing floating point numbers - a word of caution and a solution "Think of a number between 5 and 15.
Double it.
Add fourteen.
Halve it.
Take away the number you first thought of.
Is the result 7?"
We all played games like that as children, thinking of the number 0 ourselves so that we could do an easy calculation and impress our friends. And the result was 7 ... ... | 2010-02-02 |
| 2586 | And and Or illustrated by locks Lisa and I came across this impressive array of locks on what we have since learned is probably the back gate to the National Grid's Lacock Switching Station, about 3 miles North of Melksham. [picture/details]
Our first reaction was "wow - that must be REALLY secure - what are they doing in there?" ... | 2010-01-20 |
| 2509 | A life lesson from the accuracy of numbers in Excel and Lua Floating point numbers aren't held EXACTLY in a computer's memory - they're held to a certain accuracy (number of significant figures or binary digits to be more accurante) after which they are truncated or rounded. And this means that at time 1.0 / 3.0 * 3.0 doesn't go full circle and come back to ... | 2009-11-21 |
| 2259 | Grouping rows for a summary report - MySQL and PHP It's quite quick and easy to write a loop that goes through a mysql result set and displays the content on an HTML page (but remember security of data, size of resulting HTML page, and the need to consider special characters such as <). But what if you want a shorter report, grouping records together ... | 2009-06-29 |
| 2189 | Matching disparate referencing systems (MediaWiki, PHP, also Tcl) Yes, we are Well House CONSULTANTS and do a bit of specialist coding ...
I have a requirement on my plate at present to write a piece of code for a customer that recognises cross reference codes within a document and turns them into links. And what makes the task quite difficult is that the references ... | 2009-05-19 |
| 1949 | Nuclear Physics comes to our web site One of the major projects that we'll be undertaking in the near future is aimed at improving the findability of information on our site - you shouldn't need to know that you need a blog article dated 2nd Feb 2007 to find about the difference between a comparator and comparable in Java, nor to look up ... | 2008-12-17 |
| 1840 | Validating Credit Card Numbers It's standard practise for on line bookings these days to take credit or debit card details as a booking security, and we're no exception at Well House Manor - our hotel for business visitors to Melksham, Wiltshire. There are very many security issues involved, and I am not going to describe what we ... | 2008-10-14 |
| 1391 | Ordnance Survey Grid Reference to Latitude / Longitude I've already written about conversion of postal addresses to latitude and longitude using Google's interface - but what is I want to convert the Ordinance Survey's grid references into latitude and longitude? Google's interface doesn't support the OS units - and in any case it's "just" a a calculation. ... | 2008-08-30 |
| 227 | Bellringing and Programming and Objects and Perl For the second time this year (and it's only the second month), I find that I have a keen bell-ringer on my programming course ... he's off each evening to meet up with fellow bell-ringers in church towers in Wiltshire, and having a really good time outside course hours as well as during the day. I understand ... | 2008-05-16 |
| 1157 | Speed Networking - a great evening and how we arranged it What an excellent evening! Our Speed Networking evening, organised on behalf of the Federation of Small Businesses, drew in around a dozen inividual and a coupe of pairs with a disparate range of products to sell, and a wide variety of requirements to meet - some by using other's products and services.
Seated ... | 2007-06-23 |
| 1187 | Updating a page strictly every minute (PHP, Perl) For the Clock exercise that I mentioned in my last entry, I need to update the page once a minute. Exactly once a minute. At the start of the minute.
I'm using client pull, where the browser asks for the next page - so my basic request is:
<meta http-equiv="refresh" content="60; url=/clock/now.php">
but ... | 2007-05-14 |
| 642 | How similar are two words Do you want to help your web site user find what he's looking for on your web site, even if he mis-spells a name or word in a search? PHP provides you with three facilities - soundex, metaphones and Levenshtein distance calculations - which let you compare two words and see how similar they are when ... | 2006-06-05 |
Some modules are
available for download as a sample of our material or under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Sorting.
Coverage.
Mean time between failure.
Halflife.
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 700 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.