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 アカウントにサインインするか新しい MathWorks アカウントを作成します。