Implementation of the HM Algorithm W as a learning exercise