It can be observed that if we number the rings with odd numbers n (1,3,5..), then (not counting the innermost ring), the numbers in the corner of the nth ring are: (n - 2)^2 + (n - 1), (n - 2)^2 + 2*(n - 1), (n - 2)^2 + 3*(n - 1), (n - 2)^2 + 4*(n - 1) taking the sum of these numbers and converting to a more reasonable index n (0,1,2,..) we get that the sum of the corners in the nth ring (for n > 0) is 4*(2(n-1) + 1)^2 + 20n moving some terms around and adding in a 1 for the innermost ring, we get that the sum of the corners of the first 501 rings (and thus the sum of the diagonals of the 1001x1001 spiral) is 1 + 4*sum{from n = 1 to 500} (4n^2 + n + 1)I am not sure if the recent problems have been more suited to pencil and paper solutions than earlier problems, or working with Befunge has just made me want to look for one more...but hopefully after Befunge is done, programming will become the norm again also. I feel like I am almost there with Befunge, but it is really hard to tell when debugging is impeded by the fact that you can only see printed out statements if the program successfully terminates, and also you have to deal with the fact that it might be near impossible to add a print statement in a certain place to debug because it would throw off the alignment of your code.
Thursday, August 15, 2013
Problem 28 - more straight up math, no programming
I am approaching a solution for problem 27 in Befunge...I am not entirely sure how close I am though, because Befunge isn't exactly an easy language to debug. Anyway, while I was working through problem 27, I decided to look at problem 28. Again, this problem wound up being a lot easier to solve using math than with programming, so while I keep hacking away at Befunge, yet another problem has been crossed off the list without having to cross a language off the list. My solution goes like this:
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment