Project Euler problems are an exacting standard by which to judge your problem solving abilities in a programming language. I wouldn't worry too much about any current lack of facility in using J to solve such problems.
Spoiler alert. Geoff's solution: +/(>/)"1 <.@(10&^.)(2 & x:) (+%)/\(1x,1000$2) The following is what I did for that problem. I used #@":"0 instead of <.@(10&^.) to find the number of decimal digits. But the main thing is to avoid computing all the continue fractions. In J: nd=: 2 x: (+%)/\ 1,100$2x c=: +/\ >/"1 #@":"0 nd b=: c %. 1,.i.#c b +/ .* 1 1000 154.679 nd are the numerator/denominator pairs for the first 101 expansions. c gives a running count of where the number of digits in the numerator exceeds those in the denominator. b are the linear regression coefficients for what the count should be. Finally, the last phrase computes the predicted count for 1000. ----- Original Message ----- From: Geoff Canyon <[EMAIL PROTECTED]> Date: Tuesday, May 1, 2007 0:25 am Subject: [Jprogramming] Moving past the alchemist stage > I learn best by doing. I don't have any pressing programming needs > at > the moment, so I'm not in a good position to learn a new language. > > That said, I fool around at projecteuler.net. I fiddled with J a > bit > over the course of two weeks and solved three problems. A fourth > problem I came up with code that works, but too slowly (ran for a > day > with no answer). I read through the primer and sections of the > rest > of the documentation. > > In all cases I've stuck with implicit solutions. I have yet to > write > flow control in J, and all my solutions have ended up as one- > liners. > So although I feel like I've spent a lot of effort on J, so far > I've > managed to write five lines of code ;-) > > Then Mike posted about his solution to another projecteuler > problem. > I studiously avoided reading his post or any of the follow-ups. > Instead I looked at the problem and I had no clue. I had to > retreat > to my previous language to get a solution to the problem, just so > I > could look at Mike's code without it being cheating. > > Imagine my disappointment when I couldn't even figure out the code. > > Nevertheless, I've just solved a fourth projecteuler problem using > J. > That's the way it goes: I see a problem and realize that my > limited > understanding of J is sufficient, and I'm all set. But outside my > understanding is completely outside my understanding. > > > I feel like an ancient alchemist working from a dusty tome, who > can > only mix up what the formulas tell him, never anything new. I look > at > something as simple as $,: and I don't know what it will do until > I > look it up. Something like: > > mis =: monad def '>./(0:>.+)/\.y.,0' > > is a serous puzzle. > > So my question is this: how long should I expect it to take before > I > "get" J, at least enough that I can puzzle through other people's > code without having to grab the dictionary every other symbol? > > Here's my latest Project Euler code, to give you an idea where I'm > at > developmentally. I'm not saying which problem it solves, and it > doesn't meet the 1-minute rule, but look away if you want to avoid > > any taint of spoilers: > > > > > > > > > > > > > > > +/(>/)"1 <.@(10&^.)(2 & x:) (+%)/\(1x,1000$2) > > regards, > > Geoff ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
