With some great tips to help me along, Ive done as follows #5: Find a number evenly divsable with all ints from 1 - 20
*./ >:i.20 #6: Difference between Sum of the squares and square of the sum (from the ints 1 - 100) This one really had me eating my words regarding combining functions for a while. Until I discovered [: cap, I struggled to make this simple algo run. I even tried naming the components to no avail. Eventually I ended up with (([:*:+/)-([:+/*:)) >:i.100 #7: Find the 10001.th prime p: <: 10001 #8: Find the greatest product of 5 consecutive numbers in a 1000-digit number This was a bit disappointing for me, as I thought I could solve it straight off, but quickly ran into all sorts of trouble. I started out just working with a subset of the entire number data=: ": 73167176531330624919225119674426574742355349194934x With that as a string representation, I figured that partitioning it would be simple 5<\ data +-----+-----+-----+-----+-----+ |73167|31671|16717|67176|71765|....... +-----+-----+-----+-----+-----+ And it was. So all thats left is calculating the product of the individual cells. Which I had hoped was something like */\"0 (5<\ data) But for some reason that just adds a leading axis and does nothing to the individual cells (*/\"0)"0 ,(5<\ data) +-----+ |73167| +-----+ |31671| +-----+ |16717| +-----+ |67176| +-----+ ... So my question might essentially be narrowed down to this: How do I apply */ to the digits of each window? Then just to follow up on Mr. Brons comment: I might be spoiled from my Clojure experience, but I find it very inhibiting to have strict evaluation as my only option. Lazy evaluation is not some small finnimbrun, but it effectively alters the way you model code. Is this on the drawing board for the next release of J, or has someone held to a floccinaucinihilipilification of lazy-seqs ? Anyway, that made #9 more complex than it needed to be. Any comments hints, criticisms etc of the code is most welcomed. /Lau ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
