There is a python based implementation available on Github for Discrete HMM ( most likely state sequence given observed sequence x # using the Viterbi algorithm ), The code is quite step by step, see whether going through the example helps the understanding.