1 year ago 🥁 for day 328, 2020 with 529 words.


Exercise: 2 mile walk to the shops and back.

Keyboard: more C G D+, C G F, E; E F G A; G

I was playing the notes above when I thought, maybe I'll try playing them as major chords of each note. Didn't sound right. So I thought, OK, play them as 3rd's - I think that is the technical term for the first two notes of the major chord. It sounded OK, but not great. So, I thought, I'll try playing them as 5th's, which if I am correct - and musical terminology is definitely not my thing - is the first and last note of the major chord.

It was at this point that I discovered something very interesting about how those original first three notes were constructed, how they sounded and why they sounded so good together.

The pair of notes from the first and last notes of the major cords of them were as follows:

C & G

G & D+

D+ & A+

The last note of the first cord was the first note of the second cord and the last note of the second cord was the first note of the third cord. No wonder it sounded so perfect as individual notes, they were exactly a fifth apart.

Last year I wrote a long series of articles about programming languages, ending with a list of languages I haven’t programed in. One that is all the rage - even my kids know this one better than I - is python. I’d always had an interest in learning the language, although it seemed that it never offered anything that other scripting languages - such as PHP - offered. There are places where you can’t run PHP, but Python is an option - such as AWS Lamba’s - so I figured one day I would learn some of it.

Today turned out to be the day. A friend asked me for some help “dry running” some python code for some homework and I suggested that we modify the code to get it to generate the results for us instead of having to do the hard work ourselves. It was sort of a cheat maneuver but hey, we’re engineers, we use the tools we have. He wasn’t sure what I was suggesting, or how to go about it, so given the code he had I set about modifying it while knowing nothing about the syntax of the python language but knowing that what I didn’t know I could google.

Thus I present to you, my first Python program - to calculate a fibonacci number using a recursion implementation, whilst also calculating how many times the function was called. Finding out how many times it was called was the hand exercise.

count = 0

def fib(n):
    global count
    count += 1
    if n < 2:
        return n
        return fib(n-2) + fib(n-1)

def fibCount(n):
    global count
    count = 0
    msg = 'fib(' + str(n) + ') => ' + str(fib(n))
    msg += ' with ' + str(count) +  ' invocations of the fib(n) function'


Yes, I know, global variables. Fixing that is left as an exercise for the reader of this post.

User Photo

By Yorick Phoenix 🥁

Chief WriteTogether Bug Finder & character stringer. Generally, to create computer code, but sometimes actual words and paragraphs. Listens to lots of music, takes lots of photos, & invests in stocks for the long haul.

Get Yorick Phoenix's newsletter

Almost there! Check your inbox and click the link to confirm.

Subscribe to Yorick Phoenix's latest writing to get it right in your inbox.