Friday, August 8, 2014

Problem 100 - To the Moon(Script)

So, problem 100. After the flurry of work that was getting through problems 98 and 99, the work on this one was fairly unexciting. I expressed the problem in terms of a quadratic diophantine equation, observed that such things have been studied by mathematicians enough for methods to solve them to be widely available online, so then I solved my equation and wrote some short code that iterates through solutions until finding the one desired for this problem.

The language I used was Moonscript, which I don't have much to say about, as I haven't actually written much in it, as can be seen below. However, it was very easy to set up, which was nice after I failed to build two programming languages, this one just had an online compiler.

So yeah, this was my 100th problem. A reflective post is upcoming.

Code runs in about 378ms on the interwebs.
X0 = 1
Y0 = 1
while Y0 < 1000000000000
  X1 = 3*x0 + 2*Y0 - 2
  Y1 = 4*x0 + 3*Y0 - 3
  X0 = x1
  Y0 = Y1
 
print X0

No comments:

Post a Comment