Yes, my code uses 1 and 0 for stressed and unstressed syllables. You show 2 and 1, which amounts to the same thing.
I'm not sure that I agree entirely with the statement that shorter code indicates a more proficient programmer. In this case, the code needs to display the metrical pattern consistently for any given input, so how rarely it makes mistakes is also a measure of code quality. Other considerations would be readability of the diagram, readability of the code itself, and maintainability of the program.
I see that your comment refers to an article about meter in Arabic verse. It is interesting that Arabic verse can also be analyzed systematically. It is difficult to compare the metrical systems of languages. Latin and English, for instance, share a lot of vocabulary and a common Indo-Eurpoean origin, but their metrical systems are vastly different. Writing a program that determines the meter of verse also will be influenced by how closely the written version of the language matches the phonetics. In English, the spelling is notoriously not aligned with the phonetics. In Spanish, Italian, Latin, and Hebrew (the few languages I know about well enough to make this statement), the phonetics, including the stresses, can be mostly determined by the way a word is written.
I am currently working on code to update and improve the program shown in this post. I hope to be done with it by June, fingers crossed.