Introduction to computer programming concepts by way of practical examples 1: Planting hedges.

(This might make slightly more sense if you look at the individual story, and not the condensed view on the front page… Click here if you like.)

Sub PlantHedges

   Dim HedgesToPlant as hedges = 2
   Dim HedgePlants as HoneysuckleBox = 88

    for HedgesStillToPlant = 0 to HedgesToPlant
      Mark out desired hedge line with builders line and rocks
      Dig turf out of desired hedge line
      Fill hole that we've just dug with compost
      Do While HedgePlants > 0 and not at end of hedge trough
         dig hole for plant
         if big stones in soil pile just dug up
            pull out any big stones
            put stones in empty plant pot
            raise eyebrows in surprise
         end if
         push in HedgePlant
         HedgePlants = HedgePlants minus one
         put all soil just dug out of hole back around plant
         move 25cm along row
   next HedgesStillToPlant

   clean up site so next mow of lawn doesn't fire stones everywhere
   sprinkle blood and bone in the hope it keeps the hares away
   celebrate completion appropriately
   feel pretty weary and go watch rugby highlights to recover

End Sub

And that pretty much sums up our fun-day Sunday! Hope you can work out just how much fun we had in the cold, grey day. But at least that’s another 88 shrubs/trees planted. Just the last 100 of yet another size and shape to go. They’re going to follow a similar pattern though, I suspect. Good job we’ve got the perfect algorithm sorted now!

Let’s just hope we have the same level of assistance (i.e. sleeping) from munchkin when we’re planting the next instalment.

Leave a Reply

You must be logged in to post a comment.