📜 ⬆️ ⬇️

Choose a number from 1 to 99

We describe a simple procedure. Choose a natural number N from 1 to 99 and compare it with a number equal to the number of letters in the record N in the form of a word of some language. For the resulting number, repeat this operation. For the Russian language, a pretty tree is obtained, in which there are three cycles 3 → 3, 11 → 11 and 6 → 5 → 4 → 6.

image


It is interesting that in English in no more than five steps we will come to 4 and get stuck.
Here is an example of a short Ruby code that produces the graph we need for the English language.
require 'humanize' require 'rgl/adjacency' require 'rgl/dot' result = RGL::DirectedAdjacencyGraph.new 1.upto(99) { |i| result.add_edge(i.to_s, i.humanize(locale: :en).length.to_s) } result.dotty 

')


The code for French is similar.
 result = RGL::DirectedAdjacencyGraph.new 1.upto(99) { |i| result.add_edge(i.to_s, i.humanize(locale: :fr).length.to_s) } result.dotty 

In this case we come to the cycle 5 → 4 → 6 → 3 → 5.

Source: https://habr.com/ru/post/320638/


All Articles