Number to Glyph
I was doing leetcode the other day(yes, to find an internship), and ran into a problem that asks to convert numbers to roman number. Before writing that program, I certainly didn’t know the exact rule of this conversion. I spent quite a bit if-else statement in order to capture all the conditions that the convertion could involve.
And I was quite shocked to see that the answer is much simpler than I imagined. You write a dictionary, look it up, then you are done!(Try it yourself)
Besides the inevitable feeling of defeat(go programmers!), I also had a spark: “what if the dictionary contains shapes instead of roman numeral characters?”
So that’s exactly what I did. I encoded “I” with circle, “V” with rectangle and etc. To avoid two circles with the same size (e.g., for II, or III), I only determined the type (e.g. rectangle, circle, ellipse), but not the property (e.g. size, rotation).
The results are quite interesting. I will post some of them here and you can go to the live link here