I have used Mathematica very, very little in the past (twice for a physics class), but I had few difficulties with this problem. My only real difficulties were unfamiliarity with the user interface of Mathematica, and my inability to find any relative path for the data file (note for anyone deriving information about my filesystem from the absolute path, this problem was solved on a very infrequently used Windows partition of my laptop)
Hopefully tomorrow (or, oh, look at how late it is, later today), I will be ale to reach 100 with a yet to be determined language.
I didn't feel like figuring out how to do timing in Mathematica, but the below code runs pretty quickly on my machine.
ans = 0 maximum = 0 list = ReadList["C:\\Users\\Sam\\Desktop\\Euler\\base_exp.txt", Number] For[i = 1, i <= Length[list], i = i + 2, next = Log[Part[list, i] * 1.0] * Part[list, i + 1] ; ans = If[next > maximum, (i + 1) / 2, ans]; maximum = Max[next, maximum] ] Print[ans]
No comments:
Post a Comment