I've solved 84 of the Project Euler problems, mostly in Haskell. I am now going back and trying to solve in J some of those I already solved in Haskell, as an exercise in learning J.
Currently, I am trying to solve Problem 56. Let me stress that I already know what the right answer is, since I've already solved it in Haskell. It's a very easy, trivial problem. I will not give the answer here.
Here is my solution in J:
digits =: ("."0)@":"0 eachDigit =: adverb : 'u@:digits"0' NB. I use this so often I made it an adverb. cartesian =: adverb : '((#~ #) u ($~ *:@#))' >./ +/ eachDigit x: ^ cartesian >: i. 99
This produces a number less than the desired result. In other words, it's wrong somehow. Any J-ers out there know why? I'm baffled, since it's pretty straightforward and totally brute force.