BJC (the Beauty and Joy of Computing) online course completed – Tower of Hanoi

I just completed the 4th and final semester of BJC MOOC via edX hosted by Berkeley, San Francisco.  What a great course!  And I learned so much about basic programming, computer science and technology trends.  All for free if you wish, though I contributed some.  For teaching purposes it uses blocks which you re-arrange called Snap! which is based on Scratch developed by MIT.  A fun exercise was the Tower of Hanoi puzzle.

The rules are simple.  There are 3 pegs labelled left to right “From”, “Spare” and “To”.  The puzzle begins with various sized disks, smallest on top, stacked on the leftmost “From” peg.  The object is to move the disks over to the rightmost “To” peg subject to 3 rules: 1) only move 1 disk at a time; 2) take the top disk from one peg and place it on top of another peg; 3) you can never place a bigger disk on a smaller disk.

So if there are just 2 disks on the “From” peg, the solution is simple – just move top disk to “Spare” peg, next disk to “To” peg and then disk on “Spare” peg to “To” peg.

2 layerWith 3 disks it is a bit more complicated.  First:

3layeraThen with red and blue at “Spare”, green is moved to “To”.  The final step is:

3layerbI cut wood rectangles of descending sizes and practiced the puzzle beginning with a few pieces and progressing to 5 pieces.  When I found the recurring sequences I used a technique called recursion to implement the sequences.  Berkeley provided the backdrop and software to move the disks, all I had to do was figure which disks to move when and where.  My program is not fully automated (a remaining challenge) but it works and here is a video showing the solution to a 5 block puzzle.

 

So what has this to do with growing and sustainable living?  During the very cold and very hot months when outside work is unpleasant or unfruitful and you have time to spare, a MOOC on basic electronics or programming should be a good investment.  Once you understand a bit about electronics and software you will feel confident to install and program your own security system; install strategically placed cameras connected to a DVR to which you set up remote access via a smart phone; and with the expanding world of IoT (internet of things) you can also install perimeter sensors to provide early intruder warning, or an automated chicken coop door opener.  And you can diagnose and repair things which you might otherwise have tossed.  And becoming self reliant makes you feel good.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *