Project Euler solutions in J

I’d known of the existence of both Project Euler and J for a long while now, but for various reasons I never got around to investigating either until recently. I decided it was time to stop indefinitely delaying learning J, and delved right into the various guides and materials on its website and wiki. Once I had had enough of reading about J’s very-difficult-to-learn syntax, I decided it was time to just try programming in J.

Project Euler

Where else did I turn to but Project Euler? Project Euler, in once sentence, is a large corpus of often mathematical programming puzzles. Think of them like brainteasers for programmers. Doing the problems is very fun, and especially good is the satisfying feeling of getting a problem right.

J

At first, my answers in J were not very good, but as I did more and more problems and looked to the solutions of other users, I found myself getting better and better. Since J isn’t the most readable language, I decided to document my solutions thoroughly and make them available for all of those learning or interested in the language (or those also doing Project Euler problems in J). I benefited so much from reading the solutions in J posted by other users on the Project Euler forums, but almost every one that I found was hardly commented, if at all. For some of these solutions, I had to return after a few more weeks of learning in order to understand them.

I intend to make my commented solutions readable to anyone who has a rudimentary understanding of J (supplemented by my post about common J code you’ll see in my answers). Eventually, I hope to add enough documentation and guides to J that a complete novice could read through them and immediately understand my solutions.

You can view the solutions I’ve posted here.

Miscellany

As for questions of whether these solutions should be posted in the first place, I believe I address those best in the About page for ProJect Euler.

These solutions were originally not just in J, though they were primarily being done to learn J. That’s why for many posts you’ll see “Solution in J” – that’s a remnant from when Python solutions also were posted. Perhaps now they don’t say that, since I’ve gotten around to removing that part…

The name is just a combination between “Project Euler” and “J,” for those not understanding the capitalization (I used parantheses in this post to emphasize it since the font I’m using is all caps for the title).