Visualizing number of letters in a number
Edgar created this interesting visualization inspired by a blog post by @matthen2. The concept is simple.
- Start with a number between 1 and 99: e.g. "42"
- Spell out the number: "forty-two"
- Count the number of letters in the spelled out number, excluding hyphen: "8"
- Repeat steps 2 and 3 until the same number is reached: "eight" → "5" → "five" → "4" → "four" → "4"
With Edgar's code, you can visualize this for all numbers from 1 to 99. To get the word representations of the numbers, I'm using another Pick from the past, Number to Words.
numbers = 1:99;
number_words = cell(size(numbers));
for id = 1:length(numbers)
number_words{id} = num2words(numbers(id));
end
plotDirectedGraph(numbers,number_words)
I modified Edgar's plotDirectedGraph function to animate the creation of the graph.
- 범주:
- Picks
댓글
댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.