[ prog / sol / mona ]

prog


The Forced Indentation Of Code

117 2022-06-24 11:35

Since the sum of the geometric series of ratio 1/N is N / (N - 1), our sum becomes 4/3. Substituting into the numerator and expanding the square in the denominator we get:

  36 * Q + 5 * Q * 4/3
-------------------------
64 * Q - 16 * sqrt(Q) + 1

The latter two terms in the denominator, a constant and a term proportional to 2n, become insignificant compared to the dominant term proportional to 2(2*n) as n grows, so in the limit they do not influence the ratio and can be ignored. Our ratio thus becomes (36 + 20/3) / 64 which is 2/3.

Empirically, without simplifying the denominator or anything else:

>>> C = lambda n: 41 if n < 1 else 4 * C (n - 1) + 5
>>> D = lambda n: (2 ** (3 + n) - 1) ** 2
>>> R = lambda n: (lambda a, b: (a / b, a, b)) (C (n), D (n))
>>> print ("\n".join (map (lambda kr: "{}. {} = {} / {}".format (kr [0], kr [1] [0], kr [1] [1], kr [1] [2]), map (lambda k: (k, R (k)), range (10)))))
0. 0.8367346938775511 = 41 / 49
1. 0.7511111111111111 = 169 / 225
2. 0.708636836628512 = 681 / 961
3. 0.6875787351977828 = 2729 / 3969
4. 0.6771033542067084 = 10921 / 16129
5. 0.6718800461361015 = 43689 / 65025
6. 0.6692720999077056 = 174761 / 261121
7. 0.6679690672690389 = 699049 / 1046529
8. 0.667317787728488 = 2796201 / 4190209
9. 0.6669922073585077 = 11184809 / 16769025
>>> print ("\n".join (map (lambda kr: "{}. {} = {} / {}".format (kr [0], kr [1] [0], kr [1] [1], kr [1] [2]), map (lambda k: (k, R (k)), range (10, 51, 5)))))
10. 0.666829432049174 = 44739241 / 67092481
15. 0.6666717529345381 = 45812984489 / 68718952449
20. 0.6666668256123908 = 46912496118441 / 70368727400449
25. 0.6666666716337204 = 48038396025285289 / 72057593501057025
30. 0.6666666668218871 = 49191317529892137641 / 73786976277658337281
35. 0.6666666666715173 = 50371909150609548946089 / 75557863725364567605249
40. 0.6666666666668183 = 51580834970224178120796841 / 77371252455318674995150849
45. 0.6666666666666714 = 52818775009509558395695966889 / 79228162514263774643590529025
50. 0.6666666666666669 = 54086425609737787797192670096041 / 81129638414606663681390495662081
>>> 

So, even though it may not be intuitively or visually obvious, as the recursion level increases the pattern of >>113 has two thirds of its enclosing area covered by tiles.

267


VIP:

do not edit these