Sorting is probably the most common type of algorithm in programming. A sorting algorithm puts elements of a list in a certain order. The most-used orders are numerical, and alphabetical. It’s extremely useful in many applications, because sorted data can be searched or merged very quickly (e.g. by binary search). A sorted data set is one where every item…
Animated Tower of Hanoi
A Quick Introduction to Python 3 Programming
This Quick Introduction to Python 3 aims to teach you just enough Python, so that you can get started in computer programming! First, you’ll want to install Python 3 or you can use the in-browser Trinket near the bottom of the page – just edit the code directly in there. If you have Python installed, you can…
Playing in Python with Pickover’s Premise per Pi
My favourite tweeter is Clifford A. Pickover. His tweets are delightful nuggets of math, physics & more. I have a copy of his fascinating The Physics Book. However, in these tweets, he claims that the string 44899 first occurs in pi at position 44899, counting from the first digit after the decimal point. I thought it might be…
A Graphical Dice Simulator
This PyGame program simulates the roll of a die (or dice if you prefer). It’s a fairly simple, straightforward thing to do, though it may be worth noting that the spots display is oh-so-slightly clever. Some spots appear in more than one number, e.g. the middle spot is in all the odd numbers, hence the…
A Python Dictionary
Editors & IDEs
A text editor is all very well for simple notes, but for programming the basic text editor will quickly become very tedious. For example, Python uses code indentation to indicate ‘blocks’, using tabs or spaces (4 spaces recommended for each level of indentation). It will help a lot if the editor you use ‘knows’ Python!…
Make ‘Computer Music’ with a very small program!
This is a fun little program to generate ‘computer music’, specifically ‘bytebeats’ which sound like the chip music featured in the early computer games. As is well-known, sound can be digitised and stored in computers. Conversely, numbers can be converted to sound. But those numbers don’t have to come from a file, they can be generated on the…
Compute Average Heights
This is a simple program to compute average heights. In a loop, it prompts the user for heights, inputs a text string and converts it to a ‘real’ number, sums them, and divides by the number of heights. Exit is signalled by negative height, after which the sum of the numbers is divided by the number of…
Binary Search
Naive Mandelbrot Set
This is your basic Mandelbrot Set plotter. Very little effort made to speed it up, except for plotting top & bottom pixels together as they’re mirrored across the x-axis. Later I’ll show you some much faster programs! The heart of this program is the iteration of z2+c where c is a point in the complex…
FizzBuzz
This is apparently a well-known interview question (but not one I was ever asked). Print the numbers 1 to 100, but replace every number divisible by 3 with “Fizz”, every number divisible by 5 with “Buzz”, and every number that’s divisible by both 3 & 5 with “FizzBuzz”. Apparently many people have difficulty with it.…
How the Web works, in Amazing Detail!
WordPress Tips & Tutorials
This WordPress Tips & Tutorials article offers a few tips gained from a few years of experience with building and tuning WordPress websites. It also links to further articles for optimising WordPress, and some tutorials. WordPress started in 2003 as a free, open-source website building and blogging tool. As of Jan 2012, over 24% of…
LFCS: Linux Foundation Certified System Administrator
This is an effort to provide a set of links to material that should be helpful in studying for the Linux Foundation Certified System Administrator (LFCS) exam. Their site only provides a list of the required topics, without going into any detail, so I can’t be sure if these links will cover too much or too little depth…