[source code included]
Exploring the Domain
I started by organizing the data I had already collected into a spreadsheet and extending it, which resulted on the following table:
Table 1. Data gathering
Next, I went for some sort of validation of these data, and drew the following figure:
Figura 1. Equilateral triangle with 7 unit measures side
Such a prototype, although rudimentary, allowed the verification and validation of the data collected before (as for a 7-side triangle).
The table below defines the composed triangles inside Figure 1.
Tabela 2. Triângulos compostos
Such actions made me see that I was on the right track. Therefore, I went back to the sheet and started to imagine what formula would give an answer to the question proposed by the contest, which can be phrased as follows:
Given an L side equilateral triangle, determine the total number of triangles within it.
It is all about implementing a function that returns 118 when the user provides seven as input, right? Well, I am not so sure… By looking to the data more closely, we can clearly note that only 28 of those are actually real, concrete instances. Isn’t it?
Figure 2. Real, unitary (instantiated) triangles inside a 7-side triangle
All of the others are just optical illusion, or composed by a mix of real (in blue) and “virtual” – nonexistent, illusionary, apparent, or fake – triangles. Right?
Thus, a more accurate and complete answer to the proposed challenge should be represented by something more or less like this:
Listing 1. Stats report
As we can see, there are (at least) two answers to the proposed question. The “right”, more appropriate one will depend on the contextual needs and objectives, which determine purposes and reasons, provide the requirements, and direct our efforts and strategies.
In fact, there is a third valid answer that could be even more recommendable – depending on the client’s specifications. Later I explore this alternative.